function setCookie(name,value,expires,path,domain,secure){
  var cookie=name+'='+escape(value)+((expires)?';expires='+expires.toGMTString():'')+((path)?';path='+path:'')+((domain)?';domain='+domain:'')+((secure)?';secure':'');
  document.cookie=cookie;
}
function datex(date){ var x=new Date(0); var y=x.getTime(); if(y>0){ date.setTime(date.getTime()-y); } }
function id_display(id,cookie){ var type_id=document.getElementById(id).style.display;
	if(type_id=='none'){ document.getElementById(id).style.display='block'; var inf_display=1; }else{ document.getElementById(id).style.display='none'; var inf_display=0; }
	if(cookie!=null){
		var now=new Date(); datex(now); now.setTime(now.getTime() + 90 * 24 * 60 * 60 * 1000); // 90 суток
		setCookie('inf_display',inf_display,now);
	}
}
function sendpost(file,id,post){ var xmlhttp=getXmlHttp()
	xmlhttp.open("POST","/code/"+file+".php?r="+Math.random(),true);
	xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState != 4) return
			clearTimeout(timeout)
		if (xmlhttp.status==200){
			sendhtml(id,xmlhttp.responseText);
		}else{ sendhtml(id,"ошибка запроса"); }
	}
	xmlhttp.send(post); // var params='post='+encodeURIComponent(post);
	var timeout=setTimeout( function(){ xmlhttp.abort(); sendhtml(id,"время вышло"); } ,180000);
}
function getXmlHttp(){ var httprequest;
	try{ httprequest=new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e){ try{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }catch(e1){ httprequest=false; } }
	if(!httprequest && typeof XMLHttpRequest!='undefined'){ httprequest=new XMLHttpRequest(); } return httprequest;
}
function blackdiv(napr,i){
	var timote=new Array(); var allbrowser=new Array(0,0.1,0.2,0.3,0.4,0.5,0.6,0.7); var iebrowser=new Array(0,10,20,30,40,50,60,70);
	if(i==undefined){ sendstyle("blackdiv","display","block");if(napr==1){var i=0;}else{var i=7;} }
	if(napr==1){i++;} if(napr!=1){i--; } sendstyle("blackdiv","opacity",allbrowser[i]);
	sendstyle("blackdiv","filter","alpha(opacity="+iebrowser[i]+")"); timote[i]=setTimeout("blackdiv('"+napr+"',"+i+")",60);
	if( allbrowser[i]==0.7 || allbrowser[i]==0 ){ clearTimeout(timote[i]);if(napr!=1){sendstyle("blackdiv","display","none");} }
}
function winwidth(){
	var width;
	if(document.documentElement.clientWidth){ width=document.documentElement.clientWidth; }else
	if(document.body.clientWidth){ width=document.body.clientWidth; }else
	if(innerWidth){ width=innerWidth; } return width;
}
function winheight(){
	var height;
	if(document.documentElement.clientHeight){ height=document.documentElement.clientHeight; }else
	if(document.body.clientHeight){ height=document.body.clientHeight; }else
	if(innerHeight){ height=innerHeight; } return height;
}
function scrl(){ var scroll=0;
	if(document.documentElement.scrollTop){ scroll=document.documentElement.scrollTop; }else
	if(document.body.scrollTop){ scroll=document.body.scrollTop; }
	return scroll;
}
function sizeblackdiv(){ var scroll=scrl();
	if(scroll==0){
		sendstyle("blackdiv","width",document.documentElement.scrollWidth);
		sendstyle("blackdiv","height",document.documentElement.scrollHeight);	
	}else{
		sendstyle("blackdiv","width",document.documentElement.scrollWidth);
		sendstyle("blackdiv","height",document.documentElement.scrollHeight);
	}
}
function sendstyle(id,x,style){
	if(x=="display"){document.getElementById(id).style.display=style;}
	if(x=="opacity"){document.getElementById(id).style.opacity=style;}
	if(x=="filter"){document.getElementById(id).style.filter=style;}
	if(x=="width"){document.getElementById(id).style.width=style+"px";}
	if(x=="height"){document.getElementById(id).style.height=style+"px";}
}
function sendhtml(id,html,type){
	if(type=="+"){ document.getElementById(id).innerHTML+=html; }
	if(type=="-" || type==null){ document.getElementById(id).innerHTML=html; }
}