var et,root;
var foo={};
var cba="#DCDCDC";
if (!root) root='';
function fl(hr,ur){ur=(ur)? ur='&url='+this.location:'';location.href=hr+ur;}
function vr(ids){
	GE('vr'+ids).innerHTML="<img src='"+root+"/gfx/loading.gif' alt=''>";
	arrs=GE('arrs'+ids).innerHTML;
	vals=GE('vals'+ids).innerHTML;
	arrs=arrs.split(';');
	vals=vals.split(';');
	pcs=0;
	out="<div class=vr><table class='ar w100' cellspacing=0><tr><td><strong><small>Varianta:</small></strong></td><td class=ac width='22%'><strong><small>počet</small></strong></td></tr>";
	for(i=0;i<arrs.length;i++){
		if (vals[i]!=0 && vals[i]!=undefined) {
			out+="<tr><td class=b><small>"+arrs[i]+":</small></td><td class=nw><span class=fr><img src='"+root+"/gfx/plus.gif' class=hand onclick=\"addval('pcs"+ids+"-"+i+"',1)\"  alt='+'><br><img src='"+root+"/gfx/minus.gif' class=hand onclick=\"addval('pcs"+ids+"-"+i+"',-1)\"  alt='-'></span><input type=text size=2 name='sel[]' value='"+vals[i]+"' class=ac id='pcs"+ids+"-"+i+"'></td></tr>";
			pcs=1;
		}
		else out+="<tr><td><small>"+arrs[i]+":</small></td><td class=nw><span class=fr><img src='"+root+"/gfx/plus.gif' class=hand onclick=\"addval('pcs"+ids+"-"+i+"',1)\"  alt='+'><br><img src='"+root+"/gfx/minus.gif' class=hand onclick=\"addval('pcs"+ids+"-"+i+"',-1)\"  alt='-'></span><input type=text size=2 name='sel[]' value='0' class=ac onclick='if (this.value==0) this.value=1;' id='pcs"+ids+"-"+i+"'></td></tr>";
	}
	out+="</table></div>";
	if (pcs) out += "<input type=submit value='kupuji vybrané' class=butt>";
	else out += "<input type=submit value='koupit vybrané' class=butt>";
	GE('vr'+ids).innerHTML=out;
}
function addval(ids,val){GE(ids).value=1*(GE(ids).value)+val;if (1*GE(ids).value<0) GE(ids).value=0;}
function axprod(vat,pid,start){window.onscroll=null;ad(root+'/ajaxloadproducts.php?payvat='+vat+'&pid='+pid+'&start='+start);}
function ShowFoto(img,par){ad(root+'/img.php?img='+img+'&root='+root+'&par='+par)}
function GE(eId){return document.getElementById(eId)}
function setc(obj){document.cookie=encodeURIComponent(obj.name)+"="+encodeURIComponent(obj.value)+";expires=Sun, 20 Dec 2020 20:20:20 GMT"}
function ad(url){
	if (GE('ax111')) document.body.removeChild(GE('ax111'));
	var j=document.createElement('SCRIPT');
	j.type='text/javascript';
	j.id='ax111';
	j.src=url;
	document.body.appendChild(j);
}
function SizeMe(){var f=GE('i7');GE('d7').style.height='auto';if (f.width>470) GE('d7').innerHTML='<a href=\'javascript:ShowFoto("'+f.src+'",1)\'><img src="'+f.src+'" alt="'+f.alt+'" title="'+f.alt+'" width="470"><img src="'+root+'/gfx/big.png" id=lupa alt=""></a>';}

var pBox,pImg,pUrl,pFrom,pT;
function getPosXY(a,offset){
	var p=offset?offset.slice(0):[0,0],tn;
	while(a){
		tn=a.tagName.toUpperCase();
		if(tn=='IMG'){a=a.offsetParent;continue;}
		p[0]+=a.offsetLeft;
		p[1]+=a.offsetTop;
		if(tn=="BODY") break;
		a=a.offsetParent;
	}
	return p;
}
function cCompl(){
	if(cCompl.__img && cCompl.__img.complete) cCompl.__onload();
}
cCompl.__onload=function(){
	clearInterval(cCompl.__timeId);
	var w=cCompl.__img.width;
	var h=cCompl.__img.height;
	if(w<150) {pImg.style.width=pImg.style.height='';GE('pBox').innerHTML='';return false;}
	else if(w>h && w>350) pImg.style.width='350px';
	else if(h>=w && h>350) pImg.style.height='350px';
	else pImg.style.width=pImg.style.height='';
	pImg.src=cCompl.__img.src;pUrl.href=cCompl.href;cCompl.__img=null;
}
function sPrev(e,ib,il){
	if (!GE('pBox')){
		var j=document.createElement('DIV');
		j.id='pBox';
		document.body.appendChild(j);
	}
	pBox=GE('pBox');
	if (!GE('pUrl')){
		var j=document.createElement('A');
		j.id='pUrl';
		pBox.appendChild(j);
	}
	pUrl=GE('pUrl');
	if (!GE('pImg')){
		var j=document.createElement('IMG');
		j.id='pImg';
		if (e.pageX) j.onmouseout=function(evt){hPrev(e)};
		else j.onmouseout=function(e){hPrev(e)};
		pUrl.appendChild(j);
	}
	pImg=GE('pImg');
	hPrev(e);
	pFrom=e.target||e.srcElement;
	pImg.style.width=pImg.style.height='';
	pT=setTimeout('_sPrev("'+ib+'","'+il+'")',110);
	cCompl.__img=null;
}
function hPrev(e){
	if(e){
		var toElement=e.relatedTarget||e.toElement;
		while(toElement){
			if(toElement.id=='pBox') return;
			toElement=toElement.parentNode;
		}
	}
	try{
		clearInterval(cCompl.__timeId);
		cCompl.__img=null;
		pImg.src=null;
	}
	catch(e){}
	clearTimeout(pT);
	pBox.style.display='none';
}
function _sPrev(ib,il){
	cCompl.__img=new Image();
	pImg.src=root+'/gfx/loading.gif';
	pFrom.alt=pFrom.title='';
	if (!ib) return;
	else {
		cCompl.__img.src=ib;
		cCompl.href=il;
		cCompl.__timeId=setInterval("cCompl()",10);
		var pos=getPosXY(pFrom,[45,60]);
		pBox.style.left=pos[0]+'px';
		pBox.style.top=pos[1]+'px';
		pBox.style.display='block';
	}
}
function check_fill(obj,mail,descr,conf){
	var msg='';
	if (!descr) descr='';
	et=0;
	for (i=0;i<obj.length;i++){
		o=obj[i];
		if (o.value.length==0){
			 et=1;
			 o.style.backgroundColor=cba;
			 if (descr[i]) msg=msg+'- '+descr[i]+"\n";
		}
		else o.style.backgroundColor="";
	}
	if (mail!='' && mail!=undefined && mail.value.length>0){
		var filter=/^.+@.+\..{2,4}$/;
		if (!filter.test(mail.value)){
			mail.style.backgroundColor=cba; 
			msg=msg+"- Mail\n";et=1;
		}
	}
	if (msg) alert("Zkontrolujte vyplnění políčka:\n"+msg);
	if (et) return false;
	if (conf && !confirm(conf)) return false;
}
function chv(obj,nova,old){if (obj.value==old) obj.value=nova}
function cart_arr(ids,val){
	i = val.indexOf('... ');
	if (i>0){
		val = val.substring(i+4);
		GE('pcs'+ids).value=val;	
	}
	else GE('pcs'+ids).value=0;
}
function sp(){document.cookie='scroll='+document.body.scrollTop+";expires=Sun, 20 Dec 2020 20:20:20 GMT";}
function sc(n,val){document.cookie=n+'='+encodeURIComponent(val)+";expires=Sun, 20 Dec 2020 20:20:20 GMT;path=/";}
function fbw(){
	/*
	document.write("<iframe src='//www.facebook.com/plugins/like.php?href="+encodeURIComponent(location.href)+"&amp;send=false&amp;layout=button_count&amp;width=120&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;height=20' scrolling='no' width=120 height='20' frameborder='0'></iframe>");
	*/
	}
