function setClass(obj, cl){
	if (obj != null)
		if (obj.className!=cl) obj.className = cl;
}

function setClassById(objid, cl){
	if (!cl) cl = '';
	document.getElementById(objid).className = cl;
}

function changeDisplayById(objId){
	for (c = 0; c < changeDisplayById.arguments.length; c++){
		obj = document.getElementById(changeDisplayById.arguments[c]);
		if (obj.style.display == 'none') obj.style.display = '';
		else obj.style.display = 'none';
	}
}

function gotoURL(url){
	if (!url) url = "/";
	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){
	window.open(url);
}
*/
function popupURL(url){
	window.open(url,'','resizable=yes, scrollbars=yes,width=600,height=500');
}

function OpenPopup(url, params ,w ,h){
	var width = (w ? w : 366);
	var height = (h ? h : 250);
	return showModalDialog(url, params, 'dialogWidth:' + width + 'px; dialogHeight:' + height + 'px; resizable:no; status:no;help:no');
}


function OpenStandartPopup(url, n, w, h){
	var width = (w ? w : 366);
	var height = (h ? h : 250);
	var name = (n ? n : '');
	var handler = window.open(url,n,'resizable=yes, scrollbars=yes,width=' + width + ',height=' + height + '');
	handler.focus();
	return handler;
}


function getLeftPos(obj){
	var res = 0;
	while (obj){
		res += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return res;
}

function getTopPos(obj){
	var res = 0;
	while (obj){
		res += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return res;
}

function CheckAll(checkName, checkVal)
{
	var checkCount = 0;
	var el = document.forms[0].elements;
	for (count = 0; count < el.length; count++)
	{
		if (el[count].id == checkName + checkCount)
		{
			if (!el[count].disabled)
			{
				el[count].checked = checkVal;
			}
			checkCount++;
		}
	}
}

function GetSelected(checkName)
{
	
	var el = document.forms[0].elements;
	var arr = new Array();
	var boxCount = 0;
	for (count = 0; count < el.length; count++)
	{
		var elem = el[count];
		if (elem.id == checkName + boxCount)
		{
			boxCount++;
			if (elem.checked && !elem.disabled)
				arr.push(elem.value);
		}
	}
	return arr;
}

function ExamAll(checkName, resName)
{
	var checkCount = 0;
	var boxCount = 0;
	var el = document.forms[0].elements;
	for (count = 0; count < el.length; count++)
	{
		if (el[count].id == checkName + boxCount)
		{
			boxCount++;
			if (el[count].checked || el[count].disabled) checkCount++;
		}
	}
	
	if (document.forms[0].elements[resName])
	{
		document.forms[0].elements[resName].checked = (checkCount == boxCount);
	}
}

function exitProcedure() 
{
	if(opener)
	{
		opener.location.reload(); 
	}
	window.close(); 
}



function chbIsAllEmpty(checkName)
{
	var checkCount = 0;
	var boxCount = 0;
	var el = document.forms[0].elements;
	
	for (count = 0; count < el.length; count++)
	{
		if (el[count].name == checkName + boxCount)
		{
			boxCount++;
			if (el[count].checked) checkCount++;
		}
	}
	
	return (checkCount == 0)
}
function setCheckBox(drop_c){
	document.getElementById(drop_c).checked = false;
}

function control_perm(obj0, obj1) {
	if (obj0.checked)
		obj1.checked = false;
}