var http = false;
var isIE=(document.all && !window.opera)?true:false;


if(navigator.appName == "Microsoft Internet Explorer") {
  http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
  http = new XMLHttpRequest();
}

function Scitani(a,b) {
	 return a*1+b*1;
}

function pageScroll() {
    window.scrollBy(0,-50); // horizontal and vertical scroll increments
	if (window.pageYOffset>10) scrolldelay = setTimeout('pageScroll()',100); // scrolls every 100 milliseconds
}

function pageScroll2() {
    window.scrollBy(0,-100); // horizontal and vertical scroll increments
	if (window.pageYOffset>200) scrolldelay = setTimeout('pageScroll2()',100); // scrolls every 100 milliseconds
}

function Informace(email, text, zbozi, obchod) {
  http.abort();
  http.open("GET", "/scripts/script.php?druh=informace&email=" + email +"&text=" + text +"&id_zbozi=" + zbozi + "&id_obchod=" + obchod, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('iinfo').innerHTML = http.responseText;
    }
  }
  http.send(null);
}

function Overeni(id) {
  http.abort();
  http.open("GET", "/scripts/script.php?druh=overeni&id=" + id , true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('overit' + id).innerHTML = http.responseText;
    }
  }
  http.send(null);
}

function NahledObrazku(imgurl, img, pocet, id) {
  pageScroll();
  http.abort();
  http.open("GET", "/scripts/script.php?druh=nahledobrazku&imgurl=" + imgurl + "&id=" + id + "&img2=" + img + "&pocet=" + pocet , true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
    	document.getElementById('nahledobrazku').innerHTML = http.responseText;
		document.getElementById('nahledobrazku').style.display='block';
    }
  }
  http.send(null);
}

function OdeslaniOvereni(email, kusu, datum, id) {
  http.abort();
  http.open("GET", "/scripts/script.php?druh=odeslaniovereni&id=" + id + "&kusu=" + kusu + "&email=" + email + "&datum=" + datum , true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('overit' + id).innerHTML = http.responseText;
    }
  }
  http.send(null);
}

function KontrolaEmailu(email) {
  http.abort();
  http.open("GET", "/scripts/script.php?druh=kontrolaemailu&email=" + email, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('kemail').innerHTML = http.responseText;
    }
  }
  http.send(null);
}

function KontrolaIca(ico) {
  http.abort();
  http.open("GET", "/scripts/script.php?druh=kontrolaica&ico=" + ico, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('kico').innerHTML = http.responseText;
    }
  }
  http.send(null);
}

function KontrolaHesla(heslo1, heslo2) {
  http.abort();
  if (heslo1==heslo2 && heslo1) {
	document.getElementById('kheslo').innerHTML = "<span style='color:green;'>Heslo OK</span>";
  } else {
	document.getElementById('kheslo').innerHTML = "<span style='color:#CC0000;'>Hesla se neshodují</span>";
  }
}

function AktKosik(zakid, kosik) {
  http.abort();
  http.open("GET", "/scripts/script.php?druh=aktkosik&id_zakid=" + zakid +"&id_kosik=" + kosik, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('kosik').innerHTML = http.responseText;
    }
  }
  http.send(null);
}

function DoKosiku(zakaznik, zbozi, kusu, button, obchod, kosik, selecty, cena, kod) {
  document.getElementById('infokosik').style.display = 'none';
  http.abort();
  http.open("GET", "/scripts/script.php?druh=dokosiku&id_kosik=" + kosik + "&id_obchod=" + obchod +"&id_zakaznik=" + zakaznik +"&id_zbozi=" + zbozi +"&kusu=" + kusu + "&selecty=" + selecty + "&cena=" + cena + "&kod=" + kod, true); 
  http.onreadystatechange=function() {
	if(http.readyState == 4) {
	  document.getElementById('infokosik').style.display = 'block';
	  document.getElementById('infokosik').innerHTML = http.responseText;
		if (button!='neni') { 
	  		//document.getElementById(button).value = 'v košíku ' + kusu + 'ks';
	  		//document.getElementById(button).style.backgroundColor = 'green';
		}
		if (isIE) {
			document.getElementById('infokosik').style.top = document.documentElement.scrollTop+"px";
		}else {
			document.getElementById('infokosik').style.top = window.pageYOffset+"px";
		}
	  //javascript:opacity('infokosik', 200, 0, 3000);
	}
  }
http.send(null);
}


function Prepocitat(celkem, dopravne) {
  http.abort();
  http.open("GET", "/scripts/script.php?druh=prepocitat&dopravne="+dopravne+"&celkem="+celkem, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('celkem').innerHTML = http.responseText;
    }
  }
  http.send(null);
}

function Filtr(pole, data) {
  //pageScroll();
  document.getElementById('checkpole'+ pole).style.display = 'block';	
  http.abort();
  http.open("GET", "/scripts/script.php?druh=filtr&pole="+pole+"&data="+data, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('checkpole' + pole).innerHTML = http.responseText;
    }
  }
  http.send(null);
}

function Filtr2(id_hlavni, data) {
   //pageScroll();  	
  http.abort();
  http.open("GET", "/scripts/script.php?druh=filtr2&id_hlavni="+id_hlavni+"&data="+data , true); 
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
		document.getElementById('fpole' + id_hlavni).innerHTML = http.responseText; 
    } 
  }
  http.send(null);
}

function Zobrazitzbozi(selectzb) {
  http.abort();
  http.open("GET", "/scripts/script.php?druh=zobrazitzbozi&select="+ selectzb, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) { document.getElementById('obsahzbozi').innerHTML = http.responseText; }
  }
  http.send(null);
}

function Selecty(nazev, idzbozi) {
 pageScroll2();
  http.abort();
  http.open("GET", "/scripts/script.php?druh=selecty&nazev="+ nazev + "&sqld[id]=" + idzbozi, true);
  http.onreadystatechange=function() {
	if(http.readyState == 4) { document.getElementById('vyberselecty').innerHTML = http.responseText; }
  }
  http.send(null);
  document.getElementById('vyberselecty').style.display = 'block';	
}

function Vyber(id, pole, cena) {
 document.getElementById('cenazbozi').value
 document.getElementById('cenazbozi').value = Scitani(document.getElementById('cenazbozi').value, cena);		
 pageScroll2();
  document.getElementById('vyberselecty').style.display = 'none';	
  http.abort();
  http.open("GET", "/scripts/script.php?druh=vyber&pole="+ pole + "&id=" + id, true);
  http.onreadystatechange=function() {
	if(http.readyState == 4) { document.getElementById(pole).innerHTML = http.responseText; }
  }
  http.send(null);
}





	

