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 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);
        }
    }
}

startList2 = function() {
	if (navigator.userAgent.indexOf('Opera') == -1) {
		if (document.all&&document.getElementById) {
			navRoot = document.getElementsByTagName("tr");
			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", "");
					}
				}
			}
		}
	}
}

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

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

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

function showhide(what,what2) {
	if (what.style.display=='none')	{
		what.style.display='';
		what2=open.src
	}else{
		what.style.display='none'
		what2=closed.src
	}
}

function hide(what) {
	what.style.display='none'
	what2=closed.src
}

function show(what) {
	what.style.display='';
	what2=open.src
}

function LimitText(fieldObj,maxChars) {
	var result = true;
	
	if (fieldObj.value.length > maxChars) {
		alert('The text is too long!');
		result = false;
	}
	
	if (window.event) {
		window.event.returnValue = result;
	}

	
	return result;
}

function Count(obj,nu,id){
 var res=document.getElementById(id)
 if (obj.value.length>nu){
  obj.value=obj.value.substring(0,nu);
 }
 res.value=nu-obj.value.length;
}

function CheckForDisabled() {
  // checks to see if the selected OPTION has a disabled attribute
  if (document.Search.s_type.options[document.Search.s_type.selectedIndex].disabled) {
    //alert('This field is disabled!');
    // Now reset the drop down list so that the first item is selected.
    // If you didn't do this, the *disabled* item would still be selected
    document.Search.s_type.selectedIndex = 0;
  }
}

function CheckForDisabled2() {
  if (document.Search.s_location.options[document.Search.s_location.selectedIndex].disabled) {
    document.Search.s_location.selectedIndex = 0;
  }
}

function hov(loc,cls){
	if(loc.className) loc.className=cls;
}
