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_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() {
  with (event)
   if(keyCode==34 || keyCode==39){
   alert ("Bez uvozovek!");
   returnValue=false;
   }
}
function jencisla() {
  with (event)
   if(keyCode<48 || keyCode>57){
   alert ("Volte pouze čísla!");
   returnValue=false;
   }
   }
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";
      } 
    }   
  }
  /*
  browName = navigator.appName;
  browVerze = parseInt(navigator.appVersion);
  if (browName=="Microsoft Internet Explorer" & browVerze >=4 ){
    if (document.body.offsetWidth < 1000) {
      document.getElementById("wrapper").style.width="1000px";
    }
  }
  */
}
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 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 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();
}
