function createAjaxObj(){
var httprequest=false
if (window.XMLHttpRequest){ 
httprequest=new XMLHttpRequest()
if (httprequest.overrideMimeType)
httprequest.overrideMimeType('text/xml')
}
else if (window.ActiveXObject){ 
try {
httprequest=new ActiveXObject("Msxml2.XMLHTTP");
} 
catch (e){
try{
httprequest=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}
return httprequest
}

var ajaxpackw1=new Object()
ajaxpackw1.basedomain="http://"+window.location.hostname
ajaxpackw1.ajaxobj=createAjaxObj()
ajaxpackw1.filetype="txt"
ajaxpackw1.addrandomnumber=0 

ajaxpackw1.getAjaxRequest=function(url, parameters, callbackfunc, filetype){
ajaxpackw1.ajaxobj=createAjaxObj() 
if (ajaxpackw1.addrandomnumber==1) 
var parameters=parameters+"&ajaxcachebust="+new Date().getTime()
if (this.ajaxobj){
this.filetype=filetype
this.ajaxobj.onreadystatechange=callbackfunc
this.ajaxobj.open('GET', url+"?"+parameters, true)
this.ajaxobj.send(null)
}
}

ajaxpackw1.postAjaxRequest=function(url, parameters, callbackfunc, filetype){
ajaxpackw1.ajaxobj=createAjaxObj() 
if (this.ajaxobj){
this.filetype=filetype
this.ajaxobj.onreadystatechange = callbackfunc;
this.ajaxobj.open('POST', url, true);
this.ajaxobj.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=iso-8859-2");
this.ajaxobj.setRequestHeader("Content-length", parameters.length);
this.ajaxobj.setRequestHeader("Connection", "close");
this.ajaxobj.send(parameters);
}
}

//--

function processGetPost_w(){
var myajax=ajaxpackw1.ajaxobj
var myfiletype=ajaxpackw1.filetype
if (myajax.readyState == 4){ 
if (myajax.status==200 || window.location.href.indexOf("http")==-1){ 
if (myfiletype=="txt"){
alertXw2();

writewi(myajax.responseText);
document.forms.form_pog.select_pog.disabled=false;
}

else
confirm(myajax.responseXML)
}
}
}


function alertXw2(x){
 if(!x){

  document.getElementById('alertXw2').style.visibility='hidden'
  document.getElementById('box_w').style.height='50px';
  return
 }
 with(document.getElementById('alertXw2')){
  style.height='';innerHTML=x
  style.visibility='visible'
  
 }
}



function writewi(response) {
document.getElementById("pogoda").style.display="block"
document.getElementById("pogoda").innerHTML = response
}


function close() {
	document.getElementById("pogoda").style.display="none";
	document.forms.form_pog.select_pog[0].selected="true";
}


function submitPOSTw(file,value,what) {
if(value=="null"){
	document.getElementById("pogoda").style.display="none";
	alertXw2("<span>Proszę wybrać miejscowość!</span>")
	}
if(value!="null"){
	var poststr=value + "&metoda=ajax"
	var processGetPost=processGetPost_w
	ajaxpackw1.postAjaxRequest(file, poststr, processGetPost, 'txt'); 
	document.getElementById("pogoda").style.display="none";
	document.forms.form_pog.select_pog.disabled=true;
	document.getElementById('box_w').style.height='80px';
	alertXw2("<div align='center' style='padding-top:3px;'><img src='style/img/loading.gif' width='32' height='32' />Chwileczkę...</div>")
    }
}
