		function presmeruj(url) { 
			document.location.href=url;
		}
		function foto(url) {

			//alert("Foto "+url);
			fotogalerie_show(url);
			//f=window.open("foto.php?url="+url,"foto","top=0,left=0,scrollbars=1,width=950,height=700");
			//f.focus();
		}
		function foto_window(url) {

			f=window.open("foto.php?url="+url,"foto","top=0,left=0,scrollbars=1,width=950,height=700");
			f.focus();
		}		
		function fotoenc(url) {
			//alert(decode64(url));
			fotogalerie_show(decode64(url));

			//f=window.open("foto.php?urlenc="+url,"foto","top=0,left=0,scrollbars=1,width=950,height=700");
			//f.focus();
		}		
		var today = new Date();
		var expiry = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);

		function getCookieVal (offset) {
		  var endstr = document.cookie.indexOf (";", offset);
		  if (endstr == -1) { endstr = document.cookie.length; }
		  return unescape(document.cookie.substring(offset, endstr));
		  }

		function GetCookie (name) {
		  var arg = name + "=";
		  var alen = arg.length;
		  var clen = document.cookie.length;
		  var i = 0;
		  while (i < clen) {
		    var j = i + alen;
		    if (document.cookie.substring(i, j) == arg) {
		      return getCookieVal (j);
		      }
		    i = document.cookie.indexOf(" ", i) + 1;
		    if (i == 0) break; 
		    }
		  return null;
		  }

		function DeleteCookie (name,path,domain) {
		  if (GetCookie(name)) {
		    document.cookie = name + "=" +
		    ((path) ? "; path=" + path : "") +
		    ((domain) ? "; domain=" + domain : "") +
		    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
		    }
		  }

		function SetCookie (name,value,expires,path,domain,secure) {
		  document.cookie = name + "=" + escape (value) +
		    ((expires) ? "; expires=" + expires.toGMTString() : "") +
		    ((path) ? "; path=" + path : "") +
		    ((domain) ? "; domain=" + domain : "") +
		    ((secure) ? "; secure" : "");
		  }	
		
		/*
		var predchozi_html_par = null;
		var predchozi_html = null;
		var predchozi_html_url = null;
		*/
		
		ajax_cache = new Array();

		function ajax_html_cache(url,par) {

			//alert("url "+url);
			
			
			
			hash = encode64(url+par);
			
			if (ajax_cache[hash]!= null) {
				
				return ajax_cache[hash];
				
			}

			
		    if (window.ActiveXObject) {
		        ajax = new ActiveXObject("Microsoft.XMLHTTP");
		      }
		      else {
		        ajax = new XMLHttpRequest;
		      }

		    ajax.open("POST",url,false);
		    
		    ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		    ajax.setRequestHeader("Content-length", par.length);
		    ajax.setRequestHeader("Connection", "close");
		    
		    ajax.send(par);

		    if (ajax.readyState == 4 && ajax.status == "200") {
				x = ajax.responseText;
				
				ajax_cache[hash] =x;
				return x;
			}
		    else {
				alert("Chyba pripojeni/connection lost");
				return null;
		    }
		      
		}		
		
		var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";


		function decode64(input) {
			var output = new StringMaker();
			var chr1, chr2, chr3;
			var enc1, enc2, enc3, enc4;
			var i = 0;

			// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
			input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

			while (i < input.length) {
				enc1 = keyStr.indexOf(input.charAt(i++));
				enc2 = keyStr.indexOf(input.charAt(i++));
				enc3 = keyStr.indexOf(input.charAt(i++));
				enc4 = keyStr.indexOf(input.charAt(i++));

				chr1 = (enc1 << 2) | (enc2 >> 4);
				chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
				chr3 = ((enc3 & 3) << 6) | enc4;

				output.append(String.fromCharCode(chr1));

				if (enc3 != 64) {
					output.append(String.fromCharCode(chr2));
				}
				if (enc4 != 64) {
					output.append(String.fromCharCode(chr3));
				}
			}

			return output.toString();
		}
		function encode64(input) {
			var output = new StringMaker();
			var chr1, chr2, chr3;
			var enc1, enc2, enc3, enc4;
			var i = 0;

			while (i < input.length) {
				chr1 = input.charCodeAt(i++);
				chr2 = input.charCodeAt(i++);
				chr3 = input.charCodeAt(i++);

				enc1 = chr1 >> 2;
				enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
				enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
				enc4 = chr3 & 63;

				if (isNaN(chr2)) {
					enc3 = enc4 = 64;
				} else if (isNaN(chr3)) {
					enc4 = 64;
				}

				output.append(keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4));
		   }
		   
		   return output.toString();
		}

		var ua = navigator.userAgent.toLowerCase();
		if (ua.indexOf(" chrome/") >= 0 || ua.indexOf(" firefox/") >= 0 || ua.indexOf(' gecko/') >= 0) {
			var StringMaker = function () {
				this.str = "";
				this.length = 0;
				this.append = function (s) {
					this.str += s;
					this.length += s.length;
				}
				this.prepend = function (s) {
					this.str = s + this.str;
					this.length += s.length;
				}
				this.toString = function () {
					return this.str;
				}
			}
		} else {
			var StringMaker = function () {
				this.parts = [];
				this.length = 0;
				this.append = function (s) {
					this.parts.push(s);
					this.length += s.length;
				}
				this.prepend = function (s) {
					this.parts.unshift(s);
					this.length += s.length;
				}
				this.toString = function () {
					return this.parts.join('');
				}
			}
		}


function fotogalerie_hidden(){
    fotogalerie_timer = false;
	d = document.getElementById('bigfoto');
    d.innerHTML = '';
    d.style.display='none';
    fotogalerie_timer = false;
    obsah_puvodni = '';
    //alert('fotogalerie_hidden()');
    

}
var fotogalerie_img = "";
function fotogalerie_show(img) {

	fotogalerie_img = img;
	fotogalerie_timer = true;

	if (document.getElementById('bigfoto')==null) {
		document.getElementById('all').innerHTML+=('<div id="bigfoto" style="position:absolute;top:0;left:0;"></div>');
	}
	d = document.getElementById('bigfoto');

	d.style.display='';
	
	fotogalerie_draw();

}
var pocitadlo = 1;
var obsah_puvodni = "";
function fotogalerie_draw(){


	
	
	var img = fotogalerie_img;
	
	hodnoty = ajax_html_cache('plugins/fotogalerie_js.php','file='+img)+";";
	h2 = hodnoty.split(';');

	var pocet_fotek = h2[2];
	
	
	//alert(fotogalerie_timer);
	if (fotogalerie_timer == false) return;
	//var img = img;
	odsazeni = 30;

	body_vyska = document.body.clientHeight;
	body_sirka = document.body.clientWidth;


	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
	  //Non-IE
	  myWidth = window.innerWidth;
	  myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	  //IE 6+ in 'standards compliant mode'
	  myWidth = document.documentElement.clientWidth;
	  myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	  //IE 4 compatible
	  myWidth = document.body.clientWidth;
	  myHeight = document.body.clientHeight;
	}

	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
	  //Netscape compliant
	  scrOfY = window.pageYOffset;
	  scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
	  //DOM compliant
	  scrOfY = document.body.scrollTop;
	  scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
	  //IE6 standards compliant mode
	  scrOfY = document.documentElement.scrollTop;
	  scrOfX = document.documentElement.scrollLeft;
	}


	d = document.getElementById('bigfoto');

	
	


	var newImg = new Image();
	//newImg.src = img;
	
	newImg.width = h2[0];
	newImg.height = h2[1];


	//var img_vyska = newImg.height * 2.00;
	//var img_sirka = newImg.width * 2.00;
	var img_sirka = h2[0];
	var img_vyska = h2[1];

	//alert(img);
	//alert(img_sirka+ " : "+img_vyska);

	okraje = 3;

	myHeight -=30;

	if (pocet_fotek<=1) {
		var pruh_display='none';
		var blok_vyska = (myHeight-odsazeni);
	}
	else {
		var pruh_display='block';
		var blok_vyska = (myHeight-odsazeni-100);
	}	
	
	var blok_sirka = (myWidth-odsazeni);
	


	if (img_sirka <160 && img_sirka > 0) {
		img_vyska = newImg.height/newImg.width * 160;
		img_sirka = 160;
	}

	if (img_sirka>blok_sirka) {
		img_vyska = newImg.height/newImg.width * blok_sirka;
		img_sirka = blok_sirka;


	}

	if (img_vyska>blok_vyska) {
		img_sirka = newImg.width/newImg.height * blok_vyska;
		img_vyska = blok_vyska;

	}


	okraje = 3;
	blok_sirka += 2*okraje;
	blok_vyska += 2*okraje;

	odsazeni_top = Math.round((blok_vyska - (2*okraje) - img_vyska)/2) +15;
	odsazeni_pruh = Math.round(scrOfY);

	odsazeni_img = (scrOfY+(odsazeni/2)) ;

	if (pocet_fotek>1) {
		
		odsazeni_img += 100;
	}
	
	var obsah_galerie = '';;
	

	
	
	obsah_galerie = obsah_galerie+('<div id="fotogalerie_pruh" style="display:'+pruh_display+';position:absolute; border-bottom:solid 1px black;left:0;top:'+odsazeni_pruh+'px; width:'+(body_sirka)+'px; height:99px;background: #212121;z-index:19200;color:white;overflow:hidden;"  ></div>');
 	obsah_galerie = obsah_galerie+('<div style="position:absolute; left:0;top:0; width:'+(body_sirka)+'px; height:'+(body_vyska)+'px;background: url(\'css/img/gray70.png\');z-index:19000" class="pruhledne" ></div>');
 	obsah_galerie = obsah_galerie+('<div style=" padding-top:'+odsazeni_top+'px;position:absolute; z-index:19100; width:'+(blok_sirka)+'px;height:'+(blok_vyska)+'px;overflow:auto;top:'+odsazeni_img+'px;left:'+(scrOfX+(odsazeni/2))+'px;text-align:center;"><img src="'+img+'" onkeydown="fotogalerie_hidden();" onclick="fotogalerie_hidden();"  class="nepruhledne" style="width:'+(img_sirka)+'px;height:'+(img_vyska)+'px;border:solid '+okraje+'px black;cursor:pointer;"/></div>');
 	
 	//if (newImg.width > 0) {

		 if (document.getElementById('navig_foto')==null) {
		 }
		 else {
			 var sstyle = 'z-index:19999;top:'+(odsazeni_top+odsazeni_img-25)+'px;left:'+((myWidth/2)-(img_sirka/2) )+'px;width:'+((img_sirka*1)+(2*okraje))+'px;text-align:left;';
			 //alert(sstyle);
			 obsah_galerie = obsah_galerie+('<div class="fotogalerie_close" style="'+sstyle+'"  >'+document.getElementById('navig_foto').innerHTML+'</div>');
		 }
 	//}

 	
 	if (document.getElementById('holo1')==null) {
 		
 		
 	}
 	else {
 		
 		
	obsah_galerie = obsah_galerie+('<div onkeydown="fotogalerie_hidden();" onclick="fotogalerie_hidden();"  style="padding-top:'+Math.round(odsazeni_top+ (img_vyska * 0.55))+'px;position:absolute; z-index:19908; width:'+(blok_sirka)+'px;height:'+(blok_vyska)+'px;overflow:auto;top:'+(odsazeni_img+2)+'px;left:'+(2+scrOfX+(odsazeni/2))+'px;text-align:center;color:black; font-weight:bold ; font-size:'+Math.round(img_vyska/20)+'px;" class="alfa50">'+document.getElementById('holo1').innerHTML+'</div>');
	obsah_galerie = obsah_galerie+('<div onkeydown="fotogalerie_hidden();" onclick="fotogalerie_hidden();"  style="padding-top:'+Math.round(odsazeni_top+ (img_vyska * 0.55))+'px;position:absolute; z-index:19909; width:'+(blok_sirka)+'px;height:'+(blok_vyska)+'px;overflow:auto;top:'+odsazeni_img+'px;left:'+(scrOfX+(odsazeni/2))+'px;text-align:center;color:white; font-weight:bold ; font-size:'+Math.round(img_vyska/20)+'px;"  class="alfa50">'+document.getElementById('holo2').innerHTML+'</div>');



 		
 		
 	}

	if (obsah_galerie==obsah_puvodni) {
		//document.title = 'ok';
 	}
 	else {
 		d.innerHTML = obsah_galerie;
 		obsah_puvodni = obsah_galerie;
 		//document.title = '. . . .';
 		
 		
 		
 		document.getElementById('fotogalerie_pruh').innerHTML = ajax_html_cache('plugins/fotogalerie.php','file='+img);
 		


 		
 		a = document.getElementById('aktivni_nahled');
 		
 		var imgx = Math.round((body_sirka/2) - getX(a) - (a.width/2)); 
 		//(getX(a));
 		
 		if (imgx > 0) imgx = 0;
 			
 		//alert(imgx);
 		document.getElementById('in_fotogalerie').style.left = ''+imgx+'px';

 		
 		
	 }
 	

    if (fotogalerie_timer == true) {
    	var t=setTimeout("fotogalerie_draw()",500);
    }

	//alert(getScrollXY());
	
    //
}
function getY( oElement )
{
	var iReturnValue = 0;
	while( oElement != null ) {
		iReturnValue += oElement.offsetTop;
		oElement = oElement.offsetParent;
	}
	return iReturnValue;
}
function getX( oElement )
{
var iReturnValue = 0;
	while( oElement != null ) {
		iReturnValue += oElement.offsetLeft;
		oElement = oElement.offsetParent;
	}
	return iReturnValue;
}
function GetDomainName() {

	var url = window.location.href;

	var url_parts = url.split('/');

	var domain_name_parts = url_parts[2].split(':');

	var domain_name = domain_name_parts[0];

	return domain_name;

	}

function formatuj_cas(x){

	// Calculate the number of days left
	//var days=Math.floor(x / 86400);
	// After deducting the days calculate the number of hours left
	//var hours = Math.floor((x - (days * 86400 ))/3600)
	var hours = Math.floor((x )/3600);
	// After days and hours , how many minutes are left
	var minutes = Math.floor((x - (0 * 86400 ) - (hours *3600 ))/60)
	// Finally how many seconds left after removing days, hours and minutes.
	var secs = Math.floor((x - (0 * 86400 ) - (hours *3600 ) - (minutes*60)))

	if (secs<10) secs = "0"+secs;
	if (minutes<10) minutes = "0"+minutes;

	var r = '<span class="odpocet_hodiny" >'+hours + '</span>:<span class="odpocet_minuty" >' + minutes + '</spa>:<span class="odpocet_vteriny" >' + secs+'</span>';
	//var r = minutes + ":" + secs + "";
	
	return r;
	
}


function odpocet_cas(divid,x,formid){

	cas = formatuj_cas(x);

	document.getElementById(divid).innerHTML = cas;

	if (x > 0) {

		setTimeout("odpocet_cas('"+divid+"','"+(x-1)+"','"+formid+"')",1000);

	}
	else {
		
		document.getElementById(formid).innerHTML = '';
		document.getElementById(formid).style.display = 'none';
		
	}
	
}

function koupit_za_body(id_zbozi){
	
	
	document.getElementById("pocet").value = 1;
	document.getElementById("bonus").value = 1;
	document.getElementById("form_polozka"+id_zbozi).submit();
	
	
}


function balik_hledej() {

	
	
	var u = "action=balik_hledej&balik_mesto="+(document.getElementById('balik_mesto').value)+"&balik_psc="+(document.getElementById('balik_psc').value);
	var data = ajax_html_cache("js_connector.php",u);
	
	document.getElementById('balik_vysledky').innerHTML = data;
	
	document.getElementById('step').value = '3';
	
	
	
}


function balik_vyber(posta,adresa,mesto,psc,dorucovaci_adresa) {
	
	document.getElementById('objednavka_3_tabulka').style.display = '';
	document.getElementById('balik_na_postu').style.display = 'none';
	
	document.getElementById('step').value = 4;
	
	document.getElementById('dpsc').value = psc;
	document.getElementById('dpsc').setAttribute('readonly','readonly');
	document.getElementById('dpsc').setAttribute('style','color:#666;background:white;border:0;font-weight:bold;width:400px;');
	
	
	document.getElementById('dmesto').value = mesto;
	document.getElementById('dmesto').setAttribute('readonly','readonly');
	document.getElementById('dmesto').setAttribute('style','color:#666;background:white;border:0;font-weight:bold;width:400px;');
	
	document.getElementById('dadresa2').value = adresa;
	document.getElementById('dadresa2').setAttribute('readonly','readonly');
	document.getElementById('dadresa2').setAttribute('style','color:#666;background:white;border:0;font-weight:bold;width:400px;');
	
	document.getElementById('dadresa1').value = posta;
	document.getElementById('dadresa1').setAttribute('readonly','readonly');
	document.getElementById('dadresa1').setAttribute('style','color:#666;background:white;border:0;font-weight:bold;width:400px;');

	document.getElementById('dstat').value = "ČR";
	document.getElementById('dstat').setAttribute('readonly','readonly');
	document.getElementById('dstat').setAttribute('style','color:#666;background:white;border:0;font-weight:bold;width:400px;');	
	
	for (i=1;i<=6;i++) {
		document.getElementById('da'+i).style.display='';
	}
	
	
	document.getElementById('adresa_je_jina').innerHTML = dorucovaci_adresa;
	
	
}



		
