document.documentElement.className = "js";
function otevri(stranka) {
  if(stranka=="kontakt") {
    /* mozilla */
    if(document.getElementById && !document.all) {
      msg=window.open("kontakt.php","kontakt","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=430,height=520,top=0,left=0");
    }
    /* IE */
    else {
      msg=window.open("kontakt.php","kontakt","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=415,height=500,top=0,left=0");
    }
  }
  else {
    if(stranka=="podminky") {
      msg=window.open("obchod_podminky_gen.php#ochrana","podminky","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=598,height=460,top=0,left=0");
    }
    else {
      if(stranka=="podminkygen") {
        msg=window.open("obchod_podminky_gen.php","podminky","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=598,height=460,top=0,left=0");
      }
      else {
        if(stranka=="bodiky") {
          msg=window.open("info_body.php","bodiky","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=460,height=460,top=0,left=0");
        }
        else {
          msg=window.open(stranka,"detail","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=860,height=860,top=0,left=0");
        }
      }
    }
  }
		msg.focus();
}
function otevri_dalsi_img(x,y,z,resize) {
  if(resize==0) {
    var y_new;
    var z_new;
  		y_new=y+30;
  		z_new=z+250;
  		if(y_new<350) {
  		  y_new=350;
  		}
  		if(z_new>screen.height) {
  		  z_new=screen.height
  		}
  		//if(document.getElementById && !document.all) y_new=screen.width;
    msg=window.open(x, 'obalka', 'toolbar=no,menubar=no,location=no,directories=no,scrollbars=no,resizable=yes,status=no,width='+y_new+',height='+z_new+',top=0,left=0')
    msg.resizeTo(y_new,z_new);
    msg.focus();
  }
  else {
    var getimg;
    getimg = document.images.obr;
    var y_new;
    var z_new;
    y_new = getimg.width + 30;
    z_new = getimg.height + 250;
  		if(y_new<350) {
  		  y_new=350;
  		}
  		if(z_new>screen.height) {
  		  z_new=screen.height
  		}    
    window.resizeTo(y_new,z_new);
    window.focus;
  } 
}
function otevri_obalka(x,y,z) {
    //rozsiruji okno kvuli scrollerum, pro FF dam sirku PC obrazovky
    var y_new;
				y_new=y+40;
				if(document.getElementById && !document.all) y_new=screen.width;
    msg=window.open(x, 'obalka', 'toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes,resizable=yes,status=no,width='+y_new+',height='+z+',top=0,left=0')
    msg.focus();
}
function otevri_help(stranka) {
  msg=window.open(stranka, "help", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=598,height=460,top=0,left=0");
  msg.focus();
}
function otevri_send_psw(stranka) {
  msg=window.open(stranka,"send_psw","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=598,height=350,top=0,left=0");
  msg.focus();
}
function otevri_board(stranka) {
 msg=window.open(stranka,'okno','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=780,height=210,top=0,left=0');
	msg.focus();
}
function bezuvozovek(e) {
  if(!e) var e = window.event;
  with(e)
  if (e.keyCode) {
      key = e.keyCode;
   }
   else {
      key = e.which;
   }
   if((key==34 || key==39) && key!=8 && key!=37 && key!=38 && key!=40 && key!=13){
     alert ("Bez uvozovek!");
     return false;
   }
   else {
     return true;
   }
}
function jencisla(e) {
  if(!e) var e = window.event;
  with(e)
  if (e.keyCode) {
      key = e.keyCode;
   }
   else {
      key = e.which;
   }
   //alert(key);
   if((key<48 || key>57) && key!=8 && key!=37 && key!=38 && key!=40 && key!=13){
     alert ("Volte pouze čísla!");
     return false;
   }
   else {
     return true;
   }
}
function potvrd()
{        if (confirm("Opravdu chcete tuto položku odstranit z nákupního košíku?")==false) {
return false;
}
}
function control_basket(form) {
  var canSubmit = true;
  var z;
  var citac_input=0;
  var prvni_pole_input=0;
  for(var i=0;i<form.elements.length;i++) {
    z=form.elements[i].name.indexOf("[");
    if(z>0) {
      if(prvni_pole_input==0) {
        prvni_pole_input=i;
      }  
      if(form.elements[i].value != "") {
        citac_input=1;
      }
    }
    else {
      if(form.elements[i].name=="kolik" && form.elements[i].value=="") {
        alert ("Zadejte počet objednávaných položek.");
        canSubmit = false;
        form.kolik.focus();    
      }
      else if(form.elements[i].name=="kolik") {
        citac_input=1;
      }
    }  
  } 
  if (canSubmit == true) {
    if(citac_input==0) {
      alert ("Zadejte počet objednávaných položek.");
      form.elements[prvni_pole_input].focus();
      return false;
    }
    else {
      return true;
    }  
  }
  else {
    return false;
  }
}
function potvrd_sprava()
{        if (confirm("Opravdu chcete položky v této objednávce nahradit položkami z Vašeho košíku?\nKliknutím na tlačítko \"OK\" nahrazení potvrdíte.")==false) {
return false;
}
}
function potvrd_unlog() {        
  if (confirm("Opravdu se chcete odhlásit?\nOdhlášením se vyprázdní i Váš košík.\n\nKliknutím na tlačítko \"OK\" odhlášení potvrdíte")==false) {
  return false;
  }
}
function ukaz_detail(x,y) {
  if(!document.getElementById && document.all) document.getElementById = document.all;
  document.getElementById(x).style.display="block";
  document.getElementById(y).style.display="none";
}
function skryj(x,y) {
  if(!document.getElementById && document.all) document.getElementById = document.all;
  document.getElementById(x).style.display="none";
  spans = document.getElementsByTagName("span");
  for (var i = 0; i < spans.length; i++) {
    if(spans[i].id) {
      if(spans[i].getAttribute("id").indexOf("submit_doplnkovy_delic")==0) {
        document.getElementById(spans[i].getAttribute("id")).style.display="none";
      } 
    }   
  }
}
function potvrd_objednavka() {
  if (confirm("Opravdu chcete Vaši objednávku odeslat?")==false) {
   return false;
  }
}
function clearMail_web() {
 if (document.mailreg_main.email.value=="váš@e-mail") { document.mailreg_main.email.value="";}
}
function check_main() {
		var cform=document.forms.mailreg_main;
		if ((cform.email.value=="@") || (cform.email.value=="")) {
    alert("Pravděpodobně jste zapomněli vyplnit Váš e-mail");
    cform.email.focus();
    return false;
	 }
		else if (window.RegExp) {
		  re = new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,4}$", "i");
		  if (!re.test(cform.email.value)) {
					 alert("Zadaný e-mail nemá správnou syntaxi");
				  cform.email.focus();
				  return false;
		  }
		}
		else return true;
}	
function check_contact(x) {
		if (x.odesilatel.value=="") {
    alert("Napište prosím Vaši e-mailovou adresu");
    x.odesilatel.focus();
    return false;
	 }
		else if (x.message.value=="") {
		  alert("Napište prosím text zprávy!");
				x.message.focus();
				return false;
		}		
		else if (window.RegExp) {
		  re = new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,4}$", "i");
		  if (!re.test(x.odesilatel.value)) {
					 alert("Uvedená e-mailová adresa je zřejmě neplatná");
				  x.odesilatel.focus();
				  return false;
		  }
		}
		else return true;
}

function check_diskuze(x) {
	 if (x.nazev_diskuze.value=="") {
	   alert("Napište prosím název komentáře");
    x.nazev_diskuze.focus();
    return false;
	 }
		else if (x.prispevek_diskuze.value=="") {
    alert("Napište prosím Váš komentář");
    x.prispevek_diskuze.focus();
    return false;
	 }
		else return true;
}

function checkFrmAnketa() {
		var cform=document.forms.frmAnketa;
		var i = 0;
		var isChecked = false;

		while (i < cform.cid.length) {
			if (cform.cid[i].checked) isChecked = true;
			i++;
		}
			if (isChecked==false) {
				alert("Při hlasování je nutno nejprve zaškrtnou jednu z možností.");
				return false;
			}
			else 
				return true;
}

function storeCaret (textEl) {
	if (textEl.createTextRange) 
		textEl.caretPos = document.selection.createRange().duplicate();
}	

	function insertAtCaret (textEl, text) {
	if (textEl.createTextRange && textEl.caretPos) {
		var caretPos = textEl.caretPos;
		caretPos.text =	caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
	}
	else if(document.getElementById && !document.all) {
	  textEl.value  += text;  
	 }
else {
	 alert("Před kliknutím na \"smajlík\" umístěte kurzor do textu Vašeho příspěvku");
	}
}

function InsertFlash(src,width,height) { 
		document.writeln("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"" + width + "\" height=\"" + height + "\">");
		document.writeln("    <param name=\"movie\" value=\"" + src + "\" />");
		document.writeln("    <param name=\"quality\" value=\"high\" />");
		document.writeln("    <param name=\"wmode\" value=\"transparent\" />");
		document.writeln("    <embed src=\"" + src + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + width + "\" height=\"" + height + "\" wmode=\"transparent\"></embed></object>");
}

	function insertAt2Caret (textEl, text, odkaz) {
	odkaz=odkaz*1;
	if(odkaz==0) {
	  alert("Do textového pole zadejte číslo příspěvku, na který chcete odkazovat");
			document.vlozit.odkazprispevek.focus();
	}
	else if (textEl.createTextRange && textEl.caretPos) {
		var caretPos = textEl.caretPos;
		caretPos.text =	caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
	}
	else if(document.getElementById && !document.all) {
	  textEl.value  += text;  
	 }
else {
	 alert("Umístěte kurzor do textu Vašeho příspěvku");
	}
}
function delic_kosik(x) {
 x.ID_enable.value=0;
 x.submit();
}
function kopirovat(x) {
  x[0].select();
  if(document.getElementById && !document.all) {
    alert("Vaše verze prohlížeče tuto funkci nepodporuje.\nPro zkopírování označeného textu použijte např. menu pravého tlačítka myši nebo kombinaci kláves Ctrl+C")
  }
  else {
    document.execCommand("Copy");
  }
}
function skryj_and_scroll(x,y) {
  skryj(x,y);
  var destinationLink = null;
  var anchor = null;
  if (location.href.indexOf('#') != -1) {
    var urlHash_pole = location.href.split("#");
    var urlHash = urlHash_pole[1];
    if(urlHash.length>0) {
      var allLinks = document.getElementsByTagName('form');
      for (var i=0;i<allLinks.length;i++) {
        var lnk = allLinks[i];
        var anchor_pole=lnk.action.split("#");
        if(anchor_pole[1]==urlHash) {
          anchor=anchor_pole[1];
          break;
        }
      }
    }
  }
  if (!anchor) return true;
  //projdu img na name
  //var allLinks = document.getElementsByTagName('img');
  //var allLinks = document.getElementsByTagName('a');
  var allLinks = document.getElementsByTagName('span');
  var destinationLink = null;
  for (var i=0;i<allLinks.length;i++) {
    var lnk = allLinks[i];
    //if (lnk.href && (lnk.href == "http://" + anchor + "/")) {
    //if (lnk.name && (lnk.name == anchor)) {
    if (lnk.className && (lnk.className == anchor)) {
      destinationLink = lnk;
      break;
    }
  }  
  if (!destinationLink) return true;
  var destx = destinationLink.offsetLeft; 
  var desty = destinationLink.offsetTop;
  var thisNode = destinationLink;
  while (thisNode.offsetParent && 
        (thisNode.offsetParent != document.body)) {
    thisNode = thisNode.offsetParent;
    destx += thisNode.offsetLeft;
    desty += thisNode.offsetTop;
  }    
  ss_scrollWindow(desty,anchor)
  return false;
}
function ss_scrollWindow(dest,anchor) {
 wascypos = ss_getCurrentYPos();
 isAbove = (wascypos < dest);
 window.scrollTo(0,wascypos);
 iscypos = ss_getCurrentYPos();
 isAboveNow = (iscypos < dest);
 if ((isAbove != isAboveNow) || (wascypos == iscypos)) {
   // if we've just scrolled past the destination, or
   // we haven't moved from the last scroll (i.e., we're at the
   // bottom of the page) then scroll exactly to the link
   window.scrollTo(0,dest);
 }
}
function ss_getCurrentYPos() {
  if (document.body && document.body.scrollTop)
    return document.body.scrollTop;
  if (document.documentElement && document.documentElement.scrollTop)
    return document.documentElement.scrollTop;
  if (window.pageYOffset)
    return window.pageYOffset;
  return 0;
}
