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);
}

// 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_dotaz(theForm){
  if (theForm.jmeno.value == "" || theForm.jmeno.value.length < 2){
		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.telefon.value == "" || theForm.telefon.value.length < 5){
		alert("Prosím zadejte telefon.");
		theForm.telefon.focus();
		return false;
	}
	if (theForm.dotaz.value == "" || theForm.dotaz.value.length < 5){
		alert("Prosím zadejte dotaz.");
		theForm.dotaz.focus();
		return false;
	}
return true;
}

function zkontroluj_registraci(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.telefon.value == "" || theForm.telefon.value.length < 2){
		alert("Prosím zadejte telefon.");
		theForm.telefon.focus();
		return false;
	}
	if (theForm.heslo1.value == "" || theForm.heslo1.value.length < 5){
		alert("Prosím zadejte heslo.");
		theForm.heslo1.focus();
		return false;
	}
	if (theForm.heslo2.value == "" || theForm.heslo2.value.length < 5){
		alert("Prosím zadejte ověření hesla.");
		theForm.heslo2.focus();
		return false;
	}
	if (theForm.heslo1.value != theForm.heslo2.value){
		alert("Zadaná hesla se neshodují. Zadejte je prosím znovu.");
		theForm.heslo1.focus();
		return false;
	}
return true;
}

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.telefon.value == "" || theForm.telefon.value.length < 2){
		alert("Prosím zadejte telefon.");
		theForm.telefon.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 == ""){
	  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;
  }
  return true;
}


function zkontroluj_velkoobchod(theForm)
{
  if (theForm.firma.value == "" || theForm.firma.value.length < 2){
	  alert("Prosím zadejte název firmy.");
	  theForm.firma.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 == ""){
	  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.ico.value == "" || theForm.ico.value.length < 2){
	  alert("Prosím zadejte IČ.");
	  theForm.ico.focus();
	  return false;
  }
  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.telefon.value == "" || theForm.telefon.value.length < 2){
	  alert("Prosím zadejte telefon.");
	  theForm.telefon.focus();
	  return false;
  }
	if (theForm.heslo1.value == "" || theForm.heslo1.value.length < 5){
		alert("Prosím zadejte heslo.");
		theForm.heslo1.focus();
		return false;
	}
	if (theForm.heslo2.value == "" || theForm.heslo2.value.length < 5){
		alert("Prosím zadejte ověření hesla.");
		theForm.heslo2.focus();
		return false;
	}
	if (theForm.heslo1.value != theForm.heslo2.value){
		alert("Zadaná hesla se neshodují. Zadejte je prosím znovu.");
		theForm.heslo1.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.telefon.value == "" || theForm.telefon.value.length < 2){
		alert("Prosím zadejte telefon.");
		theForm.telefon.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 == ""){
	  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;
}	

