function openWindow(url, w, h,name) {
        var Win = window.open(url,name,'width=' + w + ',height=' + h + ',resizable=1,scrollbars=yes,menubar=no' )
}
function show_hide(ggg)
{

var val;
   val=document.getElementById(ggg);
   if(val.style.display=='none') val.style.display='';
   else val.style.display='none';


}
function hide(ggg)
{

var val;
   val=document.getElementById(ggg);
   val.style.display='none';
}
function show(ggg)
{

var val;
   val=document.getElementById(ggg);
   val.style.display='';


}

function createCookie(name,value,days) {
	if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";

	document.cookie = name+"="+value+expires+"; path=/";
}
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 eraseCookie(name) {
	createCookie(name,"",-1);
}
function wspin_get_skaly(select)
{
	var id=select.value;
	try
  {
    xmlHttp=new XMLHttpRequest();
  }
  catch (e)
  {
    try
    {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      try
      {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e)
      {
        alert("Your browser does not support AJAX!");
        return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
  {
     if(xmlHttp.readyState==4)
     {
			select.form.id_rejon.value=id;
	 		document.getElementById('skaly_div').innerHTML=xmlHttp.responseText;
	 		document.getElementById('skaly_tr').style.display='';

     }
  }
  	xmlHttp.open("GET","modules/Wspin/ajax.php?id_rejon="+id+"",true);

    xmlHttp.send(null);


}
function wspin_nowy_rejon(input)
{
	try
  {
    xmlHttp=new XMLHttpRequest();
  xmlHttp.overrideMimeType('text/xml');
  }
  catch (e)
  {
    try
    {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      try
      {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e)
      {
        alert("Your browser does not support AJAX!");
        return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
  {
  
  	if (xmlHttp.readyState == 4) {
	if (xmlHttp.status == 200) {
	
		var xml=xmlHttp.responseXML;
		var root=xml.documentElement;
		var id;
		if(document.all) id=root.childNodes[1].text;
		else id=root.childNodes[1].firstChild.nodeValue;

		var text;
		if(document.all) text=root.childNodes[3].text;
		else text=root.childNodes[3].firstChild.nodeValue;
		input.form.id_rejon.style.display='none';	
		input.form.id_rejon.value=id;

	 	document.getElementById('skaly_div').innerHTML=text;
	 	document.getElementById('skaly_tr').style.display='';
	}
	}
	
   }
  	
	var url = "modules/Wspin/ajax.php";
	var params = "nowy_rejon="+input.value+"";
	xmlHttp.open("POST", url, true);

	//Send the proper header information along with the request
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
//  	xmlHttp.open("GET","modules/Wspin/ajax.php?nowy_rejon="+input.value+"",true);

    xmlHttp.send(params);


return false;
}
function wspin_nowa_skala(input)
{
	try
  {
    xmlHttp=new XMLHttpRequest();
  xmlHttp.overrideMimeType('text/xml');
  }
  catch (e)
  {
    try
    {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      try
      {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e)
      {
        alert("Your browser does not support AJAX!");
        return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
  {
  
  	if (xmlHttp.readyState == 4) {
	if (xmlHttp.status == 200) {
	
		var xml=xmlHttp.responseXML;
		var root=xml.documentElement;
		var id;
		if(document.all) id=root.childNodes[1].text;
		else id=root.childNodes[1].firstChild.nodeValue;

		if(input.form.skala) input.form.skala.style.display='none';	
		input.form.id_skala.value=id;

	 	document.getElementById('wycena_tr').style.display='';
	}
	}
	
   }
  	
	var url = "modules/Wspin/ajax.php";
	var params = "nowa_skala="+input.value+"&id_rejon="+input.form.id_rejon.value+"";
	xmlHttp.open("POST", url, true);

	//Send the proper header information along with the request
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");

    xmlHttp.send(params);
return false;

}

