function HideDebugger(id) 
{
	setCookie("debug_status_"+id, "hided", new Date(2299,1,1), "/");
	if ( document.getElementById('debug_'+id) ) 
	{
		document.getElementById('debug_'+id).style.display 			= "none";
		document.getElementById('debug_hide_butt_'+id).style.display 	= "none";
		document.getElementById('debug_show_butt_'+id).style.display 	= "";
	}
}

function ShowDebugger(id) 
{
	setCookie("debug_status_"+id, "showed", new Date(2299,1,1), "/");
	if ( document.getElementById('debug_'+id) ) 
	{
		document.getElementById('debug_'+id).style.display 			= "";
		document.getElementById('debug_hide_butt_'+id).style.display 	= "";
		document.getElementById('debug_show_butt_'+id).style.display 	= "none";
	}
}

function DebuggerCheck(id)
{
	if(getCookie("debug_status_"+id) == "hided") HideDebugger(id);
}

function setClass(obj, cl)
{
    if (obj.className!=cl) obj.className = cl;
}

function setClassById(objid, cl)
{
	if (!cl) cl = '';
	document.getElementById(objid).className = cl;
}


function gotoURL(url, target, callback)
{
	if (!url) url = "/";
	if(typeof callback == "function") callback(url);
	if(target && target!='_self')
	{
		popupURL(url, target);
	}
	else
	{
		if (window.event)
		{
			var src = window.event.srcElement;
			if((src.tagName != 'A') && ((src.tagName != 'IMG') || (src.parentElement.tagName != 'A'))){
				if (window.event.shiftKey) window.open(url);
				else document.location = url;
			}
		} 
		else 
		{
			document.location = url;
		}
	}
}

function popupURL(url, target)
{
	window.open(url, target);
}

function chbCheckAll(formObj, checkName, checkVal)
{
	var el = formObj.elements;
	for (count = 0; count < el.length; count++)
		if (el[count].name == checkName + '[]')
			if (!el[count].disabled) el[count].checked = checkVal;
}

function chbExamAll(formObj, checkName, resName)
{
	var checkCount = 0;
	var boxCount = 0;
	var el = formObj.elements;

	for (count = 0; count < el.length; count++)
		if (el[count].name == checkName + '[]')
		{
			boxCount++;
			if (el[count].checked || el[count].disabled) checkCount++;
		}
	formObj.elements[resName].checked = (checkCount == boxCount);
}

function chbIsAllEmpty(formObj, checkName)
{
	var checkCount = 0;
	var boxCount = 0;
	var el = formObj.elements;

	for (count = 0; count < el.length; count++)
		if (el[count].name == checkName + '[]')
		{
			boxCount++;
			if (el[count].checked) checkCount++;
		}

	return(checkCount == 0);
}

function chbIsOnlyOne(formObj, checkName)
{
	var checkCount = 0;
	var boxCount = 0;
	var el = formObj.elements;

	for (count = 0; count < el.length; count++)
	{
		if (el[count].name == checkName + '[]')
		{
			boxCount++;
			if (el[count].checked) checkCount++;
		}
	}

	return(checkCount == 1);
}

function setCookie(name, value, expires, path, domain, secure)
{
	var curCookie = name + "=" + escape(value) +
                ((expires) ? "; expires=" + expires.toGMTString() : "") +
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                ((secure) ? "; secure" : "");

	if ( (name + "=" + escape(value)).length <= 4000)
		document.cookie = curCookie
}

function getCookie(name)
{
        var prefix = name + "=";
        var cookieStartIndex = document.cookie.indexOf(prefix);

        if (cookieStartIndex == -1)
                return null;

        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 deleteCookie(name, path, domain)
{
	if (getCookie(name))
	{
		document.cookie = name+"="+
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                "; expires=Thu, 01-Jan-70 00:00:01 GMT"
	}
}