
function SearchTop(){
	document.frmIndex.submit();
}

function checkformF(){
	if(document.frmSignup.userid.value.search(/\S/)==-1){
		var et = document.frmSignup.userid.getAttribute('errortext');
        alert(et);
		document.frmSignup.userid.focus();
		return false;
	}
    if(document.frmSignup.fname.value.search(/\S/)==-1){
		var et = document.frmSignup.fname.getAttribute('errortext');
        alert(et);
		document.frmSignup.fname.focus();
		return false;
	}
	if(document.frmSignup.lname.value.search(/\S/)==-1){
		var et = document.frmSignup.lname.getAttribute('errortext');
        alert(et);
		document.frmSignup.lname.focus();
		return false;
	}
	
	if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z]{2,5}$/).exec(document.frmSignup.email_add.value)==null){
		var et = document.frmSignup.email_add.getAttribute('errortext');
        alert(et);
        document.frmSignup.email_add.focus();
		return false;
	}
	if(document.frmSignup.password.value.search(/\S/)==-1){
		var et = document.frmSignup.password.getAttribute('errortext');
        alert(et);
		document.frmSignup.password.focus();
		return false;
	}
	if(document.frmSignup.password_confirm.value.search(/\S/)==-1){
		var et = document.frmSignup.password_confirm.getAttribute('errortext');
        alert(et);
		document.frmSignup.password_confirm.focus();
		return false;
	}	
	if(document.frmSignup.password.value != document.frmSignup.password_confirm.value ){
		var et = document.frmSignup.password.getAttribute('errortext');
        alert(et);
		document.frmSignup.password_confirm.focus();
		return false;
	}
	if(document.frmSignup.cgender[0].checked){
		document.frmSignup.cgender.value="M";
	}
	else if(document.frmSignup.cgender[1].checked){
		document.frmSignup.cgender.value="F";
	}	
	if(document.frmSignup.country_id.value==""){
		var et = document.frmSignup.country_id.getAttribute('errortext');
        alert(et);
		document.frmSignup.country_id.focus();
		return false;
	}
	if((document.frmSignup.birth_day.value=="") || (document.frmSignup.birth_month.value=="") || (document.frmSignup.birth_year.value=="")){
        var et = document.frmSignup.birth_year.getAttribute('errortext');
        alert(et);
		document.frmSignup.birth_year.focus();
		return false;
	}
	if(document.frmSignup.country_id.value=="226" && document.frmSignup.state_id.value=="0"){
	    var et = document.frmSignup.state_id.getAttribute('errortext');
        alert(et);
		document.frmSignup.state_id.focus();
		return false;
	}
    if(document.frmSignup.move_month.value==""){
        if(document.frmSignup.move.checked==""){
    		var et = document.frmSignup.move_month.getAttribute('errortext');
            alert(et);
    		document.frmSignup.move.focus();
    		return false;
    	}

    }
}

function checkformFEdit(){
		if(document.frmSignup.userid.value.search(/\S/)==-1){
		var et = document.frmSignup.userid.getAttribute('errortext');
        alert(et);
		document.frmSignup.userid.focus();
		return false;
	}
    if(document.frmSignup.fname.value.search(/\S/)==-1){
		var et = document.frmSignup.fname.getAttribute('errortext');
        alert(et);
		document.frmSignup.fname.focus();
		return false;
	}
	if(document.frmSignup.lname.value.search(/\S/)==-1){
		var et = document.frmSignup.lname.getAttribute('errortext');
        alert(et);
		document.frmSignup.lname.focus();
		return false;
	}

	if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z]{2,5}$/).exec(document.frmSignup.email_add.value)==null){
		var et = document.frmSignup.email_add.getAttribute('errortext');
        alert(et);
        document.frmSignup.email_add.focus();
		return false;
	}

	if(document.frmSignup.cgender[0].checked){
		document.frmSignup.cgender.value="M";
	}
	else if(document.frmSignup.cgender[1].checked){
		document.frmSignup.cgender.value="F";
	}	
	if(document.frmSignup.country_id.value==""){
		var et = document.frmSignup.country_id.getAttribute('errortext');
        alert(et);
		document.frmSignup.country_id.focus();
		return false;
	}
	if((document.frmSignup.birth_day.value=="") || (document.frmSignup.birth_month.value=="") || (document.frmSignup.birth_year.value=="")){
        var et = document.frmSignup.birth_year.getAttribute('errortext');
        alert(et);
		document.frmSignup.birth_year.focus();
		return false;
	}
	if(document.frmSignup.country_id.value=="226" && document.frmSignup.state_id.value=="0"){
	    var et = document.frmSignup.state_id.getAttribute('errortext');
        alert(et);
		document.frmSignup.state_id.focus();
		return false;
	}
    if(document.frmSignup.move_month.value==""){
        if(document.frmSignup.move.checked==""){
    		var et = document.frmSignup.move_month.getAttribute('errortext');
            alert(et);
    		document.frmSignup.move.focus();
    		return false;
    	}

    }
}

function checkform(){
	if(document.frmSignup.username.value.search(/\S/)==-1){
		var et = document.frmSignup.username.getAttribute('errortext');
                alert(et);
		document.frmSignup.username.focus();
		return false;
	}
    if(document.frmSignup.fname.value.search(/\S/)==-1){
		var et = document.frmSignup.fname.getAttribute('errortext');
                alert(et);
		document.frmSignup.fname.focus();
		return false;
	}
	if(document.frmSignup.lname.value.search(/\S/)==-1){
		var et = document.frmSignup.lname.getAttribute('errortext');
                alert(et);
		document.frmSignup.lname.focus();
		return false;
	}

	if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z]{2,5}$/).exec(document.frmSignup.email_add.value)==null){
		var et = document.frmSignup.email_add.getAttribute('errortext');
                alert(et);
		document.frmSignup.email_add.focus();
		return false;
	}
	if(document.frmSignup.pass.value.search(/\S/)==-1){
		var et = document.frmSignup.pass.getAttribute('errortext');
                alert(et);
		document.frmSignup.pass.focus();
		return false;
	}
	if(document.frmSignup.password_confirm.value.search(/\S/)==-1){
		var et = document.frmSignup.password_confirm.getAttribute('errortext');
                alert(et);
		document.frmSignup.password_confirm.focus();
		return false;
	}	
	if(document.frmSignup.pass.value != document.frmSignup.password_confirm.value ){
		var et = document.frmSignup.password_confirm.getAttribute('errortext');
                alert(et);
		document.frmSignup.password_confirm.focus();
		return false;
	}
	
	if(document.frmSignup.country_id.value==""){
		var et = document.frmSignup.country_id.getAttribute('errortext');
                alert(et);
		document.frmSignup.country_id.focus();
		return false;
	}
	if(document.frmSignup.country_id.value=="226" && document.frmSignup.state_id.value=="0"){
		var et = document.frmSignup.state_id.getAttribute('errortext');
                alert(et);
		document.frmSignup.state_id.focus();
		return false;
	}

}

function checkformEdit(){
	if(document.frmSignup.username.value.search(/\S/)==-1){
		var et = document.frmSignup.username.getAttribute('errortext');
                alert(et);
		document.frmSignup.username.focus();
		return false;
	}
    if(document.frmSignup.fname.value.search(/\S/)==-1){
		var et = document.frmSignup.fname.getAttribute('errortext');
                alert(et);
		document.frmSignup.fname.focus();
		return false;
	}
	if(document.frmSignup.lname.value.search(/\S/)==-1){
		var et = document.frmSignup.lname.getAttribute('errortext');
                alert(et);
		document.frmSignup.lname.focus();
		return false;
	}

	if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z]{2,5}$/).exec(document.frmSignup.email_add.value)==null){
		var et = document.frmSignup.username.getAttribute('errortext');
                alert(et);
		document.frmSignup.email_add.focus();
		return false;
	}
	if(document.frmSignup.country_id.value==""){
		var et = document.frmSignup.country_id.getAttribute('errortext');
                alert(et);
		document.frmSignup.country_id.focus();
		return false;
	}
	if(document.frmSignup.country_id.value=="226" && document.frmSignup.state_id.value==""){
		var et = document.frmSignup.state_id.getAttribute('errortext');
                alert(et);
		document.frmSignup.state_id.focus();
		return false;
	}

}

function Login(){
	if(document.frmSignup.username.value==''){
		var et = document.frmSignup.username.getAttribute('errortext');
                alert(et);
		document.frmSignup.username.focus();
		return false;
	}
	if(	document.frmSignup.password.value.search(/\S/)==-1) {
		var et = document.frmSignup.password.getAttribute('errortext');
                alert(et);
		document.frmSignup.password.focus();
		return false;
	}
	document.frmSignup.hidaction.value="login";
	document.frmSignup.submit();
}

function Search(){
	document.frmEditSearch.hidaction.value="editSearch";
	document.frmEditSearch.submit();
}
function selectcountryS(){
	document.frmEditSearch.action="edit_search.php";
	document.frmEditSearch.submit();
}

function SetUsrOrder(){
	document.usersearch.submit();
}

function SearchInclude(){
	document.frmSearch.submit();
}

function SearchTop(){
	document.frmTop.submit();
}

function rowsshown(){
	document.frmPage.hidaction.value="jump";
	document.frmPage.submit();
}

function chFrmS(){
	if(	document.frmSearchList.savesearch_name.value.search(/\S/)==-1) {
		var et = document.frmSearchList.savesearch_name.getAttribute('errortext');
                alert(et);
		document.frmSearchList.savesearch_name.focus();
		return false;
	}
    opener.document.frmPage.savesearch_name.value = document.frmSearchList.savesearch_name.value;
	opener.document.frmPage.hidaction.value = "SaveSearchListing";
	opener.document.frmPage.submit();
    window.close();
}  

function chFrm(){
	if(	document.frmListing.list_name.value.search(/\S/)==-1) {
		var et = document.frmListing.list_name.getAttribute('errortext');
                alert(et);

		document.frmListing.list_name.focus();
		return false;
	}
    opener.document.frmdetail.list_name.value = document.frmListing.list_name.value;
 opener.document.frmdetail.hidaction.value = "SaveListing";
	opener.document.frmdetail.submit();
    window.close();
}  

function checkformP(Frm){
    f = Frm;

   for(var i=0;i<f.elements.length;i++){
       if (f.elements[i].type!="text"){
           continue;
       }
       t = f.elements[i].value;

       if((t == null || t.length == 0) && (f.elements[i].name == "price") && (f.elements[i].name == "description")){
           var et = f.elements[i].getAttribute("errortext");
           alert(et);
           f.elements[i].focus();
           return false;
       }
   }

    if(document.frmAddEdit.country_id.value==""){
		var et = f.style.getAttribute("errortext");
           alert(et);
		f.country_id.focus();
		return false;
	}		
	if(document.frmAddEdit.state_id.value==""){
		var et = f.style.getAttribute("errortext");
           alert(et);
		f.state_id.focus();
		return false;
	}

	var stylecheck = f.style.value;
    if (stylecheck == 0){
      var et = f.style.getAttribute("errortext");
           alert(et);
           f.style.focus();
           return false;
   }
    var forcheck = f.property_for.value;
   if (forcheck == 0){
      var et = f.property_for.getAttribute("errortext");
           alert(et);
           f.property_for.focus();
           return false;
   }
	return true;
}
function selectcountry(){
	document.frmAddEdit.action="property_add.php";
	document.frmAddEdit.submit();
}

function change_image(link,num,pic,wpic,hpic,path){
	aSlide = document.getElementById( 'slide' );
	aSlide.href = link;
	aChild = aSlide.getElementsByTagName( 'img' );
	aChild[0].src = path + pic;
    aChild[0].width=wpic;
    aChild[0].height=hpic;
    return false;
}
function callBrochure(id,url){
	window.open(url+'/brochure.php?pid='+id,'Brochure','toolbar=0,scrollbars=1,location=no,statusbar=0,menubar=0,resizable=1,height=630,width=600,top=10,left=10');
}
function openSaveListing(id,url){
	window.open(url+'/openSaveListing.php?property_id='+id,'SaveListing','toolbar=0,scrollbars=1,location=no,statusbar=0,menubar=0,resizable=1,height=300,width=660,top=10,left=10');
}
function openSearchListing(url){
	window.open(url+'/openSearchListing.php','SaveSearchListing','toolbar=0,scrollbars=1,location=no,statusbar=0,menubar=0,resizable=1,height=300,width=660,top=10,left=10');
}
function sendMail(id,url){
	window.open(url+'/sendMail.php?pid='+id,'Sendmail','toolbar=0,scrollbars=1,location=no,statusbar=0,menubar=0,resizable=1,height=420,width=600,top=10,left=10');
}
function GoogleMap(id,url){
	window.open(url+'/googlemap.php?pid='+id,'GoogleMap','toolbar=0,scrollbars=1,location=no,statusbar=0,menubar=0,resizable=1,height=630,width=600,top=10,left=10');
}
function MortgageCalc(id,url){
	window.open(url+'/mortgagecalc.php?pid='+id,'Mortgage Calculator','toolbar=0,scrollbars=1,location=no,statusbar=0,menubar=0,resizable=1,height=400,width=600,top=10,left=10');
}
function send(){
	if(	document.frmContact.fname.value.search(/\S/)==-1) {
		var et = document.frmContact.fname.getAttribute('errortext');
                alert(et);
		document.frmContact.fname.focus();
		return false;
	}
	if(	document.frmContact.lname.value.search(/\S/)==-1) {
		var et = document.frmContact.lname.getAttribute('errortext');
                alert(et);
		document.frmContact.lname.focus();
		return false;
	}
	if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z]{2,5}$/).exec(document.frmContact.email.value)==null){
		var et = document.frmContact.email.getAttribute('errortext');
                alert(et);
		document.frmContact.email.focus();
		return false;
	}
	document.frmContact.pageaction.value="submitform";
	document.frmContact.submit();	
}

function checkformFriend(){
	if(	document.frmMail.your_name.value.search(/\S/)==-1) {
		var et = document.frmMail.your_name.getAttribute('errortext');
                alert(et);
		document.frmMail.your_name.focus();
		return false;
	}
	if(	document.frmMail.friend_name.value.search(/\S/)==-1) {
		var et = document.frmMail.friend_name.getAttribute('errortext');
                alert(et);
		document.frmMail.friend_name.focus();
		return false;
	}
	if(	document.frmMail.subject.value.search(/\S/)==-1) {
		var et = document.frmMail.subject.getAttribute('errortext');
                alert(et);
		document.frmMail.subject.focus();
		return false;
	}
	if(	document.frmMail.message.value.search(/\S/)==-1) {
		var et = document.frmMail.message.getAttribute('errortext');
                alert(et);
		document.frmMail.message.focus();
		return false;
	}
	if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z]{2,5}$/).exec(document.frmMail.your_email.value)==null){
		var et = document.frmMail.your_email.getAttribute('errortext');
                alert(et);
		document.frmMail.your_email.focus();
		return false;
	}
	if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z]{2,5}$/).exec(document.frmMail.friend_email.value)==null){
		var et = document.frmMail.friend_email.getAttribute('errortext');
                alert(et);
		document.frmMail.friend_email.focus();
		return false;
	}

	document.frmMail.submit();
}
function openWindow(obj,wd,ht){

	features = "width="+wd+",height="+ht;      
	features += ",left=10,top=10,screenX=0,screenY=0,location=no,toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=yes";
	webwindow=window.open(obj, 'webwindow1', features);
	if (parseInt(navigator.appVersion) >= 4) { 
		webwindow.window.focus(); 
	}
}

function notify() {
	pmbox=confirm("Warning: Are you sure you really want to delete this item?");
	if (pmbox==true) { // Output when OK is clicked
		return;
	} else {
	// Output when Cancel is clicked
	return false;
	}
}

function uncheckSingle(formName,field) {
	var ChckBxs = formName.elements[field];
	if(ChckBxs.length!=-1) {
		for (i = 0; i < ChckBxs.length; i++){
			if(ChckBxs[i].value=="99")
				ChckBxs[i].checked = false ;
		}
		formName.elements[field].checked = false;
	}
}

function valid_cc(form) {
   f = form;
   var x_country_tag = form.country_id.value;
   for(var i=0;i<f.elements.length;i++){
       if (f.elements[i].type!="text" && f.elements[i].type!="password"){
           continue;
       }
       t = f.elements[i].value;

       if(t == null || t.length == 0 && f.elements[i].name != "x_company" && f.elements[i].name != "Street2" && f.elements[i].name != "ccde"){
           var et = f.elements[i].getAttribute("errortext");
           alert(et);
           f.elements[i].focus();
           return false;
       }
   }
   	if (x_country_tag == 0)
    	{
       var et = x_country_tag.getAttribute("errortext");
       form.country.focus()
    	 return false;
    	}

return true;
}

function Morgcal() {
        form = document.myform
        LoanAmount= form.LoanAmount.value 
        DownPayment= "0" 
        AnnualInterestRate = form.InterestRate.value/100 
        Years= form.NumberOfYears.value 
        MonthRate=AnnualInterestRate/12
        NumPayments=Years*12 
        Prin=LoanAmount-DownPayment 
        MonthPayment=Math.floor((Prin*MonthRate)/(1-Math.pow((1+MonthRate),(-1*NumPayments)))*100)/100
        form.NumberOfPayments.value=NumPayments
        form.MonthlyPayment.value=MonthPayment
}
