function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 } 
}
window.onload = externalLinks;

function test(what)
{
	return confirm(what);
}

function openwin(url,name,width,height) 
{
	window.open(url,name,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,width="+width+",height="+height);
}

function clearform(theForm) {
  if (theForm.value=="Zadejte hledaný výraz") {
    theForm.value="";
  } else if (theForm.value=="")  {
    theForm.value="Zadejte hledaný výraz";
  }
}

function disable_select() 
  {
	   //nastaveni orezu a povrchu
	   set_form = document.formular;
	   obj_platba = document.getElementById("platba");
	   //obj_platba.value = ;
	 
	      for (i = 0; i < set_form.length; i++) 
       {
          //zjisteni, ktera doprava je vybrana
          var el = set_form.elements[i];
          if (el.name == "doprava") 
          {
            for (j = 0; j < el.length; j++) 
            {
               if (el.options[j].selected == true)
               {
                
                doprava_selected = el.options[j].value;
               }   
            }
            //ceska posta (1) - dobirka (1) | prevodem (2)
            //osobne (2)- prevodem (2)| hotove (3)
               
            if ( doprava_selected == 1) //posta
            {
              for (k = 0; k < obj_platba.length; k++) 
              {
                    obj_platba.options[k].disabled = false;
              }
              for (k = 0; k < obj_platba.length; k++) 
              {
                  if (obj_platba.options[k].value == 3)
                    obj_platba.options[k].disabled = true;
              }
            }
            if ( doprava_selected >= 2) //osobne
            {
              for (k = 0; k < obj_platba.length; k++) 
              {
                    obj_platba.options[k].disabled = false;
              }
              for (k = 0; k < obj_platba.length; k++) 
              {
                  if (obj_platba.options[k].value == 1)
                    obj_platba.options[k].disabled = true;
              }
            }
          }
        }
  return false;
  }


// tato funkce zaskrtne vsechna pole
	function checkall() {
	  cur = document.formular
        for (i = 0; i < cur.length; i++) {
          var el = cur.elements[i];
          if (el.type == "checkbox") {
            el.checked = true;
          }
        }
    }

  // tato funkce zrusi zaskrtnuti vsech poli
    function uncheckall() {
        cur = document.formular
        for (i = 0; i < cur.length; i++) {
          var el = cur.elements[i];
          if (el.type == "checkbox") {
            el.checked = false;
          }
        }
    }

function zkontroluj_registraci(theForm){
  if (theForm.login.value == "" || theForm.login.value.length < 2){
		alert("Prosím zadejte přihlašovací jméno.");
		theForm.login.focus();
		return false;
	}
	if (theForm.email.value == "" || theForm.email.value.indexOf('@',1)== -1 || theForm.email.value.indexOf('.',2)==-1){
		alert("Prosím zadejte emailovou adresu.");
		theForm.email.focus();
 		return false;
	}
return true;
}
	
function zkontroluj_dotaz(theForm){
  if (theForm.jmeno.value == "" || theForm.jmeno.value.length < 5){
		alert("Prosím zadejte jméno a příjmení.");
		theForm.jmeno.focus();
		return false;
	}
	if (theForm.email.value == "" || theForm.email.value.indexOf('@',1)== -1 || theForm.email.value.indexOf('.',2)==-1){
		alert("Prosím zadejte emailovou adresu.");
		theForm.email.focus();
		return false;
	}
	if (theForm.dotaz.value == "" || theForm.dotaz.value.length < 5){
		alert("Prosím zadejte dotaz.");
		theForm.dotaz.focus();
		return false;
	}
}

function zkontroluj_poslat_odkaz(theForm){
	if (theForm.email_od.value == "" || theForm.email_od.value.indexOf('@',1)== -1 || theForm.email_od.value.indexOf('.',2)==-1){
		alert("Prosím zadejte emailovou adresu.");
		theForm.email_od.focus();
		return false;
	}
	if (theForm.email_komu.value == "" || theForm.email_komu.value.indexOf('@',1)== -1 || theForm.email_komu.value.indexOf('.',2)==-1){
		alert("Prosím zadejte emailovou adresu.");
		theForm.email_komu.focus();
		return false;
	}
	if (theForm.predmet.value == "" || theForm.predmet.value.length < 2){
		alert("Prosím zadejte předmět.");
		theForm.predmet.focus();
		return false;
	}
	if (theForm.zprava.value == "" || theForm.zprava.value.length < 2){
		alert("Prosím zadejte text zprávy.");
		theForm.zprava.focus();
		return false;
	}
}

function zkontroluj_diskusi(theForm)
{
  if (theForm.jmeno.value == "" || theForm.jmeno.value.length < 2){
	  alert("Prosím zadejte jméno.");
	  theForm.jmeno.focus();
	  return false;
  }
	if (theForm.email.value == "" || theForm.email.value.indexOf('@',1)== -1 || theForm.email.value.indexOf('.',2)==-1){
	  alert("Prosím zadejte emailovou adresu.");
	  theForm.email.focus();
	  return false;
  }
  if (theForm.predmet.value == "" || theForm.predmet.value.length < 2){
	  alert("Prosím zadejte předmět.");
	  theForm.predmet.focus();
	  return false;
  }
  if (theForm.text.value == "" || theForm.text.value.length < 2){
	  alert("Prosím zadejte text příspěvku.");
	  theForm.text.focus();
	  return false;
  }
  if (theForm.kontrola_kodu.value == "" || theForm.kontrola_kodu.value.length < 5){
	  alert("Prosím zadejte kontrolní kod.");
	  theForm.kontrola_kodu.focus();
	  return false;
  }
  return true;
}
function zkontroluj_editaci_uzivatele(theForm)
{
  if (theForm.jmeno.value == "" || theForm.jmeno.value.length < 2){
	  alert("Prosím zadejte jméno.");
	  theForm.jmeno.focus();
	  return false;
  }
  if (theForm.prijmeni.value == "" || theForm.prijmeni.value.length < 2){
	  alert("Prosím zadejte příjmení.");
	  theForm.prijmeni.focus();
	  return false;
  }
	if (theForm.email.value == "" || theForm.email.value.indexOf('@',1)== -1 || theForm.email.value.indexOf('.',2)==-1){
	  alert("Prosím zadejte emailovou adresu.");
	  theForm.email.focus();
	  return false;
  }
  if (theForm.ulice_a_cp.value == "" || theForm.ulice_a_cp.value.length < 2){
	  alert("Prosím zadejte ulici.");
	  theForm.ulice_a_cp.focus();
	  return false;
  }
  if (theForm.cp.value == "" || theForm.cp.value.length < 1){
	  alert("Prosím zadejte číslo popisné.");
	  theForm.cp.focus();
	  return false;
  }
  if (theForm.mesto.value == "" || theForm.mesto.value.length < 2){
	  alert("Prosím zadejte město.");
	  theForm.mesto.focus();
	  return false;
  }
  if (theForm.psc.value == "" || theForm.psc.value.length < 2){
	  alert("Prosím zadejte PSČ.");
	  theForm.psc.focus();
	  return false;
  }
  if (theForm.stat.value == "" || theForm.stat.value.length < 2){
	  alert("Prosím zadejte stát.");
	  theForm.stat.focus();
	  return false;
  }
  return true;
}

function zkontroluj_objednavku(theForm)
{
  if (theForm.jmeno.value == "" || theForm.jmeno.value.length < 2){
	  alert("Prosím zadejte jméno.");
	  theForm.jmeno.focus();
	  return false;
  }
  if (theForm.prijmeni.value == "" || theForm.prijmeni.value.length < 2){
	  alert("Prosím zadejte příjmení.");
	  theForm.prijmeni.focus();
	  return false;
  }
	if (theForm.email.value == "" || theForm.email.value.indexOf('@',1)== -1 || theForm.email.value.indexOf('.',2)==-1){
	  alert("Prosím zadejte emailovou adresu.");
	  theForm.email.focus();
	  return false;
  }
  if (theForm.ulice_a_cp.value == "" || theForm.ulice_a_cp.value.length < 2){
	  alert("Prosím zadejte ulici.");
	  theForm.ulice_a_cp.focus();
	  return false;
  }
  if (theForm.cp.value == "" || theForm.cp.value.length < 1){
	  alert("Prosím zadejte číslo popisné.");
	  theForm.cp.focus();
	  return false;
  }
  if (theForm.mesto.value == "" || theForm.mesto.value.length < 2){
	  alert("Prosím zadejte město.");
	  theForm.mesto.focus();
	  return false;
  }
  if (theForm.psc.value == "" || theForm.psc.value.length < 2){
	  alert("Prosím zadejte PSČ.");
	  theForm.psc.focus();
	  return false;
  }
  if (theForm.stat.value == "" || theForm.stat.value.length < 2){
	  alert("Prosím zadejte stát.");
	  theForm.stat.focus();
	  return false;
  }
  if (theForm.souhlas.checked == false){
	  alert("Prosím potvrďte souhlas s obchodními podmínkami.");
	  theForm.souhlas.focus();
	  return false;
  }
  return true;
}


function show(object) {
	if (document.getElementById && document.getElementById(object) != null)
	node = document.getElementById(object).style.display='inline';
	else if (document.layers && document.layers[object] != null)
	document.layers[object].display = 'inline';
	else if (document.all)
	document.all[object].style.display = 'inline';
}

function hide(object) {
	if (document.getElementById && document.getElementById(object) != null)
	node = document.getElementById(object).style.display='none';
	else if (document.layers && document.layers[object] != null)
	document.layers[object].display = 'none';
	else if (document.all)
	document.all[object].style.display = 'none';
}

function change_background(where, color) {
	var obj = document.getElementById(where);
	obj.style.background = color;
}	

	
function change_pic(url, where, text) {
	var img = document.getElementById(where);
	img.src = url;
	img.title = text;
	img.alt = text;
	
}	

function empty_pic(where, picture) {
	var img = document.getElementById(where);
	img.src = picture;
}	

function add_text(where, text) {
	var node = document.getElementById(where);
	node = text;
}	

//Horni menu

navHover = function() {
var lis = document.getElementById("menu").getElementsByTagName("LI");
for (var i=0; i<lis.length; i++) {
lis[i].onmouseover=function() {
this.className+=" iehover";
}
lis[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" iehover\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", navHover);


function show_mk(no) {
	hide_mk();
	var obj;
	
		obj = document.getElementById('mk0' + no);
		obj.style.display='block';
	
}

function hide_mk() {
	var obj;
	for (var i=1; i<=5; i++) {
		obj = document.getElementById('mk0' + i);
		obj.style.display='none';
	}
}


