startList = function() {
	if (document.all && document.getElementById) {
		navRoot = document.getElementById("dropdown");
		if (!navRoot) return;
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}
window.onload=startList;

function fcheck(i,v){
 var r=1;
 formels[i]=v;
 for (i=0; i<formels.length;i++) {if (formels[i]==0) r=0;}
 if (r==1) show("submit"); else hide("submit");
 }

function getElementPosition(offsetTrail){
 var offsetLeft = 0;
 var offsetTop = 0;
 while (offsetTrail){
 offsetLeft += offsetTrail.offsetLeft;
 offsetTop += offsetTrail.offsetTop;
 offsetTrail = offsetTrail.offsetParent;
 }
 if (navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != 'undefined'){
 offsetLeft += document.body.leftMargin;
 offsetTop += document.body.topMargin;
 }
 return {left:offsetLeft,top:offsetTop};
 }

function getCookie(c_name){
if (document.cookie.length>0) {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1) { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}

function show(id){
	document.getElementById(id).style.display = "block";
}

function hide(id){
	document.getElementById(id).style.display = "none";
}

function toggle_vis(id){
	var el = document.getElementById(id);
	if(el.style.display!='block') el.style.display= 'block';
	else el.style.display= 'none';
}


var ajax_have_changes=0;
var ajax_in_use=0;

var ajax_text;
var ajax_id;
var ajax_url;

function ppchange(id, url) {
    var pp_last_id=id;
    var pp_last_url=url;
    if  (ajax_in_use!=0) {
	ajax_have_changes++;
	return;
	}

	url="/ajax.php?" + get_url(url);
	if(!this.http){
	    this.http = get_http();
	}
	if (this.http)
	 {
	    var http = this.http;
	    this.http.open("GET", url, true);
	    this.http.onreadystatechange = function() {
		if (http.readyState == 4) {
		    var data=http.responseText;
		    if (typeof(data)!='string') data='';

            	    var in_js=data.indexOf("<!--/JS/-->");
		    if (data.substr(0,9)!="<!--JS-->") in_js=0;
		    if (in_js>0) {document.getElementById(id).innerHTML=data.substr(in_js+11);eval(data.substr(9,in_js-9));}
		    else document.getElementById(id).innerHTML=data;

		    ajax_in_use=0;
		    if (ajax_have_changes!=0) {
		       ajax_have_changes=0;
		       ppchange(pp_last_id,pp_last_url);
		       }
		  }else{
		  }
	    }
	    ajax_in_use=1;
	    this.http.send(null);
	}
	if(!this.http){
	      alert('Ошибка при создании XMLHTTP объекта!');
	}

}

function ppsend(id,params,loadtext,xcode) {
	ppload(id,get_url(params),loadtext,xcode);
}

function get_url(params) {
	url=params.split("&");
	var surl="";
	for(var i in url){
	 if (url[i].match("=")==null) {
	  var url2=url[i].split("#");
          if (!document.getElementById(url2[1])) alert("Form id="+url2[1]+" not found!");
	  else {var idunit=document.getElementById(url2[1]);
		if (idunit.type=="radio" || idunit.type=="checkbox") surl+="&"+url2[0]+"="+encodeURIComponent(idunit.checked);
		else surl+="&"+url2[0]+"="+encodeURIComponent(idunit.value);
		}
	  }
	 else  surl+="&"+url[i];
	 }
    return surl.substr(1);
}

function ppload(id,url,loadtext,xcode) {
  var element;
  if (typeof(id)=='string') element=document.getElementById(id);
  else element=id;
  this.http = get_http();
  if (this.http) {
    var xhttp = this.http;
    this.http.open("GET", "/ajax.php?" + url, true);
    this.http.onreadystatechange = function() {
	if (xhttp.readyState == 4) {
	    if (typeof(xhttp.responseText)=='string') {
                var in_js=xhttp.responseText.indexOf("<!--/JS/-->");
		if (xhttp.responseText.substr(0,9)!="<!--JS-->") in_js=0;
		if (in_js>0) {element.innerHTML=xhttp.responseText.substr(in_js+11);eval(xhttp.responseText.substr(9,in_js-9));}
		else element.innerHTML=xhttp.responseText;
		element.style.display='block';
		if (typeof(xcode)=='string') eval(xcode);
		}
	    }
	}
    if (typeof(loadtext)=='string') element.innerHTML=loadtext;
    this.http.send(null);
    }
}

function get_http(){
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
	try {
	    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	    try {
		xmlhttp = new 
		ActiveXObject("Microsoft.XMLHTTP");
	    } catch (E) {
		xmlhttp = false;
	    }
	}
    @else
	xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
	try {
	    xmlhttp = new XMLHttpRequest();
	} catch (e) {
	    xmlhttp = false;
	}
    }
    return xmlhttp;
}

function trackit(id){
  id.style.left = event.x;
  id.style.top = event.y;
  if(event.x < "200") { id.style.left = "200"; }
  }

