﻿var xmlHttp;

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;
}
function showCity(){
var prowincja=document.getElementById('prowincja').value;
if(prowincja!=0){
xmlHttpSzukaj = GetXmlHttpObject()
if (xmlHttpSzukaj==null)
{
alert ("Browser does not support HTTP Request")
return
}
url="wybierz_miasto.php";
var dane=encodeURIComponent("id")+"="+ encodeURIComponent(prowincja);
xmlHttpSzukaj.open("POST",url,true);
xmlHttpSzukaj.onreadystatechange=szukajCity;
xmlHttpSzukaj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttpSzukaj.send(dane);}
else{
document.getElementById("city").innerHTML="<select name=\"miasto\" readonly><option value=\"0\">Wybierz</option></select>";
}
}
function szukajCity(){ 
if (xmlHttpSzukaj.readyState==4 || xmlHttpSzukaj.readyState=="complete")
{
document.getElementById("city").innerHTML=xmlHttpSzukaj.responseText;
}
}

function szukaj(){
var prowincja=document.getElementById('prowincja').value;
var city=document.getElementById('miasto').value;
var services=document.getElementById('dodatki').value;
var prices=document.getElementById('cena').value;
var dodatki= new Array();
for(i=0;i<services.length;i++){
if(services[i].checked){
dodatki.push(services[i].value);
alert(dodatki.push(services[i].value));}
}
alert("dlugosc tab: "+dodatki.length);

xmlHttpSearch = GetXmlHttpObject()
if (xmlHttpSearch==null)
{
alert ("Browser does not support HTTP Request")
return
}
url="wyszukaj.php";
var dane=encodeURIComponent("province")+"="+ encodeURIComponent(prowincja)+encodeURIComponent("city")+"="+ encodeURIComponent(city)+encodeURIComponent("service")+"="+ encodeURIComponent(services)+encodeURIComponent("prices")+"="+ encodeURIComponent();
xmlHttpSearch.open("POST",url,true);
xmlHttpSearch.onreadystatechange=pokaz;
xmlHttpSearch.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttpSearch.send(dane);
}
function pokaz(){ 
if (xmlHttpSearch.readyState==4 || xmlHttpSearch.readyState=="complete")
{
document.getElementById("dane").innerHTML=xmlHttpSearch.responseText;
}
}
function showProvince(){
var region=document.getElementById('region').value;
//var wybrana_prowincja=document.getElementById('wybrana_prowincja').value;
if(region!=0){
xmlHttpSzukajR = GetXmlHttpObject()
if (xmlHttpSzukajR==null)
{
alert ("Browser does not support HTTP Request")
return
}
url="wybierz_prowincje.php";
var dane=encodeURIComponent("id")+"="+ encodeURIComponent(region);//+"&"+encodeURIComponent("wybrana_prowincja")+"="+ encodeURIComponent(wybrana_prowincja);
xmlHttpSzukajR.open("POST",url,true);
xmlHttpSzukajR.onreadystatechange=pokazProwincje;
xmlHttpSzukajR.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttpSzukajR.send(dane);}
else{
document.getElementById("province").innerHTML="<select name=\"prowincja\" readonly><option value=\"0\">Wybierz</option></select>";
}
}
function pokazProwincje(){ 
if (xmlHttpSzukajR.readyState==4 || xmlHttpSzukajR.readyState=="complete")
{
 document.getElementById("province").innerHTML=xmlHttpSzukajR.responseText;
}
}



function wyslij_maila(){
var name=document.getElementById('nazwa').value;
var mail=document.getElementById('mail').value;
var telefon=document.getElementById('telefon').value;
var message=document.getElementById('message').value;
xmlHttpWys_Mail = GetXmlHttpObject()
if (xmlHttpWys_Mail==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 url="wyslij.php";
 
xmlHttpWys_Mail.onreadystatechange=wyslij_m;
xmlHttpWys_Mail.open("POST",url,true);
var dane = encodeURIComponent("name") + "=" + encodeURIComponent(name)+"&"+encodeURIComponent("mail") + "=" + encodeURIComponent(mail)+"&"+encodeURIComponent("telefon") + "=" + encodeURIComponent(telefon)+"&"+encodeURIComponent("message") + "=" + encodeURIComponent(message);
xmlHttpWys_Mail.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttpWys_Mail.send(dane);
}
function wyslij_m(){ 
	if (xmlHttpWys_Mail.readyState==4 || xmlHttpWys_Mail.readyState=="complete")
	{
		 document.getElementById("komunikat").innerHTML=xmlHttpWys_Mail.responseText;
	}
}

function wyslij_maila_pos(){
var name=document.getElementById('nazwa').value;
var mail=document.getElementById('mail').value;
var telefon=document.getElementById('telefon').value;
var message=document.getElementById('message').value;
var nazwa_posiadlosci=document.getElementById('nazwa_posiadlosci').value;
var nr_posiadlosci=document.getElementById('nr_posiadlosci').value;
xmlHttpWys_Mail = GetXmlHttpObject()
if (xmlHttpWys_Mail==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 url="wyslij_pos.php";
 
xmlHttpWys_Mail.onreadystatechange=wyslij_m_pos;
xmlHttpWys_Mail.open("POST",url,true);
var dane = encodeURIComponent("name") + "=" + encodeURIComponent(name)+"&"+encodeURIComponent("mail") + "=" + encodeURIComponent(mail)+"&"+encodeURIComponent("telefon") + "=" + encodeURIComponent(telefon)+"&"+encodeURIComponent("message") + "=" + encodeURIComponent(message)+"&"+encodeURIComponent("nazwa_posiadlosci") + "=" + encodeURIComponent(nazwa_posiadlosci)+"&"+encodeURIComponent("nr_posiadlosci") + "=" + encodeURIComponent(nr_posiadlosci);
xmlHttpWys_Mail.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttpWys_Mail.send(dane);
}
function wyslij_m_pos(){ 
	if (xmlHttpWys_Mail.readyState==4 || xmlHttpWys_Mail.readyState=="complete")
	{
		 document.getElementById("komunikat").innerHTML=xmlHttpWys_Mail.responseText;
	}
}

function showSort(a,b,c,d,h){
var limit=document.getElementById('limit').value;
var order=document.getElementById('order').value;
var kolejnosc=document.getElementById('kolejnosc').value;
var dodatki=document.getElementById('dodatki').value;
var wyb_typ=document.getElementById('wybrany_typ').value;
var wyb_os=document.getElementById('wybrane_osoby').value;
var wyb_dom=document.getElementById('wybrany_domek').value;
if(limit!=0 && order!=0){
xmlHttpSzukajSS = GetXmlHttpObject()
if (xmlHttpSzukajSS==null)
{
alert ("Browser does not support HTTP Request")
return
}
url="sort_ile.php";
var dane=encodeURIComponent("wyb_reg")+"="+ encodeURIComponent(a)+"&"+encodeURIComponent("wyb_prow")+"="+ encodeURIComponent(b)+"&"+encodeURIComponent("wyb_mias")+"="+ encodeURIComponent(c)+"&"+encodeURIComponent("wyb_cen")+"="+ encodeURIComponent(d)+"&"+encodeURIComponent("wyb_os")+"="+ encodeURIComponent(wyb_os)+"&"+encodeURIComponent("wyb_typ")+"="+ encodeURIComponent(wyb_typ)+"&"+encodeURIComponent("wyb_dod")+"="+ encodeURIComponent(dodatki)+"&"+encodeURIComponent("limit")+"="+ encodeURIComponent(limit)+"&"+encodeURIComponent("order")+"="+ encodeURIComponent(order)+"&"+encodeURIComponent("page")+"="+ encodeURIComponent(h)+"&"+encodeURIComponent("kolejnosc")+"="+ encodeURIComponent(kolejnosc)+"&"+encodeURIComponent("house")+"="+ encodeURIComponent(wyb_dom);
xmlHttpSzukajSS.open("POST",url,true);
xmlHttpSzukajSS.onreadystatechange=pokaz_sort;
xmlHttpSzukajSS.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttpSzukajSS.send(dane);}
}
function pokaz_sort(){ 
if (xmlHttpSzukajSS.readyState==4 || xmlHttpSzukajSS.readyState=="complete")
{
 document.getElementById("div_sort").innerHTML=xmlHttpSzukajSS.responseText;
 jQuery(document).ready(function(){
	imagePreview();
	jQuery(window).scrollTop(300);
	jQuery('.os').tooltip({
	track: true,
	delay: 0,
	showURL: false,
	left: -120
});
});
}
}

