var ConciseDesc = getCookie();
var YesCB = "/img/build/buttons/checkyes.gif";
var NoCB  = "/img/build/buttons/checkno.gif";
ConciseDesc = ConciseDesc == 1 ? 1 : 0;
var urlRegExp = /^(http:\/\/)?(www\.)?gwskills\.net\/(professions\/((assassin|dervish|elementalist|monk|mesmer|necromancer|paragon|ranger|ritualist|warrior)\/\?)|index(\/?)|tcode)/i;
var BCwarning = /^(http:\/\/)?(www\.)?gwskills\.net\/tcode\/editor/i;

function toogle_desc(mode)
{
	var showT = document.getElementById("set_classic");
	var showC = document.getElementById("set_concise");
	var CRC = 0;
	
	if (mode != ConciseDesc && BCwarning.test(document.location.href))
	{
		if (!confirm("Внимание! Все сделанные изменения будут потеряны. Вы действительно хотите переключить стиль описаний?"))
		{ return false;}

	}

	// Включаем краткие описания
	if (mode == 1 && ConciseDesc == 0)
	{
		showT.src = NoCB;
		showC.src = YesCB;
		ConciseDesc = 1;
		setCookie(1);
		CRC = 1;
	}
	// Включаем полные описания
	else if (mode == 0 && ConciseDesc == 1)
	{
		showT.src = YesCB;
		showC.src = NoCB;
		ConciseDesc = 0;
		setCookie(0);
		CRC = 1;
	}
	
	if (CRC == 1) 
	{
		if (urlRegExp.test(document.location.href))
		{
			document.location = document.location.href; 	
		}
	}
}

function getCookie() 
{
	var prefix = "GWS_Concise=";
	var cookieStartIndex = document.cookie.indexOf(prefix);
	if (cookieStartIndex == -1) { return 0; }
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
	if (cookieEndIndex == -1) { cookieEndIndex = document.cookie.length; }
	return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function setCookie(value) 
{
	value = value == 1 ? 1 : 0;
	var curCookie = 'GWS_Concise=' + value + '; EXPIRES=Friday, 31-Dec-20 23:59:59 GMT; PATH=/';
	document.cookie = curCookie;
}