// this check if data not equal "" 

function validateRequest() {

        var form = document.sendForm;
        
        // --- DATE FROM & TO ---
	if (form.date_from.value == "") {
		alert("Need FROM date value.");
		return false;
        }
        
        if (form.date_to.value == "") {
		alert("Need TO date value.");
		return false;
        }
        
        // --- ACCOMMODATION TYPE ---
	if (form.Accommodation_type.value == "") {
		alert("Need accommodation type value.");
		return false;
        }
        
        // --- ROOMs ---
	if (form.Rooms.value == "") {
	        alert("Need room value.");
	        return false;
        }
        
        // --- ROOM COUNT ---      
	if (form.rooms_count.value == "") {
		alert("You didn't enter a room(s) quantity.");
		form.rooms_count.focus();
		return false;
	}
	
	var stripped1 = form.rooms_count.value.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
	if (isNaN(parseInt(stripped1))) {
		alert("The room(s) quantity contains illegal characters(use numbers).");
		form.rooms_count.focus();
		return false;
	}
        
        
        // --- PERSON COUNT ---
        
        if (form.persons_count.value == "") {
	   alert("You didn't enter a person(s) quantity.");
	   form.persons_count.focus();
	   return false;
	}

	var stripped = form.persons_count.value.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
	if (isNaN(parseInt(stripped))) {
		alert("The person(s) quantity contains illegal characters(use numbers).");
		form.persons_count.focus();
		return false;
	}


	// --- PERSON NAME ---
        if (form.persons_name.value == "") {
		alert("Need person name value.");
		form.persons_name.focus();
		return false;
        }
        
        
        // --- PERSON SURNAME ---
        if (form.persons_surname.value == "") {
		alert("Need person surname value.");
		form.persons_surname.focus();
		return false;	
        }
        
        // --- EMAIL VALIDATION ---		
	if ((form.persons_email.value==null)||(form.persons_email.value=="")){
		alert("Please Enter your Email ID");
		form.persons_email.focus();
		return false;
	}
	if (echeck(form.persons_email.value)==false){
		form.persons_email.value="";
		form.persons_email.focus();
		return false;
	}
        
        function echeck(str) {
	
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
					
	}
	
	// --- PHONE VALIDATION ---
	
	if (form.persons_phone.value == "") {
	   alert("You didn't enter a phone number.");
	   form.persons_phone.focus();
	   return false;
	}
	
	var stripped = form.persons_phone.value.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
	if (isNaN(parseInt(stripped))) {
		alert("The phone number contains illegal characters(use numbers).");
		form.persons_phone.focus();
	  	return false;
	}
	
	if (stripped.length < 9) { // phone number length must be =/> then 9 digits
		alert("The phone number is the wrong length. Make sure you included an area code.");
		form.persons_phone.focus();
		return false;
    	}

	document.sendForm.submit();
	return true;

}

function validateAnswer() {

	var form = document.sendInfo;

	if (form.questionaire_options.value == "") {
		alert("No answer selected.");
		return false;
        }

	return true;

}

function validateLogin() {
  
  var form = document.loginForm;
  
  // --- validate user ---
	if (form.UserName.value == "") {
		alert("You must enter valid user name.");
		return false;
  }
  
  // --- validate password ---
	if (form.Pass.value == "") {
		alert("Password can't have null value.");
		return false;
  }
  
  // --- check for pass length ---
  if (form.Pass.value.length < 8) { 
		alert("Password have wrong length. Must have at least 8 characters.");
		return false;
  }
  
  return true;

}

function validateData() {
  var form = document.sendDataForm;
  
  // --- validate password ---
	if (form.visibility_status.value == "ZAPNUTO" && form.cz_text.value == "") {
		alert("Český text nesmí mít nulovou hodnotu.");
		return false;
  }
  
  if (form.visibility_status.value == "ZAPNUTO" && form.gb_text.value == "") {
		alert("Anglický text nesmí mít nulovou hodnotu.");
		return false;
  }
  
  if (form.visibility_status.value == "ZAPNUTO" && form.de_text.value == "") {
		alert("Německý text nesmí mít nulovou hodnotu.");
		return false;
  }
  
  if (form.visibility_status.value == "ZAPNUTO" && form.ru_text.value == "") {
		alert("Ruský text nesmí mít nulovou hodnotu.");
		return false;
  }
  
  document.sendDataForm.submit();
  return true;
}

