function checkboxclick(element){
	id=element.id;

	if ((element.id.substr(0,3)=='tc_')||(element.id.substr(0,3)=='tf_')){ //clicknato na text-a
		id=element.id.substr(3,element.id.length);
		document.getElementById(id).checked=!document.getElementById(id).checked;
	}

	if (id.substr(id.length-1,1)=='_'){
		idd=id;
		if (document.all || document.getElementById) {
			navRoot = document.getElementsByTagName("input");
			for (i=0; i<navRoot.length; i++) {
				node = navRoot[i];
				if (node.id.substr(0,idd.length)==idd)	{
					if (!node.disabled)
						node.checked=document.getElementById(idd).checked;
				}
			}
		}
	}else{
		rx=new RegExp('(_[^\_]*?)+_([^\_]*?)$');
		if (rx.exec(id)){
			rx=new RegExp('_([^\_]*?)$');
			idd=id.replace(rx,'_');
			document.getElementById(idd).checked=false;
			chk=true;
			if (document.all || document.getElementById) {
				navRoot = document.getElementsByTagName("input");
				if (navRoot.length>1)for (i=0; i<navRoot.length; i++) {
					node = navRoot[i];
					if ((node.id.substr(0,idd.length)==idd)&&(node.id!=idd))	{
						if (!node.disabled){
							chk=chk&&node.checked;
						}
					}
				}
			}
			document.getElementById(idd).checked=chk;
		}
	}
}

function check_all(id) { //checkva vsi4ki enabled checkboxove na koito id-to zapo4va s "id"

	if (document.all || document.getElementById) {
		navRoot = document.getElementsByTagName("input");
		for (i=0; i<navRoot.length; i++) {
			node = navRoot[i];
			if (node.id.substr(0,id.length)==id)	{
				if (!node.disabled)
					node.checked=document.getElementById(id).checked;
			}
		}
	}
}

function uncheck_all(id) { //checkva vsi4ki enabled checkboxove na koito id-to zapo4va s "id"
	var p=true;
	if (document.all || document.getElementById) {
		navRoot = document.getElementsByTagName("input");
		for (i=0; i<navRoot.length; i++) {
			node = navRoot[i];
			if (node.id.substr(0,id.length)==id && node.id!=id){
				if (!node.checked) p=false;
			}
		}
		document.getElementById(id).checked=p;
	}
}

function getObjectById(id) {
    for (i=0; i<document.all.length; i++) {
        if (document.all(i).id==id) {
            return document.all(i);
        }
    }
}

function startList2() {

		if (document.all&&document.getElementById) {
			navRoot = document.getElementsByTagName("li");
			for (i=0; i<navRoot.length; i++) {
				node = navRoot[i];

				/*if ((node.className=='ktr_1')||(node.className=='ktr_2')){
					node.onmouseover=function() {
						this.className+=" over";
					}
					node.onmouseout=function() {
						this.className=this.className.replace(" over", "");
					}
				}*/
				if ((node.className=='li_menu')||(node.className=='li_menu current')){
					node.onclick=function() {

						navRoot2 = document.getElementsByTagName("li");
						for (i2=0; i2<navRoot2.length; i2++) {
							node2 = navRoot2[i2];
							if ((node2.className=='li_menu current')){

								node2.className=node2.className.replace(" current", "");
							}
						}
						this.className+=" current";
					}
				}
			}
		}

}

function popup(url, width, height){
	var winpops=window.open(url,"","'toolbar=no,scrollbars=yes,resizable=1', width="+width+",left=0,top=0,height="+height);
	//var winpops=window.open(url,"","width="+width+",left=80,top=80,height="+height);
}

function popup2(url, width, height){
	var winpops=window.open(url,"","'toolbar=no,scrollbars=yes,resizable=1', width="+width+",left=5,top=5,height="+height);
}

function popup3(url, width, height){
	var winpops=window.open(url,"","'toolbar=yes,scrollbars=no,resizable=1', width="+width+",left=5,top=5,height="+height);
}

function showhide(hide){
	var node;
	var navRoot = document.getElementsByTagName("td");
	for (i=0; i<navRoot.length; i++) {
		var node = navRoot[i];
		if (node.id.indexOf('advertizing_id')>=0||node.id.indexOf('offices_id')>=0|| node.id.indexOf('operations_id')>=0|| node.id.indexOf('readed')>=0){
			node.style.display = hide;
		}
	}
}

function checkform(err1,err2) {
	if (document.form_values.l_username.value == '') {
		// something is wrong
		alert(err1);
		return false;
	}else if (document.form_values.l_password.value == ''){
		// something else is wrong
		alert(err2);
		return false;
	}
	// If the script gets this far through all of your fields
	// without problems, it's ok and you can submit the form
	return true;
}
