// JavaScript Document
function CopyRight(){
	var mydate=new Date()
	var year=mydate.getYear()
	if (year < 2000) year = 1900 + year;
    var cRight = "Copyright " + year + " - Tarmina Luxury Homes. All Rights Reserved."
	cRight = cRight + "&nbsp;|&nbsp;<a href='http://www.virtualvistabiz.com' target='_blank'>Created by Virtual Vista Biz Real Estate Marketing</a></p>"
	return(cRight)
}

function checkform_1(form)
{
	var msg=new String()	
  	msg = ""
  	if (form.INPUT_01.value == "") {
		msg = msg +  "\n Name must be filled";
    	
	}
	if (form.INPUT_02.value == "") {
		msg = msg + "\n Email must be filled";
    	
	}
	if (msg != "") {		
    	alert( msg );
		form.INPUT_01.focus();
    	return false ;
	}	
  
  return true ;
}

function verifyContactusRequired(frm,req) {  	
  
  //var reqFlds = parseOptions(document.contactusform["required"].value);
  var reqFlds = parseOptions(frm[req].value);
  //var reqFlds = parseOptions(req)
  for (var i in reqFlds) {	   
	   if (frm[reqFlds[i]].value == "") {
		frm[reqFlds[i]].focus();
		alert(reqFlds[i] + " is required.");
		return false;
  		}
		if (reqFlds[i] == "email") {
			//at this point we passed the empty check, now
			//we check if the email is valid
			if (echeck(frm[reqFlds[i]].value)==false){
				frm[reqFlds[i]].value="";
				frm[reqFlds[i]].focus();
				//alert("email is not in a valid format.");
				return false;
			  }
  		}
//		if (document.contactusform[reqFlds[i]].value == "") {
//		document.contactusform[reqFlds[i]].focus();
//		alert(reqFlds[i] + " is required.");
//		return false;
//  		}
   
 	}
	//now we check if email is valid
	 // if (echeck(document.contactusform["email"].value)==false){
//		frm.email.value="";
//		frm.email.focus();
//		//alert("email is not in a valid format.");
//		return false;
//	  }
	
  
 // if (document.orderform["req_name"].value == "") {
//    document.orderform["req_name"].focus();
//    alert("The Requestor's Name field is required.");
//    return false;
//  }
//  if (document.orderform["req_company"].value == "") {
//    document.orderform["req_company"].focus();
//    alert("The Requestor's Company or Agency field is required.");
//    return false;
//  }
//  if (document.orderform["req_city"].value == "") {
//    document.orderform["req_city"].focus();
//    alert("The Requestor's City field is required.");
//    return false;
//  }
//  if (document.orderform["req_state"].value == "") {
//    document.orderform["req_state"].focus();
//    alert("The Requestor's State field is required.");
//    return false;
//  }
//  if (document.orderform["req_zip"].value == "") {
//    document.orderform["req_zip"].focus();
//    alert("The Requestor's Zip Code field is required.");
//    return false;
//  }
//  if (document.orderform["req_email"].value == "") {
//    document.orderform["req_email"].focus();
//    alert("The Requestor's Email field is required.");
//    return false;	 
//  } 
//  if (echeck(document.orderform["req_email"].value)==false){
//		document.orderform["req_email"].value="";
//		document.orderform["req_email"].focus();
//		return false;
//	}
//  
//  if (document.orderform["req_phone"].value == "") {
//    document.orderform["req_phone"].focus();
//    alert("The Requestor's Phone field is required.");
//    return false;
//  }


//return true;

}
function isValidEmail(str) {

   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 


}

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
		 }

 		 return true					
	}

function parseOptions(inputToParse){

 //make an array from the comma delimited options string
 	var parsedInput = inputToParse.split(",");
 	return parsedInput; 
}


