

function SearchTop(){

	document.frmIndex.submit();

}

// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
    var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
    var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
    // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
    for (var i = 1; i <= n; i++) {
        this[i] = 31
        if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
        if (i==2) {this[i] = 29}
   } 
   return this ;
}



function isDate(dtStr){
    var daysInMonth = DaysArray(12)
    var pos1=dtStr.indexOf(dtCh)
    var pos2=dtStr.indexOf(dtCh,pos1+1)
    var strDay=dtStr.substring(0,pos1)
    var strMonth=dtStr.substring(pos1+1,pos2)
    var strYear=dtStr.substring(pos2+1)
    strYr=strYear
    if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
    if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
    for (var i = 1; i <= 3; i++) {
        if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
    }
    month=parseInt(strMonth)
    day=parseInt(strDay)
    year=parseInt(strYr)
    if (pos1==-1 || pos2==-1){
        alert("Please enter the date format as : dd/mm/yyyy")
        return false;
    }
    if (strMonth.length<1 || month<1 || month>12){
        alert("Please enter a valid month")
        return false ;
    }
    if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
        alert("Please enter a valid day")
        return false ;
    }
    if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
        alert("Please enter a valid 4 digit year")
        return false ;
    }
    if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
        alert("Please enter a valid date")
        return false;
    }
return true  ;
}


function checkformContactDetails()
{
    if(document.frmContact.enquiry_name.value.search(/\S/)==-1){

		alert("Please enter your name.");

		document.frmContact.enquiry_name.focus();

		return false;

	}
        
    if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z]{2,5}$/).exec(document.frmContact.enquiry_emailaddress.value)==null){

		alert("Please enter a correctly formatted email address.");

		document.frmContact.enquiry_emailaddress.focus();

		return false;

	}
        
        if(document.frmContact.enquiry_type.value == 0){

		alert("Please enter the type of enquiry from the checkbox.");

		document.frmContact.enquiry_type.focus();

		return false;

	}
        
        if(document.frmContact.enquiry_text.value.search(/\S/)==-1){

		alert("Please enter your enquiry.");

		document.frmContact.enquiry_text.focus();

		return false;

	}
}


function checkFamilyformDetails(){

	if(document.frmSignup.username.value.search(/\S/)==-1){

		alert("Please enter a username.");

		document.frmSignup.userid.focus();

		return false;

	}
    
    if(document.frmSignup.password.value.search(/\S/)==-1){

        alert("Please enter a password.");

        document.frmSignup.password.focus();

        return false;

    }

    if(document.frmSignup.password_confirm.value.search(/\S/)==-1){

        alert("Please confirm your password.");

        document.frmSignup.password_confirm.focus();

        return false;

    }   
    
    if(document.frmSignup.password.value != document.frmSignup.password_confirm.value ){

        alert("The password confirmation does not match the original.");

        document.frmSignup.password_confirm.focus();

        return false;

    } 

    
    
    if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z]{2,5}$/).exec(document.frmSignup.email_address.value)==null){

        alert("Please enter a correctly formatted email address");

        document.frmSignup.email_address.focus();

        return false;

    }
    
    if(document.frmSignup.family_name.value.search(/\S/)==-1){

        alert("Please enter your families last name.");

        document.frmSignup.family_name.focus();

        return false;

    }


	if(document.frmSignup.address_1.value.search(/\S/)==-1){

		alert("Please enter your address in the first address field.");

		document.frmSignup.address_1.focus();

		return false;

	}
    
    if(document.frmSignup.city.value.search(/\S/)==-1){

        alert("Please enter a town/city.");

        document.frmSignup.city.focus();

        return false;

    }


	if(document.frmSignup.county_id.value==""){

		alert("Please select a county from the drop-down list.");

		document.frmSignup.county_id.focus();

		return false;

	}
    
    if(document.frmSignup.postcode.value.search(/\S/)==-1){

        alert("Please enter a postcode.");

        document.frmSignup.postcode.focus();

        return false;

    }
    
    if(document.frmSignup.phone.value.search(/\S/)==-1){

        alert("Please enter a valid phone number.");

        document.frmSignup.phone.focus();

        return false;

    }
    
    
    if(document.frmSignup.family_residence.value==""){

        alert("Please select a family residence type from the drop-down list.");

        document.frmSignup.family_residence..focus();

        return false;

    }
    
      if(document.frmSignup.smoking_household.value==""){

        alert("Please select whether you are a smoking household from the drop-down list.");

        document.frmSignup.family_residence..focus();

        return false;

    } 
}


function checkFamilyformDetailsEdit(){

     if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z]{2,5}$/).exec(document.frmSignup.email_address.value)==null){

        alert("Please enter a correctly formatted email address");

        document.frmSignup.email_address.focus();

        return false;

    }
    
    if(document.frmSignup.family_name.value.search(/\S/)==-1){

        alert("Please enter your families last name.");

        document.frmSignup.family_name.focus();

        return false;

    }
    
   


    if(document.frmSignup.address_1.value.search(/\S/)==-1){

        alert("Please enter your address in the first address field.");

        document.frmSignup.address_1.focus();

        return false;

    }
    
    if(document.frmSignup.city.value.search(/\S/)==-1){

        alert("Please enter a town/city.");

        document.frmSignup.city.focus();

        return false;

    }


    if(document.frmSignup.county_id.value==""){

        alert("Please select a county from the drop-down list.");

        document.frmSignup.county_id.focus();

        return false;

    }
    
    if(document.frmSignup.postcode.value.search(/\S/)==-1){

        alert("Please enter a postcode.");

        document.frmSignup.postcode.focus();

        return false;

    }
    
    if(document.frmSignup.phone.value.search(/\S/)==-1){

        alert("Please enter a valid phone number.");

        document.frmSignup.phone.focus();

        return false;

    }
    
  
    
    if(document.frmSignup.family_residence.value==""){

        alert("Please select a family residence type from the drop-down list.");

        document.frmSignup.family_residence..focus();

        return false;

    }
    
      if(document.frmSignup.smoking_household.value==""){

        alert("Please select whether you are a smoking household from the drop-down list.");

        document.frmSignup.family_residence..focus();

        return false;

    } 
}



function checkCarerformDetails(){

    if(document.frmSignup.userid.value.search(/\S/)==-1){

        alert("Please enter a username.");

        document.frmSignup.userid.focus();

        return false;

    }
    
    if(document.frmSignup.password.value.search(/\S/)==-1){

        alert("Please enter a password.");

        document.frmSignup.password.focus();

        return false;

    }

    if(document.frmSignup.password_confirm.value.search(/\S/)==-1){

        alert("Please confirm your password.");

        document.frmSignup.password_confirm.focus();

        return false;

    }   
    
    if(document.frmSignup.password.value != document.frmSignup.password_confirm.value ){

        alert("The password confirmation does not match the original.");

        document.frmSignup.password_confirm.focus();

        return false;

    } 

    if(document.frmSignup.family_name.value.search(/\S/)==-1){

        alert("Please enter your families last name.");

        document.frmSignup.family_name.focus();

        return false;

    }
    
    if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z]{2,5}$/).exec(document.frmSignup.email_add.value)==null){

        alert("Please enter a correctly formatted email address");

        document.frmSignup.email_add.focus();

        return false;

    }


    if(document.frmSignup.address_1.value.search(/\S/)==-1){

        alert("Please enter your address in the first address field.");

        document.frmSignup.address_1.focus();

        return false;

    }
    
    if(document.frmSignup.city.value.search(/\S/)==-1){

        alert("Please enter a town/city.");

        document.frmSignup.city.focus();

        return false;

    }


    if(document.frmSignup.county_id.value==""){

        alert("Please select a county from the drop-down list.");

        document.frmSignup.county_id.focus();

        return false;

    }
    
    if(document.frmSignup.postcode.value.search(/\S/)==-1){

        alert("Please enter a postcode.");

        document.frmSignup.postcode.focus();

        return false;

    }
    
    if(document.frmSignup.phone.value.search(/\S/)==-1){

        alert("Please enter a valid phone number.");

        document.frmSignup.phone.focus();

        return false;

    }
    
    if(document.frmSignup.fathers_dob.value !="")
    {
        if (isDate(document.frmSignup.fathers_dob.value)==false){
            document.frmSignup.fathers_dob.focus()
            return false
        }
    }
    
    if(document.frmSignup.mothers_dob.value !="")
    {
        if (isDate(document.frmSignup.mothers_dob.value)==false){
            document.frmSignup.mothers_dob.focus()
            return false
        }
    }
    
     if(document.frmSignup.child1_dob.value !="")
    {
        if (isDate(document.frmSignup.child1_dob.value)==false){
            document.frmSignup.child1_dob.focus()
            return false
        }
    }
    
     if(document.frmSignup.child2_dob.value !="")
    {
        if (isDate(document.frmSignup.child2_dob.value)==false){
            document.frmSignup.child2_dob.focus()
            return false
        }
    }
    
     if(document.frmSignup.child3_dob.value !="")
    {
        if (isDate(document.frmSignup.child3_dob.value)==false){
            document.frmSignup.child3_dob.focus()
            return false
        }
    }
    
     if(document.frmSignup.child4_dob.value !="")
    {
        if (isDate(document.frmSignup.child4_dob.value)==false){
            document.frmSignup.child4_dob.focus()
            return false
        }
    }
    
     if(document.frmSignup.child5_dob.value !="")
    {
        if (isDate(document.frmSignup.child5_dob.value)==false){
            document.frmSignup.child5_dob.focus()
            return false
        }
    }
    
     if(document.frmSignup.child6_dob.value !="")
    {
        if (isDate(document.frmSignup.child6_dob.value)==false){
            document.frmSignup.child6_dob.focus()
            return false
        }
    }
    
    if(document.frmSignup.family_residence.value==""){

        alert("Please select a family residence type from the drop-down list.");

        document.frmSignup.family_residence..focus();

        return false;

    }
    
      if(document.frmSignup.smoking_household.value==""){

        alert("Please select whether you are a smoking household from the drop-down list.");

        document.frmSignup.family_residence..focus();

        return false;

    } 
}


 

function Login(){

	if(document.frmSignup.userid.value==''){

		alert("Please enter a proper userid to login");

		document.frmSignup.userid.focus();

		return false;

	}

	if(	document.frmSignup.password.value.search(/\S/)==-1) {

		alert('Please enter password');

		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 SearchInclude(){

	document.frmSearch.submit();

}



function SearchTop(){

	document.frmTop.submit();

}



function rowsshown(){

	document.frmPage.submit();

}



function chFrmS(){

	if(	document.frmSearchList.savesearch_name.value.search(/\S/)==-1) {

		alert('Please provide Save Search Name');

		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) {

		alert('Please provide List name');

		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){



    if(document.frmAddEdit.country_id.value==""){

		alert("Please select country.");

		document.frmAddEdit.country_id.focus();

		return false;

	}		

	if(document.frmAddEdit.country_id.value=="226" && document.form.state_id.value==""){

		alert("Please select state.");

		document.frmAddEdit.state_id.focus();

		return false;

	}

    if(document.frmAddEdit.city.value==""){

		alert("Please enter a city.");

		document.frmAddEdit.city.focus();

		return false;

	}

	if(document.frmAddEdit.zip.value==""){

		alert("Please enter a zip.");

		document.frmAddEdit.zip.focus();

		return false;

	}

	return true;

}

function selectcountry(){

	document.frmAddEdit.action="property_add.php";

	document.frmAddEdit.submit();

}



function change_image(num,pic,id,path){

	document.frmdetail.slide.src=path+pic;

}

function callBrochure(id){

	window.open('brochure.php?property_id='+id,'Brochure','toolbar=0,scrollbars=1,location=no,statusbar=0,menubar=0,resizable=1,height=630,width=565,top=10,left=10');

}

function callTermsandConditions(location){

	window.open(location,'toolbar=0,scrollbars=1,location=no,statusbar=0,menubar=0,resizable=1,height=630,width=565,top=10,left=10');

}

function openSaveListing(id){

	window.open('openSaveListing.php?property_id='+id,'SaveListing','toolbar=0,scrollbars=1,location=no,statusbar=0,menubar=0,resizable=1,height=300,width=565,top=10,left=10');

}

function openSearchListing(id){

	window.open('openSearchListing.php?property_id='+id,'SaveSearchListing','toolbar=0,scrollbars=1,location=no,statusbar=0,menubar=0,resizable=1,height=300,width=565,top=10,left=10');

}

function sendMail(id){

	window.open('sendMail.php?property_id='+id,'Sendmail','toolbar=0,scrollbars=1,location=no,statusbar=0,menubar=0,resizable=1,height=420,width=565,top=10,left=10');

}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




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=no,resizable=no";

	webwindow=window.open(obj, 'webwindow1', features);

	if (parseInt(navigator.appVersion) >= 4) { 

		webwindow.window.focus(); 

	}

}


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;

	}

}



//counts number of words in a block of text

function cnt(w,x,limit)

{

        var y=w.value;

        var r = 0;

        a=y.replace('\n',' ');

        a=a.split(' ');

        for (z=0; z<a.length; z++)

        {

                if (a[z].length > 0)

                {

                        r++;

                }

        }

        x.value=limit - r;

        

        if(x.value < 1)

        {

                w.value = w.value.substring(0,w.value.length-1);

                return false;

        }

        return true;



}

var aDetail = new Array();



function categSelected(theSel,region_id,search){

  theForm = theSel.form;

  opt = theForm.region_id.options;

  opt.length = 0;

  

  

  if (search == 1)

  {

    var defaultstring = "--Any Region--";

  }

  else

  {

    var defaultstring = "--Select Region--";

  }

        

        

  if(theSel.value=="") {

     

     opt[0] = new Option(defaultstring, "");

     return;

  }

  opt[0] = new Option(defaultstring, "");
                     
  for(i=0;i<aDetail.length;i++){

    if(aDetail[i][2]==theSel.value){

      subCategoryValue = aDetail[i][1];

      for(j=0;j<opt.length;j++)

      {

        if(opt[j].value==subCategoryValue)

        {

          subCategoryValue="";

        }

      }

      if(subCategoryValue>"")

      {

        if (region_id == aDetail[i][0])

        {

                    opt[opt.length] = new Option(subCategoryValue, aDetail[i][0],true); 

        }

        else

        {

        opt[opt.length] = new Option(subCategoryValue, aDetail[i][0]);

        }
      }
    }
  }
}

 var tDetail = new Array();   
               
function RegionSelected(theSel,town_id,search){

  theForm = theSel.form;

  opt = theForm.town_id.options;

  opt.length = 0;

  
  
  

  if (search == 1)

  {

    var defaultstring = "--Any Town/City--";

  }

  else

  {

    var defaultstring = "--Select Town/City--";

  }



  if(theSel.value=="") {

     opt[0] = new Option(defaultstring, "");

     return;

  }

  opt[0] = new Option(defaultstring, "");

  for(i=0;i<tDetail.length;i++){

    if(tDetail[i][2]==theForm.region_id.value){

      subCategoryValue = tDetail[i][1];

      for(j=0;j<opt.length;j++)

      {

        if(opt[j].value==subCategoryValue)

        {

          subCategoryValue="";

        }

      }

      if(subCategoryValue>"")

      {

        if (town_id == tDetail[i][0])

        {

                    opt[opt.length] = new Option(subCategoryValue, tDetail[i][0],true); 

        }

        else

        {

        opt[opt.length] = new Option(subCategoryValue, tDetail[i][0]);

        }
      }
    }
  }
}


function  changeColor(id,c) {

        var colour = 'ffffff';

        if (c== '1')

        {

               colour = '00cc66'; 

        }

        else

         if (c== '2')

        {

                colour = 'dd0000'; 

        }

        else

        if (c== '3')

        {

               colour = 'ffff33';  

        }
        
         else

        if (c== '4')

        {

               colour = 'ff9933';  

        }
	document.getElementById(id).style.backgroundColor = "#" + colour;
}

function submitForm(formId)
{
        var formObj = document.getElementById(formId);
        formObj.submit();
}

function checkpasswordform()
{
        if(document.frmChangePassword.oldpassword.value.search(/\S/)==-1){

		alert("Please enter your old password.");

		document.frmChangePassword.oldpassword.focus();

		return false;

	}
        
        if(document.frmChangePassword.newpassword.value.search(/\S/)==-1){

		alert("Please enter your new password.");

		document.frmChangePassword.newpassword.focus();

		return false;

	}
        
        if(document.frmChangePassword.newpassword_confirm.value.search(/\S/)==-1){

		alert("Please confirm your new password.");

		document.frmChangePassword.newpassword_confirm.focus();

		return false;

	}

	
	if(document.frmChangePassword.newpassword.value != document.frmChangePassword.newpassword_confirm.value ){

		alert("Password confirmation doesn't match password specified above.");

		document.frmChangePassword.newpassword_confirm.focus();

		return false;

	}
}


function CountWords (this_field)
{
    var char_count = this_field.value.length;
    var fullStr = this_field.value + " ";
    var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
    var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
    var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
    var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
    var splitString = cleanedStr.split(" ");
    var word_count = splitString.length -1;
    if (fullStr.length <2)
    {
        word_count = 0;
    }
    
    return word_count;
}


function OnSubmitPropertyDetailForm()
{
  var count  = CountWords(document.frmPropertyDetails.short_description);
  if (count > 50)
  {
   alert("The short description text exceeds 50 words long.");
   document.frmPropertyDetails.short_description.focus();
   document.frmPropertyDetails.sd.value = 50-count;
   return false;
  }
  
  var dcount  = CountWords(document.frmPropertyDetails.description);
  if (dcount > 500)
  {
   alert("The main description text exceeds 500 words long.");
   document.frmPropertyDetails.description.focus();
   document.frmPropertyDetails.d.value = 500-dcount;
   return false;
  }
  
  if(document.pressed == 'cancel')
  {
   document.frmPropertyDetails.action ="property_centre.php";
  }
  else
  if(document.pressed == 'Update')
  {
    document.frmPropertyDetails.action ="property_details.php";
  }
  return true;
}

function OnSubmitPropertyLocationForm()
{
  var count  = CountWords(document.frmPropertyLocation.directions);
  if (count > 200)
  {
   alert("The directions text exceeds 200 words long.");
   document.frmPropertyLocation.about_directions.focus();
   document.frmPropertyLocation.di.value = 200-count;
   return false;
  }
  
  var dcount  = CountWords(document.frmPropertyLocation.about_area);
  if (dcount > 500)
  {
   alert("The about area text/location exceeds 500 words long.");
   document.frmPropertyLocation.about_area.focus();
   document.frmPropertyLocation.aa.value = 500-dcount;
   return false;
  }
  
  if(document.pressed == 'cancel')
  {
   document.frmPropertyLocation.action ="property_centre.php";
  }
  else
  if(document.pressed == 'Update')
  {
    document.frmPropertyLocation.action ="property_location.php";
  }
  return true;
}

function OnSubmitPropertyMapForm()
{
  if(document.pressed == 'cancel')
  {
   document.frmPropertyMap.action ="property_centre.php";
  }
  else
  if(document.pressed == 'save')
  {
    document.frmPropertyMap.action ="property_map.php?task=save";
  }
  else
  if(document.pressed == 'search')
  {
    document.frmPropertyMap.action ="property_map.php?task=search";
  }
  return true;
}

function OnSubmitAdminPropertyMapForm()
{
  if(document.pressed == 'cancel')
  {
   document.frmPropertyMap.action ="adminpropertycentre.php";
  }
  else
  if(document.pressed == 'save')
  {
    document.frmPropertyMap.action ="adminproperty_map.php?task=save";
  }
  else
  if(document.pressed == 'search')
  {
    document.frmPropertyMap.action ="adminproperty_map.php?task=search";
  }
  return true;
}


function OnSubmitPropertyTariffForm()
{
  if(document.pressed == 'cancel')
  {
   document.frmPropertyTariff.action ="property_centre.php";
  }
  else
  if(document.pressed == 'Update')
  {
    document.frmPropertyTariff.action ="property_tariff.php";
  }
  return true;
}

function OnSubmitCarerPhotosForm()
{
  if(document.pressed == 'cancel')
  {
   document.frmCarerPhotos.action ="property_centre.php";
  }
  else
  if(document.pressed == 'Update')
  {
    document.frmCarerPhotos.action ="property_tariff.php";
  }
  return true;
}

function OnSubmitPropertyAvailabilityForm()
{
  if(document.pressed == 'cancel')
  {
   document.frmPropertyAvailability.action ="property_centre.php";
  }
  else
  if(document.pressed == 'Update')
  {
    document.frmPropertyAvailability.action ="property_tariff.php";
  }
  return true;
}



function OnSubmitAdminPropertyDetailForm()
{
  
  var count  = CountWords(document.frmPropertyDetails.short_description);
  if (count > 50)
  {
   alert("The short description text exceeds 50 words long.");
   document.frmPropertyDetails.short_description.focus();
   document.frmPropertyDetails.sd.value = 50-count;
   return false;
  }
  
  var dcount  = CountWords(document.frmPropertyDetails.description);
  if (dcount > 500)
  {
   alert("The main description text exceeds 500 words long.");
   document.frmPropertyDetails.description.focus();
   document.frmPropertyDetails.d.value = 500-dcount;
   return false;
  }
  
  if(document.pressed == 'cancel')
  {
   document.frmPropertyDetails.action ="adminpropertycentre.php";
  }
  else
  if(document.pressed == 'Update')
  {
    document.frmPropertyDetails.action ="adminproperty_details.php";
  }
  return true;
}

function OnSubmitAdminPropertyLocationForm()
{
  var count  = CountWords(document.frmPropertyLocation.directions);
  if (count > 200)
  {
   alert("The directions text exceeds 200 words long.");
   document.frmPropertyLocation.about_directions.focus();
   document.frmPropertyLocation.di.value = 200-count;
   return false;
  }
  
  var dcount  = CountWords(document.frmPropertyLocation.about_area);
  if (dcount > 500)
  {
   alert("The about area text/location exceeds 500 words long.");
   document.frmPropertyLocation.about_area.focus();
   document.frmPropertyLocation.aa.value = 500-dcount;
   return false;
  }
  
  if(document.pressed == 'cancel')
  {
   document.frmPropertyLocation.action ="adminpropertycentre.php";
  }
  else
  if(document.pressed == 'Update')
  {
    document.frmPropertyLocation.action ="adminproperty_location.php";
  }
  return true;
}

function OnSubmitAdminPropertyTariffForm()
{
  if(document.pressed == 'cancel')
  {
   document.frmPropertyTariff.action ="adminpropertycentre.php";
  }
  else
  if(document.pressed == 'Update')
  {
    document.frmPropertyTariff.action ="adminproperty_tariff.php";
  }
  return true;
}

function OnSubmitAdminCarerPhotosForm()
{            
  if(document.pressed == 'cancel')
  {             
   document.frmCarerPhotos.action ="admin_carer_home.php";
  }
  else
  if(document.pressed == 'Update')
  {
    document.frmCarerPhotos.action ="adminproperty_tariff.php";
  }
  return true;
}

function OnSubmitCarerPhotosForm()
{            
  if(document.pressed == 'cancel')
  {             
   document.frmCarerPhotos.action ="carer_home.php";
  }
  else
  if(document.pressed == 'Update')
  {
    document.frmCarerPhotos.action ="adminproperty_tariff.php";
  }
  return true;
}

function OnSubmitAdminPropertyAvailabilityForm()
{
  if(document.pressed == 'cancel')
  {
   document.frmPropertyAvailability.action ="adminpropertycentre.php";
  }
  else
  if(document.pressed == 'Update')
  {
    document.frmPropertyAvailability.action ="adminproperty_tariff.php";
  }
  return true;
}


