var xmlHttp

function jump_rek()
{
	setTimeout("if(xmlHttp.readyState!=4) {jump_rek()} else {location.hash='jump1'}",100)
}
function getTravel(id)
{ 
document.passengers.departTravel.value=id
}
function getTravelBack(id)
{ 
document.passengers.returnTravel.value=id
}
function getTravelClass(str)
{
    document.passengers.travelClass.value=str
    document.getElementById("txtHint").innerHTML="" 
}
function goTo(sAnchorIN)
{
    var sParameters;
    sParameters = "#" + sAnchorIN;
    location.href = "index.php?main_page=page_2" + sParameters;
}

function addprod(name, price, descr, div, company)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}        
var url="includes/languages/"+_language+"/html_includes/addprod.php"
url=url+"?name="+name
url=url+"&price="+price
url=url+"&descr="+descr
url=url+"&company="+company
url=url+"&sid="+Math.random()
//pause(2000)
xmlHttp.onreadystatechange=function() {stateChangedAddProd(div);}
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
//alert('Bilet kupiony.')

}

function stateChangedAddProd(div) 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
   document.getElementById("txtIdProd"+div).innerHTML=xmlHttp.responseText 
//   document.getElementById("txtHintBack").innerHTML="" 
   } 
} 

function Calculate(str, str2, date1, date2, _ppl26, _ppl16, _ppl4, travelClass, _language)
{ 
if ((_ppl26+_ppl16+_ppl4) < 1)
{
	window.alert(zero_passengers_info[_language])
	return
}

document.passengers.departDate.value=date1

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}        
var url="includes/languages/"+_language+"/html_includes/getuser.php"
url=url+"?fromCity="+str+"&toCity="+str2+"&date1="+date1
url=url+"&_ppl26="+_ppl26
url=url+"&_ppl16="+_ppl16
url=url+"&_ppl4="+_ppl4
url=url+"&travelClass="+travelClass
url=url+"&sid="+Math.random()
url=url+"&_language="+_language
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
jump_rek()
}

function Calculate2(str, str2, date1, date2, _ppl26, _ppl16, _ppl4, travelClass, option, div, _language)
{
	//window.alert('str:'+str+' str2:'+ str2+' date1:'+ date1+' date2:'+date2+' ppl26:'+_ppl26+' ppl16:'+_ppl16+' ppl4:'+_ppl4+' travelClass:'+travelClass+' option:'+option+' div:'+div)
//	document.write(str)
//	document.write(str2)
//	document.write(date1)
//	document.write(date2)
//	document.write(_ppl26)
//	document.write(_ppl16)
//	document.write(_ppl4)
//	document.write(travelClass)
//	document.write(option)
//	document.write(div)
document.passengers.departDate.value=date1

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}        
var url="includes/languages/"+_language+"/html_includes/getoptions.php"
url=url+"?fromCity="+str+"&toCity="+str2+"&date1="+date1
url=url+"&_ppl26="+_ppl26
url=url+"&_ppl16="+_ppl16
url=url+"&_ppl4="+_ppl4
url=url+"&travelClass="+travelClass
url=url+"&option="+option
url=url+"&div="+div
url=url+"&sid="+Math.random()
url=url+"&_language="+_language
xmlHttp.onreadystatechange=function() {stateChangedOptions(div);}
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChangedOptions(div) 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
   document.getElementById('travel'+div).innerHTML=xmlHttp.responseText 
   } 
} 
function getTravels(str, str2, date1)
{ 
document.passengers.departDate.value=date1

xmlHttp=GetXmlHttpObject()

if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}        
var url="includes/languages/"+_language+"/html_includes/getuser.php"
url=url+"?fromCity="+str+"&toCity="+str2+"&date1="+date1
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 

function freset()
{ 
document.getElementById("txtHintBack").innerHTML="" 
document.getElementById("txtHint").innerHTML="" 
}

function getCity(str, str2, date1, _language)
{ 
document.passengers.departDate.value=date1
document.getElementById("txtHintBack").innerHTML="" 
document.getElementById("txtHint").innerHTML="" 

xmlHttp=GetXmlHttpObject()

if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}        
var url="includes/languages/"+_language+"/html_includes/getcity.php"
url=url+"?fromCity="+str+"&toCity="+str2+"&date1="+date1
url=url+"&language="+_language+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChangedCity
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 
function stateChangedCity() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
   document.getElementById("txtCityReturn").innerHTML=xmlHttp.responseText 
   document.getElementById("txtHintBack").innerHTML="" 
    document.passengers.returnTravel.value=''
    document.passengers.returnDate.value=''

   } 
} 

function getTravelsBack(str, str2, date1)
{ 
document.passengers.returnDate.value=date1

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}        
var url="includes/languages/"+_language+"/html_includes/getuserback.php"
url=url+"?fromCity="+str+"&toCity="+str2+"&date1="+date1
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChangedBack
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function getCal(str)
{
if(str==0){
    document.getElementById("ppp").style.display = "none";
    document.passengers.returnTravel.value=''
    document.passengers.returnDate.value=''
}else{
    document.getElementById("ppp").style.display = "inline";
}

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}        
var url="includes/languages/"+_language+"/html_includes/getcal.php"
url=url+"?cal="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged2
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}



function SetDate(str,str2)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}        
var url="includes/languages/"+_language+"/html_includes/setdate.php"
url=url+"?month="+str2
url=url+"&date="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChangedDate
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChangedDate() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
   document.getElementById("txtCa").innerHTML=xmlHttp.responseText 
   } 
} 
function SetDateBack(str,str2)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}        
var url="includes/languages/"+_language+"/html_includes/setdateback.php"
url=url+"?month="+str2
url=url+"&date="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChangedDateBack
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChangedDateBack() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
   document.getElementById("txtCal").innerHTML=xmlHttp.responseText 
   } 
} 
function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
   document.getElementById("txtHint").innerHTML=xmlHttp.responseText
   // **** added by Wiechu
   if (xmlHttp.responseText.search('Ooops!') != -1)
   {
   	location.href='index.php?main_page=page_3';
   }
   // *** end of added by Wiechu
  else {
   document.getElementById("txtHintBack").innerHTML="" 
    document.passengers.returnTravel.value=''
    document.passengers.returnDate.value=''
    //location.href='index.php?main_page=page_2#jump1'  
  }
   }  
} 

function stateChangedBack() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
   document.getElementById("txtHintBack").innerHTML=xmlHttp.responseText 
   } 
} 
function stateChanged2() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   { 
   document.getElementById("txtCal").innerHTML=xmlHttp.responseText 
   } 
} 

function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}
