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 ajaxpackprop=new Object()
ajaxpackprop.basedomain="http://"+window.location.hostname
ajaxpackprop.ajaxobj=createAjaxObj()
ajaxpackprop.filetype="txt"
ajaxpackprop.addrandomnumber=0 

ajaxpackprop.getAjaxRequest=function(url, parameters, callbackfunc, filetype){
ajaxpackprop.ajaxobj=createAjaxObj() 
if (ajaxpackprop.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)
}
}

ajaxpackprop.postAjaxRequest=function(url, parameters, callbackfunc, filetype){
ajaxpackprop.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_prop(){
var myajax=ajaxpackprop.ajaxobj
var myfiletype=ajaxpackprop.filetype
if (myajax.readyState == 4){ 
if (myajax.status==200 || window.location.href.indexOf("http")==-1){ 
if (myfiletype=="txt"){
alertXp('Propozycja została przesłana! Dziękuję!');
document.getElementById("form3").send.disabled=false;
document.getElementById("form3").send.value="Wyślij";


 setTimeout("document.getElementById('alertXp').style.visibility = 'hidden'",1000);
 setTimeout("document.getElementById('alertXp').style.visibility = 'visible'",1500);
 setTimeout("document.getElementById('alertXp').style.visibility = 'hidden'",2000);
 setTimeout("document.getElementById('alertXp').style.visibility = 'visible'",2500);
 setTimeout("document.getElementById('alertXp').style.visibility = 'hidden'",3000);
 setTimeout("document.getElementById('alertXp').style.visibility = 'visible'",3500);


}
else
confirm(myajax.responseXML)
}
}
}

function createpoststring_prop(form){
var value01=document.getElementById(form).propozycja.value 
var value02=document.getElementById(form).uri.value 
var poststr = "propozycja=" + encodeURI(value01) + "&uri=" + encodeURI(value02) + "&metoda=ajax"

return poststr
}


function alertXp(x){
 if(!x){

  document.getElementById('alertXp').style.visibility='hidden'
  document.getElementById('alertXp').style.height='0px';
  return
 }
 with(document.getElementById('alertXp')){
  style.height='';innerHTML=x
 // +'<div style="text-align:center;">'+'<a href="javascript:alertX()">Zamknij</a></div>'
var y=window.innerHeight?innerHeight:document.body.clientHeight,
  m=y-50
  style.height=offsetHeight>m?m+'px':''
  style.bottom=y/2-offsetHeight/2+'px'
  style.visibility='visible'
 }
}



function submitPOST_prop(file,form) {
	var poststr=createpoststring_prop(form); 
	var processGetPost=processGetPost_prop;
	ajaxpackprop.postAjaxRequest(file, poststr, processGetPost, 'txt'); 
	document.getElementById(form).reset();
	document.getElementById(form).send.disabled=true;
	document.getElementById(form).send.value="Przesyłanie...";
	alertXp("<img src='style/img/loading.gif' width='32' height='32' />")
	
}
