function zjisti_kod_akce(e){
if(e){
return e.charCode ? e.charCode : e.keyCode;}
else{return window.event.charCode ? window.event.charCode : window.event.keyCode; }}









function bookmarksite(title,url){ 
if (window.sidebar) // firefox 
window.sidebar.addPanel(title, url, ""); 
else if(window.opera && window.print){ // opera 
var elem = document.createElement('a'); 
elem.setAttribute('href',url); 
elem.setAttribute('title',title); 
elem.setAttribute('rel','sidebar'); 
elem.click(); 
} 
else if(document.all)// ie 
window.external.AddFavorite(url, title); 
} 


/* ---------------------------- */
/* XMLHTTPRequest Enable 		*/
/* ---------------------------- */
function createObject() {
	var request_type;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
	request_type = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_type = new XMLHttpRequest();
	}
		return request_type;
}

var http = createObject();

/* -------------------------- */
/* SEARCH					 */
/* -------------------------- */
function pohyb_li(e) {

var unicode=zjisti_kod_akce(e);
//Jestliže stisknu šípku dolů přejdu na danou volbu
if(unicode==40){

maxlix = document.getElementById('max_li').value;

lix = document.getElementById('aktual_li').value;
lix = parseInt(lix);




if(lix!=0){
document.getElementById('li'+lix).style.background='#C0C0C0';
}

if(lix<maxlix){
lix = lix + 1;
}

document.getElementById('aktual_li').value = lix;
document.getElementById('li'+lix).style.background='#FFFF80';


}else if(unicode==38){

lix = document.getElementById('aktual_li').value;
lix = parseInt(lix);
if(lix>1){
document.getElementById('li'+lix).style.background='#C0C0C0';
lix = lix - 1;
}

document.getElementById('aktual_li').value = lix;
document.getElementById('li'+lix).style.background='#FFFF80';


}
//end function
}


function autosuggest(e) {

var unicode=zjisti_kod_akce(e);

if(unicode==40){


}else if(unicode==38){


}else{


q = document.getElementById('search-q').value;
tb = document.getElementById('kde_hledat').value;
se = document.getElementById('seo_n_kat').value; 
ve = document.getElementById('var_shopu').value; 

// Set te random number to add to URL request
nocache = Math.random();
http.open('get', '/lib/search.php?q='+q+'&tb='+tb+'&se='+se+'&vshop='+ve+'&nocache='+nocache);
http.onreadystatechange = autosuggestReply;
http.send(null);


}
}
function autosuggestReply() {
if(http.readyState == 1){
e = document.getElementById('results');
e.innerHTML='Načítám dat...';
document.getElementById('aktual_li').value = 0;
}
if(http.readyState == 4){
	var response = http.responseText;
	e = document.getElementById('results');
	if(response!=""){
		e.innerHTML=response;
		e.style.display="block";
	} else {
		e.style.display="none";
	}
}
}

/* -------------------------- */
/* TOOLTIP					 */
/* -------------------------- */
function tooltip(idv, tbv) {

// Set te random number to add to URL request
nocache = Math.random();
http.open('get', '/lib/tooltip.php?idv='+idv+'&tbv='+tbv+'&nocache='+nocache);
http.onreadystatechange = tooltipReply;

http.send(null);

function tooltipReply() {

if(http.readyState == 1){
vyr = document.getElementById('cursor');
vyr.innerHTML='Načítám data...';
}
if(http.readyState == 4){
	var response_tooltip = http.responseText;
	vyr = document.getElementById('cursor');
	if(response_tooltip!=""){
		vyr.innerHTML= response_tooltip;
		vyr.style.display="block";
	} else {
		vyr.style.display="none";
	}
}
}
}




function tooltip_obr(katalog_id) {

// Set te random number to add to URL request
nocache = Math.random();
http.open('get', '/lib/tooltip_obr.php?katalog_id='+katalog_id+'&nocache='+nocache);
http.onreadystatechange = tooltipReply;

http.send(null);

function tooltipReply() {

if(http.readyState == 1){
vyr = document.getElementById('cursor');
vyr.innerHTML='Načítám data...';
}
if(http.readyState == 4){
	var response_tooltip = http.responseText;
	vyr = document.getElementById('cursor');
	if(response_tooltip!=""){
		vyr.innerHTML= response_tooltip;
		vyr.style.display="block";
	} else {
		vyr.style.display="none";
	}
}
}
}







function pocet_na_stranu(pocet){


n_kat = document.getElementById('nazev_kategorie').value;
n_subkat = document.getElementById('nazev_subkategorie').value;
n_ssubkat = document.getElementById('nazev_ssubkategorie').value;

// Set te random number to add to URL request
nocache = Math.random();
http.open('get', '/pocet_na_stranu.php?pocet='+pocet+'&kat='+n_kat+'&skat='+n_subkat+'&sskat='+n_ssubkat+'&nocache='+nocache);

http.onreadystatechange = ukazpocetnastranuReply;

http.send(null);



}

function ukazpocetnastranuReply(){

variantal = document.getElementById('seznam_vyrobku');



if(http.readyState == 1){
variantal.innerHTML='Načítám data...';
}

if(http.readyState == 4){
	var response_vari = http.responseText;
    
	if(response_vari!=""){ 
    variantal.innerHTML = ''+response_vari;
    }else{
    variantal.innerHTML = 'Nastala chyba ve vykreslení výrobků';
    }
}



}













function ukaz_vyrobky(forma, order){


n_kat = document.getElementById('nazev_kategorie').value;
n_subkat = document.getElementById('nazev_subkategorie').value;
n_ssubkat = document.getElementById('nazev_ssubkategorie').value;


// Set te random number to add to URL request
nocache = Math.random();
http.open('get', '/ukaz_vyrobky.php?forma='+forma+'&order='+order+'&kat='+n_kat+'&skat='+n_subkat+'&sskat='+n_ssubkat+'&nocache='+nocache);

http.onreadystatechange = ukazvyrobkyReply;

http.send(null);



}

function ukazvyrobkyReply(){

variantal = document.getElementById('seznam_vyrobku');



if(http.readyState == 1){
variantal.innerHTML='Načítám data...'; 
}

if(http.readyState == 4){
	var response_vari = http.responseText;
    
	if(response_vari!=""){ 
    variantal.innerHTML = ''+response_vari;     
    }else{
    variantal.innerHTML = 'Nastala chyba ve vykreslení výrobků';
    }
}



}










/* Tipy přepínání divů*/

function tipy0(box, nic, limit) {

// Set te random number to add to URL request
nocache = Math.random();
http.open('get', '/lib/tipy.php?box='+box+'&limit='+limit+'&nocache='+nocache);
stary_tip = document.getElementById('1_tipy');
stary_tip.style.display="none";

http.onreadystatechange = tipyReply;

http.send(null);
}


function tipy1(box, kat, limit) {

// Set te random number to add to URL request
nocache = Math.random();
http.open('get', '/lib/tipy.php?box='+box+'&kat='+kat+'&limit='+limit+'&nocache='+nocache);
stary_tip = document.getElementById('1_tipy');
stary_tip.style.display="none";

http.onreadystatechange = tipyReply;

http.send(null);
}

function tipy2(box, kat, subkat, limit) {

// Set te random number to add to URL request
nocache = Math.random();
http.open('get', '/lib/tipy.php?box='+box+'&kat='+kat+'&subkat='+subkat+'&limit='+limit+'&nocache='+nocache);
stary_tip = document.getElementById('1_tipy');
stary_tip.style.display="none";

http.onreadystatechange = tipyReply;

http.send(null);
}

function tipy3(box, kat, subkat, subkat2, limit) {

// Set te random number to add to URL request
nocache = Math.random();
http.open('get', '/lib/tipy.php?box='+box+'&kat='+kat+'&subkat='+subkat+'&subkat2='+subkat+'&limit='+limit+'&nocache='+nocache);
stary_tip = document.getElementById('1_tipy');
stary_tip.style.display="none";

http.onreadystatechange = tipyReply;

http.send(null);
}



function tipyReply() {

if(http.readyState == 1){
tip = document.getElementById('tipy');
tip.innerHTML='Načítám data...';
}
if(http.readyState == 4){
	var response_tip = http.responseText;
	tip = document.getElementById('tipy');
	if(response_tip!=""){
		tip.innerHTML= response_tip;
		tip.style.display="block";
	} else {
		tip.style.display="none";
	}

}
}










function karty(kart, id_vyr, tab) {

// Set te random number to add to URL request
nocache = Math.random();
subkat_det = document.getElementById('subkat_detail').value;
http.open('get', '/lib/karty.php?kart='+kart+'&id_vyr='+id_vyr+'&tab='+tab+'&subkat_d='+subkat_det+'&nocache='+nocache);
stara_karta = document.getElementById('1_karta');
stara_karta.style.display="none";

http.onreadystatechange = kartyReply;

http.send(null);
}



function kartyReply() {

if(http.readyState == 1){
obsahkarty = document.getElementById('obsah_karty');
obsahkarty.innerHTML='Načítám data...';
}
if(http.readyState == 4){
	var response_karta = http.responseText;
	obsahkarty = document.getElementById('obsah_karty');
	if(response_karta!=""){
		obsahkarty.innerHTML= response_karta;
		obsahkarty.style.display="block";
	} else {
		obsahkarty.style.display="none";
	}

}
}









function ukaz_variantu(variant, cen_skup){



// Set te random number to add to URL request
nocache = Math.random();
http.open('get', '/lib/varianty_detail.php?varianta='+variant+'&cen_kat='+cen_skup+'&nocache='+nocache);

http.onreadystatechange = ukazvariantuReply;

http.send(null);




function ukazvariantuReply(){

variantal = document.getElementById('ukaz_hod_var');
variantaaaa = document.getElementById('id_var');
variantaaaa.value=''+variant;

if(http.readyState == 1){
variantal.innerHTML='Načítám data...';
}

if(http.readyState == 4){
	var response_vari = http.responseText;
    
	if(response_vari!=""){ 
    variantal.innerHTML = ''+response_vari;
    
    }else{
    puvodnicenadph = document.getElementById('puvodni_cena_dph').value;
    puvodnicena = document.getElementById('puvodni_cena').value;
    
    variantal.innerHTML = '<span style="position:relative; top: -5px;">'+puvodnicena+' Kč</span><br /><span style="position:relative; top: 5px;" >'+puvodnicenadph+' Kč</span>';
    
	}
}


}
}






function ukaz_variantu_foto(variant){



// Set te random number to add to URL request
nocache = Math.random();
http.open('get', '/lib/varianty_foto.php?varianta='+variant+'&nocache='+nocache);

http.onreadystatechange = ukazvariantufotoReply;

http.send(null);



}

function ukazvariantufotoReply(){

variantal = document.getElementById('ukaz_hod_var2');



if(http.readyState == 1){
variantal.innerHTML='Načítám data...';
}

if(http.readyState == 4){
	var response_vari = http.responseText;
    
	if(response_vari!=""){ 
    variantal.innerHTML = ''+response_vari;
    }else{
    variantal.innerHTML = '';
    }
}



}

















function odhlasit(){

// Set te random number to add to URL request
nocache = Math.random();
http.open('get', '/lib/odhlasit.php?&nocache='+nocache);

http.onreadystatechange = odhlasitReply;

http.send(null);



}

function odhlasitReply(){

registroval = document.getElementById('registrovat');
variantal = document.getElementById('prihlasit_uziv');
kos = document.getElementById('blok_kosik');



if(http.readyState == 1){
variantal.innerHTML='Načítám data...';
}

if(http.readyState == 4){
	var response_vari = http.responseText;
    
	if(response_vari!=""){ 
    variantal.innerHTML = ''+response_vari;
    registroval.innerHTML = '<a href="/registrovat.php" target="_blank" >Registrovat se!</a>';
    kos.style.display='none';
    
    }
}



}





function zrusit_kosik(){

// Set te random number to add to URL request
nocache = Math.random();
http.open('get', '/lib/zrusit_kosik.php?nocache='+nocache);

http.onreadystatechange = zrusit_kosikReply;

http.send(null);


}

function zrusit_kosikReply(){

if(http.readyState == 4){

kos = document.getElementById('blok_kosik');
kos.style.display='none';
location.href='';

}

}

