

function openWindow(filename, w, h, winname)
{

    var nWidth;

        var nHeigth;

				if(filename.match(/\?/)){
					         filename += '&'+Math.random();
				}else{
					         filename += '?'+Math.random();
				}

        if (h) nHeigth = h; else nHeigth = 500;

        if (w) nWidth = w; else nWidth = 700;

        if (!winname) winname = "_blank";
        var desktop = window.open(filename, winname,

    "width="+nWidth+",height="+nHeigth+",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes");

};

function mousePageXY(e)
{
    if (!e) e = window.event;
    if (e.pageX || e.pageY)
    {
      mouse_x = e.pageX;
      mouse_y = e.pageY;
    }
    else if (e.clientX || e.clientY)
    {
      mouse_x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
      mouse_y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
    }

}
document.onmousemove = function(e){var mCur =mousePageXY(e);}

function loadmain(){	
	loadDoc('/vopros_manageru.pl?random='+ Math.random(), 'v1');		
	//alert('/otziv?random=' + Math.random())
	loadDoc('/otziv.pl?random=' + Math.random(), 'v2');
}

function select_otr_main(){
	var o=document.getElementById('otr').value;
	if(o>0){		
		loadDoc('/load_otr_header?o='+o,'v3');
		document.cookie = "cur_otr="+o+"; path=/";
		
		//document.cookie = 'service_type=1; path=/';		
		service_anons_load();
		loadDoc('/otziv.pl?o='+o+'&random=' + Math.random(), 'v2');
		mp_load_service(1);
	}
	else
		document.cookie = "cur_otr="+0+"; path=/";
}

function select_otr_content(){
	var o=document.getElementById('otr').value;
	if(o>0){
		loadDoc('/load_otr_header?o='+o,'v3');
		document.cookie = "cur_otr="+o+"; path=/";			
	}	
}

function select_otr_inner(){
	var o=document.getElementById('otr').value;
	if(o>0){		
		document.cookie = "cur_otr="+o+"; path=/";
	}
	location.href=location.href
}

function select_otr_goto_main(){
	var o=document.getElementById('otr').value;
	if(o>0){		
		document.cookie = "cur_otr="+o+"; path=/";
	}
	location.href='/';
}

function goto_main(){
	document.cookie = "cur_otr="+0+"; path=/";
	document.cookie = 'service_type=1; path=/';
	location.href='/';
}

function mp_load_service(service){	
	//document.getElementById('service_anons').innerHTML="<div class='loading'><b>Идёт загрузка...</b></div>"	
	loadDoc('/load_service_anons/'+service, 'service_anons');
	loadDoc('/load_topmenu/'+service, 'topmenu');
	//var service=readCookie('service_type');
	document.getElementById('t00').src='/img/t0'+service+'.jpg';
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function load_default_otr(){
	//alert(readCookie())
	loadDoc('/load_otr_header?o=0','v3');
	document.cookie = 'cur_otr=0; path=/';
	service_anons_load();
	loadDoc('/otziv.pl?random=' + Math.random(), 'v2');
}

function load_default_otr_inner(){		
	document.cookie = 'cur_otr=0; path=/';
	document.location.href=document.location.href
}

function service_anons_load(){
	document.getElementById('service_anons').innerHTML="<div class='loading'><b>Идёт загрузка...</b></div>"
	service=readCookie('service_type');
	if(!service) service=1;
	loadDoc('/load_service_anons/'+service, 'service_anons');		
}

function load_clients(){
	var o=document.getElementById('client_otr').value;
	var r=document.getElementById('client_region').value;
	
	if( (o>0) || (r>0)){
		loadDoc('/loadcomp?otr='+o+'&region='+r, 'load_comp');
	}
	else document.getElementById('load_comp').innerHTML='';
	

}

function mousePageXY(e)
{
    if (!e) e = window.event;
    if (e.pageX || e.pageY)
    {
      mouse_x = e.pageX;
      mouse_y = e.pageY;
    }
    else if (e.clientX || e.clientY)
    {
      mouse_x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
      mouse_y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
    }

}
document.onmousemove = function(e){var mCur =mousePageXY(e);}

function print_help(num){
	 var text;
	 if(num==1){
	 	text='О привлечении новых клиентов';
	 }
	 if(num==2	){
	 	text='О получении знаний';
	 }
	 if(num==3){
	 	text='О тендерах';
	 }	 
	 var parrent=document.getElementById('helpspan');
	 if(document.getElementById('helpreg')){
	 	parrent.removeChild(document.getElementById('helpreg'))
	 }
	 var help_div=document.createElement('div');
   parrent.appendChild(help_div);
   help_div.style.position='absolute';
   help_div.style.top=mouse_y; //+0+'px';;           
   help_div.style.left=mouse_x+5+'px';
   help_div.style.background='#eeeeee';
   
   help_div.id='helpreg';
	document.getElementById('helpreg').innerHTML=text;
}