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_dalsi_img(x,y,z,resize) {
  if(resize==0) {
    var y_new;
    var z_new;
  		y_new=y+30;
  		z_new=z+240;
  		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 + 240;
  		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_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 uvodzoviek!");
   returnValue=false;
   }
}
function jencisla() {
  with (event)
   if(keyCode<48 || keyCode>57){
   alert ("Voľte len čísla!");
   returnValue=false;
   }
   }
function potvrd()
{        if (confirm("Naozaj si želáte túto položku odstrániť z nákupného košíka?")==false) {
return false;
}
}
function potvrd_sprava()
{        if (confirm("Naozaj si želáte položky v tejto objednávke nahradiť položkami z Vášho košíka?\nKliknutím na tlačítko \"OK\" nahradenie potvrdíte.")==false) {
return false;
}
}
function potvrd_unlog() {        
  if (confirm("Naozaj si želáte odhlásiť sa?\nOdhlásením sa vyprázdni aj Váš košík.\n\nKliknutím na tlačítko \"OK\" odhlásenie 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("Naozaj si želáte Vašu objednávku odoslať?")==false) {
   return false;
  }
}
/*function control_basket(form) {
  var canSubmit = true;
  if (form.kolik.value=="")  {
    alert ("Please, enter how many items you want");
    canSubmit = false;
    form.kolik.focus();
  }  
  if (canSubmit == true) {
    return true;
  }
  else {
    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 ("Zadajte počet objednávaných položiek.");
        canSubmit = false;
        form.kolik.focus();    
      }
      else if(form.elements[i].name=="kolik") {
        citac_input=1;
      }
    }  
  } 
  if (canSubmit == true) {
    if(citac_input==0) {
      alert ("Zadajte počet objednávaných položiek.");
      form.elements[prvni_pole_input].focus();
      return false;
    }
    else {
      return true;
    }  
  }
  else {
    return false;
  }
}
function clearMail_web() {
 if (document.mailreg_main.email.value=="your@e-mail") { document.mailreg_main.email.value="";}
}
function check_main() {
		var cform=document.forms.mailreg_main;
		if ((cform.email.value=="@") || (cform.email.value=="")) {
    alert("Pravdepodobne ste zabudli vyplniť 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ávnu syntaxiu");
				  cform.email.focus();
				  return false;
		  }
		}
		else return true;
}
function check_contact(x) {
		if (x.odesilatel.value=="") {
    alert("Napíšte prosím Vašu e-mailovú adresu");
    x.odesilatel.focus();
    return false;
	 }
		else if (x.message.value=="") {
		  alert("Napíšte prosím text sprá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("Zadaný e-mail nemá správnu syntaxiu");
				  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("Pri hlasovaní je nutné najprv označiť 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("Pred kliknutím na \"smajlík\" umiestnite kurzor do textu Vášho príspevku");
	}
}
	function insertAt2Caret (textEl, text, odkaz) {
	odkaz=odkaz*1;
	if(odkaz==0) {
	  alert("Do textového poľa zadajte číslo príspevku, na ktorý si želate odkazovať ");
			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("Umiestnite kurzor do textu Vášho príspevku");
	}
}	
function delic_kosik(x) {
 x.ID_enable.value=0;
 x.submit();
}
function kopirovat(x) {
  x[0].select();
  if(document.getElementById && !document.all) {
    alert("Vaša verzia prehliadača túto funkciu nepodporuje.\nPre skopírovanie označeného textu použite napr. menu pravého tlačítka myši alebo kombináciu kláves Ctrl+C")
  }
  else {
    document.execCommand("Copy");
  }
}

