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;

}

//====================================funckje dla gadacza
function gadacz_new(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;
      }
    }
  }
 
  	
	var url = "modules/Gadacz/ajax.php";
	var params = "gadacz_new="+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.send(params);
	
	ajax_fill('modules/Gadacz/ajax.php?getcontent=true');
	document.getElementById('gnm').value = '';

return false;
}

function gadacz_ed(input,id)
{
	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;
      }
    }
  }
 
  	
	var url = "modules/Gadacz/ajax.php";
	var params = "gadacz_ed="+input.value+"&gadacz_id="+id+"";
	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);
	
	setTimeout(ajax_fill('modules/Gadacz/ajax.php?getcontent=true'),100);

return false;
}


function gadacz_del(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;
      }
    }
  }
 
  	
	var url = "modules/Gadacz/ajax.php";
	var params = "gadacz_del="+input+"";
	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);
	
	setTimeout(ajax_fill('modules/Gadacz/ajax.php?getcontent=true'),100);

return false;
}

function ajax_fill2(url,element_id)
{

}
function ajax_fill(url)
{
 var oXmlHttp = zXmlHttp.createRequest();
// var oParser = new DOMParser();
//    var oXmlDom = document.implementation.createDocument("", "", null);
//  alert(url);  
    oXmlHttp.open("get", url, true);
    
    var result = oXmlHttp.onreadystatechange = function () 
    {
     if (oXmlHttp.readyState == 4) 
     {
           if (oXmlHttp.status == 200) 
           {
             if (oXmlHttp.responseText==0) {
              return false;
             }
             else {
//			 alert('aaaaaa');
			 //tutaj to zrobic o
			 document.getElementById('gadaczcontent').innerHTML = oXmlHttp.responseText;
              return true;
             }
           } 
           else
           {
                 alert("An error occurred: " + oXmlHttp.statusText);
             return false;
           }
     }            
     };
    oXmlHttp.send(null);
    return result;
}

function gadacz_refresh(time){
//alert(aaa);
if(document.getElementById('first'))
var aaa=document.getElementById('first').innerHTML;
else var aaa=0;

//console.log($('first').get('html'));
ajax_fill('modules/Gadacz/ajax.php?getcontent=true&last='+aaa);
setTimeout('gadacz_refresh('+time+')',time);

}

function ajax_gadacz_archiwum(url)
{
 var oXmlHttp = zXmlHttp.createRequest();
// var oParser = new DOMParser();
//    var oXmlDom = document.implementation.createDocument("", "", null);
    
    oXmlHttp.open("get", url, true);
    
    var result = oXmlHttp.onreadystatechange = function () 
    {
     if (oXmlHttp.readyState == 4) 
     {
           if (oXmlHttp.status == 200) 
           {
             if (oXmlHttp.responseText==0) {
              return false;
             }
             else {
			 //tutaj to zrobic o
			 document.getElementById('gadacz_archiwum_content').innerHTML = oXmlHttp.responseText;
              return true;
             }
           } 
           else
           {
                 alert("An error occurred: " + oXmlHttp.statusText);
             return false;
           }
     }            
     };
    oXmlHttp.send(null);
    return result;
}
