// JavaScript Document

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("Ungültige E-mail Adresse")
     return false
  }
 
  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
     alert("Ungültige E-mail Adresse")
     return false
  }
 
  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
      alert("Ungültige E-mail Adresse")
      return false
  }
 
   if (str.indexOf(at,(lat+1))!=-1){
      alert("Ungültige E-mail Adresse")
      return false
   }
 
   if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
      alert("Ungültige E-mail Adresse")
      return false
   }
 
   if (str.indexOf(dot,(lat+2))==-1){
      alert("Ungültige E-mail Adresse")
      return false
   }
  
   if (str.indexOf(" ")!=-1){
      alert("Ungültige E-mail Adresse")
      return false
   }
 
    return true     
 }
 
  //Javascript validation for Property portfolio contact forms

 
function ValidateForm(){
//alert(document.getElementById("WebFormContactEmail-TextboxTextbox").value);

today = new Date(); // Initialize Date in raw form
date = today.getDate(); // Get the numerical date
year = today.getFullYear(); // Get the year
day = today.getDay(); // Get the day in number form (0,1,2,3,etc.)
month = today.getMonth()+1; // Get the month
hours = today.getHours();
minutes = today.getMinutes();

// Make day number value correspond to actual day name
var dayName=new Array(7)
dayName[0]="Sun";
dayName[1]="Mon";
dayName[2]="Tue";
dayName[3]="Wed";
dayName[4]="Thu";
dayName[5]="Fri";
dayName[6]="Sat";

// Add suffix to date (1st, 2nd, 4th, etc.)
if (date==1) suffix=("st");
else if (date==2) suffix=("nd");
else if (date==3) suffix=("rd");
else if (date==21) suffix=("st");
else if (date==22) suffix=("nd");
else if (date==23) suffix=("rd");
else if (date==31) suffix=("st");
else suffix=("th");

// Make month number correspond to month name
if (month==1) monthName=("1");
else if (month==2) monthName=("2");
else if (month==3) monthName=("3");
else if (month==4) monthName=("4");
else if (month==5) monthName=("5");
else if (month==6) monthName=("6");
else if (month==7) monthName=("7");
else if (month==8) monthName=("8");
else if (month==9) monthName=("9");
else if (month==10) monthName=("10");
else if (month==11) monthName=("11");
else monthName=("12");

// Write date
document.getElementById('orderReportdate-textBoxTextbox').value = date + "/" + monthName + "/" + year;

 var f_name = document.getElementById("orderReportfirst-name-textBoxTextbox").value;
 if ((f_name==null)||(f_name=="")){
  alert("Bitte tragen Sie Ihren Vornamen ein");
  return false
 }
 
 var l_name = document.getElementById("orderReportsur-name-textBoxTextbox").value;
 if ((l_name==null)||(l_name=="")){
  alert("Bitte tragen Sie Ihren Nachnamen ein");
  return false
 }


 var emailID= document.getElementById("orderReportemail-address-textBoxTextbox")
 //alert(emailID);
 if ((emailID.value==null)||(emailID.value=="")){
  alert("Bitte tragen Sie Ihre E-mail Adresse ein")
  emailID.focus()
  return false
 }
 
 if (echeck(emailID.value)==false){
  emailID.value=""
  emailID.focus()
  return false
 }
 
 
 var address = document.getElementById("orderReportstreet-textBoxTextbox").value;
 if ((address==null)||(address=="")){
  alert("Bitte tragen Sie Ihre Strasse ein");
  return false
 }
 
  var post = document.getElementById("orderReportnumber-textBoxTextbox").value;
 if ((post==null)||(post=="")){
  alert("Bitte tragen Sie Ihre Nummer ein");
  return false
 }
 
 var city = document.getElementById("orderReportcity-textBoxTextbox").value;
 if ((city==null)||(city=="")){
  alert("Bitte tragen Sie Ihren Ort ein");
  return false
 }
 
  var country = document.getElementById("orderReportcountry-textBoxTextbox").value;
 if ((country==null)||(country=="")){
  alert("Bitte tragen Sie Ihr Land ein");
  return false
 }
 

 /*var country = document.MainForm.orderReportcountryDropDown[document.MainForm.orderReportcountryDropDown.selectedIndex].value;
 if (country == "Country"){
  alert("Bitte Land auswählen");
  return false
 } */
  
 // document.MainForm.submit();
 return true
 }
