/* from new_header.php */
function fnChangeValue(){
	if(document.searchbyidfrm.searchbyid.value=="Property ID#"){
		document.searchbyidfrm.searchbyid.value="";
		document.searchbyidfrm.searchbyid.focus();
		return false
	}
}
function fnPutValue(){
	if(document.searchbyidfrm.searchbyid.value==""){
		document.searchbyidfrm.searchbyid.value="Property ID#";
		return false
	}

}
function fnCheckPropertyId(){
	if(document.searchbyidfrm.searchbyid.value==""){
	alert("please enter property id")
	document.searchbyidfrm.searchbyid.focus();
	return false
	}
	if(isNaN(document.searchbyidfrm.searchbyid.value)){
	alert("please enter in numeric")
	document.searchbyidfrm.searchbyid.focus();
	return false
	}
	return true
}

/* from new_siderbar.php */

function fnCheckemail(){
	if(document.frmNewslettermain.newsletteremail.value==""){
		alert("please enter email.")
		document.frmNewslettermain.newsletteremail.focus()
		return false
	}
	if(!fnEmail(document.frmNewslettermain.newsletteremail)){
		document.frmNewslettermain.newsletteremail.focus()
		return false
	}
	if(document.frmNewslettermain.zip.value==""){
		alert("please enter zip.")
		document.frmNewslettermain.zip.focus()
		return false
	}
	if(document.frmNewslettermain.xmiles.value==""){
		alert("please enter X Miles.")
		document.frmNewslettermain.xmiles.focus()
		return false
	}

return true
}
function fnEmail(txtEmail)
{

 if(txtEmail.value != "")
  {

   var intLen=txtEmail.value.length
   var blnFlag=0

   if(txtEmail.value.charAt(0)== "@" || txtEmail.value.charAt(0)==".")
    {
     alert("Invalid Email Address ")
     txtEmail.focus()
     return false
    }

   if(txtEmail.value.charAt(intLen-1)== "@" || txtEmail.value.charAt(intLen-1)== ".")
    {
     alert("Invalid Email Address ")
     txtEmail.focus()
     return false
    }

   for(var i=0; i<intLen; i++)
    {
     if(txtEmail.value.charAt(i)=="@")
      {
       blnFlag=blnFlag + 1
      }
    }

  if(blnFlag>=0 && blnFlag<1 || blnFlag >1)
    {
     alert("Invalid Email Address ")
     txtEmail.focus()
     return false
    }

  strSplit=(txtEmail.value).split("@")
		intSptLen=strSplit[1].length
		var intCnt=0
		for(var j=0;j<intSptLen;j++)
		{
			if (strSplit[1].charAt(j)==".")
			{
				intCnt=intCnt+1
			}
		}
		if (intCnt<=0)
		{
			alert("Invalid E-Mail Address")
			txtEmail.focus()
			return false
		}
return true;

  }

}

function fnUnsubscibeemail(){
	if((!fnEmail(document.frmNewslettermain.newsletteremail))){
		fnCheckemail();

	}else{
		emailid=document.frmNewslettermain.newsletteremail.value;
		url="newslettermsg.php?unsemail="+emailid;
		window.open(url,'','width=340,height=400');
	}
	return
}

/* from login.php */

function fnValidate1(){

	if(document.frmforgotemail.txtEmail.value==""){
			alert("please enter email.")
			document.frmforgotemail.txtEmail.focus()
			return false
		}
		if(!fnEmail(document.frmforgotemail.txtEmail)){
			document.frmforgotemail.txtEmail.focus()
			return false
		}
	return true
}

function fnValidate(){
	if(document.frmMain.username.value==""){
		alert("please enter user name.")
		document.frmMain.username.focus()
		return false
	}
	if(document.frmMain.password.value==""){
		alert("please enter password.")
		document.frmMain.password.focus()
		return false
	}
	return true
}

/* from applyforloan.php */
function fnDetailsLoan(id,pid)
{
	//document.frmMain.loanid.value=id
	document.frmMain.action="applyforloan.php";
	document.frmMain.submit()
}

function fnValidateLoan(){

	if(document.frmMain.firstName.value==""){
		alert("please enter first name.")
		document.frmMain.firstName.focus()
		return false
	}
	if(document.frmMain.lastname.value==""){
		alert("please enter last name.")
		document.frmMain.lastname.focus()
		return false
	}

	if(document.frmMain.email.value==""){
		alert("please enter email.")
		document.frmMain.email.focus()
		return false
	}
	if(!fnEmail(document.frmMain.email)){
		document.frmMain.email.focus()
		return false
	}
	if(document.frmMain.hphone.value==""){
		alert("please enter phone.")
		document.frmMain.hphone.focus()
		return false
	}

}
