var highlightcolor="lightyellow"

var ns6=document.getElementById&&!document.all
var previous=''
var eventobj

//Regular expression to highlight only form elements
var intended=/INPUT|TEXTAREA|SELECT|OPTION/

//Function to check whether element clicked is form element
function checkel(which){
if (which.style&&intended.test(which.tagName)){
if (ns6&&eventobj.nodeType==3)
eventobj=eventobj.parentNode.parentNode
return true
}
else
return false
}

//Function to highlight form element
function highlight(e){
eventobj=ns6? e.target : event.srcElement
if (previous!=''){
if (checkel(previous))
previous.style.backgroundColor=''
previous=eventobj
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
}
else{
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
previous=eventobj
}
}

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 12;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function ValidateForm(){
	var Phone=document.kosik.tel
	
	if ((Phone.value==null)||(Phone.value=="")){
		alert("Vložte prosím správné telefonní číslo")
		Phone.focus()
		return false
	}
	if (checkInternationalPhone(Phone.value)==false){
		alert("Prosím vložte správné telefonní číslo v mezinárodním formátu a bez mezer např. ČR +420123456789 nebo SR +421987654321")
		Phone.value=""
		Phone.focus()
		return false
	}
	return true
 }
      
      function valid(form) 
{

    if (document.formular.nick.value == "")
   {
      document.formular.nick.focus();
      alert ("Chybí vyplněné přihlašovací jméno");
      return false;
   }
   
   if (form.password.value != form.password2.value) {
   	  document.formular.password2.focus();
   	  alert("Hesla nejsou shodná.");
   	  return false
  }		
  
  if (isNaN(parseInt(document.formular.tel.value)))
  	 {
   	 document.formular.tel.focus();
   	 alert ("Chybný formát telefonního čísla");
   	 return false;
	 }
	 
    if (document.formular.prijmeni.value == "")
   {
      document.formular.prijmeni.focus();
      alert ("Chybí vyplněné PŘÍJMENÍ");
      return false;
   }
    if (document.formular.jmeno.value == "")
   {
      document.formular.jmeno.focus();
      alert ("Chybí vyplněné JMÉNO");
      return false;
   }
    if (document.formular.ulice.value == "")
   {
      document.formular.ulice.focus();
      alert ("Chybí vyplněné pole ULICE");
      return false;
   }
    if (document.formular.mesto.value == "")
   {
      document.formular.mesto.focus();
      alert ("Chybí vyplněné pole MĚSTO");
      return false;
   }
    if (document.formular.psc.value == "")
   {
      document.formular.psc.focus();
      alert ("Chybí vyplněné pole PSČ");
      return false;
   }

  var Phone=document.formular.tel
	
	if ((Phone.value==null)||(Phone.value=="")){
		alert("Prosím vložte vaše telefonní číslo!!!")
		Phone.focus()
		return false
	}
	if (checkInternationalPhone(Phone.value)==false){
		alert("Prosím vložte správné telefonní číslo v mezinárodním formátu a bez mezer např. ČR +420123456789 nebo SR +421987654321")
		Phone.value=""
		Phone.focus()
		return false
	} 
	
	if (document.formular.email.value.indexOf("@") == -1)
   {
      document.formular.email.focus();
      alert ("Chybný formát e-mailu");
      return false;
   }
   
   if (form.email.value != form.email2.value) {
   	  document.formular.email2.focus();
   	  alert("E-maily se neshodují. Zkontrolujte zada jsou správně zadané.");
   	  return false
  }	
	 
 else return true;

  }

  // zakazane prave tlacitko
  function right(e) {
if (navigator.appName == 'Netscape' && 
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' && 
(event.button == 2 || event.button == 3)) {
alert("www.e-lady.cz");
return false;
}
return true;
}

document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;