/*************** COMMON FUNCTION ***************/

function __mypopup(url){
   //mywindow = window.open(url,"mywindow","location=1,status=1,scrollbars=1,width=900,height=500");
   
   window.open (url,"mywindow","location=1,status=1,scrollbars=1,width=900,height=500"); 
   
  // mywindow.moveTo(50,50);
}
  
function checkRadio(frmName, rbGroupName) {
 var radios = document[frmName].elements[rbGroupName];
 for (var i=0; i <radios.length; i++) {
  if (radios[i].checked) {
   return true;
  }
 }
 return false;
}

// Get radio button list value

function GetRadioButtonValue(id)
{
	var radio = document.getElementsByName(id);
	for (var ii = 0; ii < radio.length; ii++)
	{
		if (radio[ii].checked)
			return radio[ii].value;
	}
}
function isEmail(str)
{
	var regex = /^[-_.a-z0-9]+@(([-_a-z0-9]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i;
	return regex.test(str);
}


function trim(myString){
 
   return myString.replace( /^\s+/g,'').replace(/\s+$/g,'');
   
}
function BisEmail1(val)
   {
  
   var email = val.value.toLowerCase();
   if (val.value.length != 0) 
     {
  var emailformat = /^[^@\s]+@([-a-z0-9]+\.)+([a-z]{2}|com|net|edu|org|gov|mil|int|biz|pro|info|arpa|aero|coop|name|museum)$/;
	   	 if (!emailformat.test(email)) {
         alert("Please enter a valid email Id.");
         val.focus();
		 val.value = "";
         val.select();
         return false;
      }
   }
   val.value=email;
   return true;
}

/*************************//////////////




function __num( valu ){

	if( isNaN( valu )){
		alert("Please enter numbers only in the 'Length of lease remaining field'");
		document.page1_form.leaselength.value = '';
		document.page1_form.leaselength.focus();
		return false;
	}else{
		document.page1_form.draft20.value = valu;
		}
}



/*************** for contact solicitors form  *****************///////////
function formContactSolicitors(){
	
     var message="";
	 var error=0; 	
 	 x = document.frmSoCon;
   
	  str = trim(x.from_name.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.from_name.focus();
			 error=1;
			 x.from_name.style.backgroundColor="red";
			 message=message + "- Name field is required.\n";
		 }else{
		 x.from_name.style.backgroundColor="White";
		 }
		 
	  str = trim(x.from_tel.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.from_tel.focus();
			 error=1;
			 x.from_tel.style.backgroundColor="red";
			 message=message + "- Telephone field is required.\n";
		 }else{
		 x.from_tel.style.backgroundColor="White";
		 }
		 
		if(!isEmail(trim(x.from_email.value)))
		{
			if(error==0)
			error=1;
			x.from_email.focus();
			x.from_email.style.backgroundColor="red";
			message=message+"- Email field is required.\n";
		}else{
			x.from_email.style.backgroundColor="White";
			}
	
	  str = trim(x.question.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.question.focus();
			 error=1;
			 x.question.style.backgroundColor="red";
			 message=message + "- Question field is required.\n";
		 }else{
		 x.question.style.backgroundColor="White";
		 }
		 
	if(error==1)
       {
		 message="__________________________________________________\n\n The form was not submitted because of the following error(s). \n Please correct these error(s) and resubmit.\n __________________________________________________\n\n" + message ;
 	     alert(message);
	     return false;
       }
     return true;
	
  }
/*************** for purchase form  *****************///////////
function formInstruct(){

     var message="";
	 var error=0; 	
 	 x = document.frmInst;
   
	  str = trim(x.title1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.title1.focus();
			 error=1;
			 x.title1.style.backgroundColor="red";
			 message=message + "- Title field is required.\n";
		 }else{
		 x.title1.style.backgroundColor="White";
		 }
		 
	  str = trim(x.firstname1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.firstname1.focus();
			 error=1;
			 x.firstname1.style.backgroundColor="red";
			 message=message + "- First Name field is required.\n";
		 }else{
		 x.firstname1.style.backgroundColor="White";
		 }
		 
	  str = trim(x.lastname1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.lastname1.focus();
			 error=1;
			 x.lastname1.style.backgroundColor="red";
			 message=message + "- Last Name field is required.\n";
		 }else{
		 x.lastname1.style.backgroundColor="White";
		 }
		 
	  str = trim(x.add1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.add1.focus();
			 error=1;
			 x.add1.style.backgroundColor="red";
			 message=message + "- Address 1 field is required.\n";
		 }else{
		 x.add1.style.backgroundColor="White";
		 }
		 
	  str = trim(x.add2.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.add2.focus();
			 error=1;
			 x.add2.style.backgroundColor="red";
			 message=message + "- Address 2 field is required.\n";
		 }else{
		 x.add2.style.backgroundColor="White";
		 }
		 
	  str = trim(x.postcode.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.postcode.focus();
			 error=1;
			 x.postcode.style.backgroundColor="red";
			 message=message + "- Post Code field is required.\n";
		 }else{
		 x.postcode.style.backgroundColor="White";
		 }
		 
    if(!isEmail(trim(x.email.value)))
	{
		if(error==0)
		error=1;
	    x.email.focus();
	    x.email.style.backgroundColor="red";
  	    message=message+"- Email field is required.\n";
	}else{
		x.email.style.backgroundColor="White";
		}
	
	if(!x.unknown.checked){

	  str = trim(x.purchaseadd1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.purchaseadd1.focus();
			 error=1;
			 x.purchaseadd1.style.backgroundColor="red";
			 message=message + "- Purchase Address 1 field is required.\n";
		 }else{
		 x.purchaseadd1.style.backgroundColor="White";
		 }

	  str = trim(x.purchaseadd2.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.purchaseadd2.focus();
			 error=1;
			 x.purchaseadd2.style.backgroundColor="red";
			 message=message + "- Purchase Address 2 field is required.\n";
		 }else{
		 x.purchaseadd2.style.backgroundColor="White";
		 }

	  str = trim(x.purchasepostcode.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.purchasepostcode.focus();
			 error=1;
			 x.purchasepostcode.style.backgroundColor="red";
			 message=message + "- Purchase Post Code field is required.\n";
		 }else{
		 x.purchasepostcode.style.backgroundColor="White";
		 }
	}
		
		
	
	if(error==1)
       {
		 message="__________________________________________________\n\n The form was not submitted because of the following error(s). \n Please correct these error(s) and resubmit.\n __________________________________________________\n\n" + message ;
 	     alert(message);
	     return false;
       }
     return true;
	
  }

function purchase_address_not_known()
{
	x = document.frmInst;
if(x.unknown.checked){
x.purchaseadd1.value="not know at this time";
x.purchaseadd1.style.backgroundColor="White";

x.purchaseadd2.value="not know at this time";
x.purchaseadd2.style.backgroundColor="White";

x.purchaseadd3.value="not know at this time";
x.purchaseadd4.value="not know at this time";

x.purchasepostcode.value="not know";
x.purchasepostcode.style.backgroundColor="White";

}else{
x.purchaseadd1.value="";
x.purchaseadd2.value="";
x.purchaseadd3.value="";
x.purchaseadd4.value="";
x.purchasepostcode.value="";
}
}



//************ instruct form sale validation **************////////////////////
function formInstructSale(){

     var message="";
	 var error=0; 	
 	 x = document.frmInst;
   
	  str = trim(x.title1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.title1.focus();
			 error=1;
			 x.title1.style.backgroundColor="red";
			 message=message + "- Title field is required.\n";
		 }else{
		 x.title1.style.backgroundColor="White";
		 }
		 
	  str = trim(x.firstname1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.firstname1.focus();
			 error=1;
			 x.firstname1.style.backgroundColor="red";
			 message=message + "- First Name field is required.\n";
		 }else{
		 x.firstname1.style.backgroundColor="White";
		 }
		 
	  str = trim(x.lastname1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.lastname1.focus();
			 error=1;
			 x.lastname1.style.backgroundColor="red";
			 message=message + "- Last Name field is required.\n";
		 }else{
		 x.lastname1.style.backgroundColor="White";
		 }
		 
	  str = trim(x.add1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.add1.focus();
			 error=1;
			 x.add1.style.backgroundColor="red";
			 message=message + "- Address 1 field is required.\n";
		 }else{
		 x.add1.style.backgroundColor="White";
		 }
		 
	  str = trim(x.add2.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.add2.focus();
			 error=1;
			 x.add2.style.backgroundColor="red";
			 message=message + "- Address 2 field is required.\n";
		 }else{
		 x.add2.style.backgroundColor="White";
		 }
		 
	  str = trim(x.postcode.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.postcode.focus();
			 error=1;
			 x.postcode.style.backgroundColor="red";
			 message=message + "- Post Code field is required.\n";
		 }else{
		 x.postcode.style.backgroundColor="White";
		 }
		 
    if(!isEmail(trim(x.email.value)))
	{
		if(error==0)
		error=1;
	    x.email.focus();
	    x.email.style.backgroundColor="red";
  	    message=message+"- Email field is required.\n";
	}else{
		x.email.style.backgroundColor="White";
		}
	
	if(!x.unknown.checked){

	  str = trim(x.saleadd1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.saleadd1.focus();
			 error=1;
			 x.saleadd1.style.backgroundColor="red";
			 message=message + "- Sale Address 1 field is required.\n";
		 }else{
		 x.saleadd1.style.backgroundColor="White";
		 }

	  str = trim(x.saleadd2.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.saleadd2.focus();
			 error=1;
			 x.saleadd2.style.backgroundColor="red";
			 message=message + "- Sale Address 2 field is required.\n";
		 }else{
		 x.saleadd2.style.backgroundColor="White";
		 }

	  str = trim(x.salepostcode.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.salepostcode.focus();
			 error=1;
			 x.salepostcode.style.backgroundColor="red";
			 message=message + "- Sale Post Code field is required.\n";
		 }else{
		 x.salepostcode.style.backgroundColor="White";
		 }
	}
		
		
	
	if(error==1)
       {
		 message="__________________________________________________\n\n The form was not submitted because of the following error(s). \n Please correct these error(s) and resubmit.\n __________________________________________________\n\n" + message ;
 	     alert(message);
	     return false;
       }
     return true;
	
  }



function sale_address_not_known()
{
	x = document.frmInst;
if(x.unknown.checked){
x.saleadd1.value = x.add1.value;
x.saleadd1.style.backgroundColor="White";

x.saleadd2.value = x.add2.value;
x.saleadd2.style.backgroundColor="White";

x.saleadd3.value = x.add3.value;
x.saleadd4.value = x.add4.value;

x.salepostcode.value = x.postcode.value;
x.salepostcode.style.backgroundColor="White";

}else{
x.saleadd1.value="";
x.saleadd2.value="";
x.saleadd3.value="";
x.saleadd4.value="";
x.salepostcode.value="";
}
}

	function __addSale1(){
		x = document.frmInst;
		if(x.unknown.checked){
			x.saleadd1.value = x.add1.value;
		}
	}
	
	function __addSale2(){
		x = document.frmInst;
		if(x.unknown.checked){
			x.saleadd2.value = x.add2.value;
		}
	}
	
	function __addSale3(){
		x = document.frmInst;
		if(x.unknown.checked){
			x.saleadd3.value = x.add3.value;
		}
	}
	
	function __addSale4(){
		x = document.frmInst;
		if(x.unknown.checked){
			x.saleadd4.value = x.add4.value;
		}
	}
	
	function __postcode(){
		x = document.frmInst;
		if(x.unknown.checked){
			x.salepostcode.value = x.postcode.value;
		}
	}
	
//************ instruct form Remortgage validation **************////////////////////
function formInstructRemortgage(){

     var message="";
	 var error=0; 	
 	 x = document.frmInst;
   
	  str = trim(x.title1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.title1.focus();
			 error=1;
			 x.title1.style.backgroundColor="red";
			 message=message + "- Title field is required.\n";
		 }else{
		 x.title1.style.backgroundColor="White";
		 }
		 
	  str = trim(x.firstname1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.firstname1.focus();
			 error=1;
			 x.firstname1.style.backgroundColor="red";
			 message=message + "- First Name field is required.\n";
		 }else{
		 x.firstname1.style.backgroundColor="White";
		 }
		 
	  str = trim(x.lastname1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.lastname1.focus();
			 error=1;
			 x.lastname1.style.backgroundColor="red";
			 message=message + "- Last Name field is required.\n";
		 }else{
		 x.lastname1.style.backgroundColor="White";
		 }
		 
	  str = trim(x.add1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.add1.focus();
			 error=1;
			 x.add1.style.backgroundColor="red";
			 message=message + "- Address 1 field is required.\n";
		 }else{
		 x.add1.style.backgroundColor="White";
		 }
		 
	  str = trim(x.add2.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.add2.focus();
			 error=1;
			 x.add2.style.backgroundColor="red";
			 message=message + "- Address 2 field is required.\n";
		 }else{
		 x.add2.style.backgroundColor="White";
		 }
		 
	  str = trim(x.postcode.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.postcode.focus();
			 error=1;
			 x.postcode.style.backgroundColor="red";
			 message=message + "- Post Code field is required.\n";
		 }else{
		 x.postcode.style.backgroundColor="White";
		 }
		 
    if(!isEmail(trim(x.email.value)))
	{
		if(error==0)
		error=1;
	    x.email.focus();
	    x.email.style.backgroundColor="red";
  	    message=message+"- Email field is required.\n";
	}else{
		x.email.style.backgroundColor="White";
		}
	
	if(!x.unknown.checked){

	  str = trim(x.remortgageadd1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.remortgageadd1.focus();
			 error=1;
			 x.remortgageadd1.style.backgroundColor="red";
			 message=message + "- Re-mortgage Address 1 field is required.\n";
		 }else{
		 x.remortgageadd1.style.backgroundColor="White";
		 }

	  str = trim(x.remortgageadd2.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.remortgageadd2.focus();
			 error=1;
			 x.remortgageadd2.style.backgroundColor="red";
			 message=message + "- Re-mortgage Address 2 field is required.\n";
		 }else{
		 x.remortgageadd2.style.backgroundColor="White";
		 }

	  str = trim(x.remortgagepostcode.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.remortgagepostcode.focus();
			 error=1;
			 x.remortgagepostcode.style.backgroundColor="red";
			 message=message + "- Re-mortgage Post Code field is required.\n";
		 }else{
		 x.remortgagepostcode.style.backgroundColor="White";
		 }
	}
		
		
	
	if(error==1)
       {
		 message="__________________________________________________\n\n The form was not submitted because of the following error(s). \n Please correct these error(s) and resubmit.\n __________________________________________________\n\n" + message ;
 	     alert(message);
	     return false;
       }
     return true;
	
  }



function remortgage_address_not_known()
{
	x = document.frmInst;
if(x.unknown.checked){
x.remortgageadd1.value = x.add1.value;
x.remortgageadd1.style.backgroundColor="White";

x.remortgageadd2.value = x.add2.value;
x.remortgageadd2.style.backgroundColor="White";

x.remortgageadd3.value = x.add3.value;
x.remortgageadd4.value = x.add4.value;

x.remortgagepostcode.value = x.postcode.value;
x.remortgagepostcode.style.backgroundColor="White";

}else{
x.remortgageadd1.value="";
x.remortgageadd2.value="";
x.remortgageadd3.value="";
x.remortgageadd4.value="";
x.remortgagepostcode.value="";
}
}

	function __addRemortgage1(){
		x = document.frmInst;
		if(x.unknown.checked){
			x.remortgageadd1.value = x.add1.value;
		}
	}
	
	function __addRemortgage2(){
		x = document.frmInst;
		if(x.unknown.checked){
			x.remortgageadd2.value = x.add2.value;
		}
	}
	
	function __addRemortgage3(){
		x = document.frmInst;
		if(x.unknown.checked){
			x.remortgageadd3.value = x.add3.value;
		}
	}
	
	function __addRemortgage4(){
		x = document.frmInst;
		if(x.unknown.checked){
			x.remortgageadd4.value = x.add4.value;
		}
	}
	
	function __postcodeRemortgage(){
		x = document.frmInst;
		if(x.unknown.checked){
			x.remortgagepostcode.value = x.postcode.value;
		}
	}



//************ instruct form sale validation **************////////////////////
function formInstructSalePurchase(){

     var message="";
	 var error=0; 	
 	 x = document.frmInst;
   
	  str = trim(x.title1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.title1.focus();
			 error=1;
			 x.title1.style.backgroundColor="red";
			 message=message + "- Title field is required.\n";
		 }else{
		 x.title1.style.backgroundColor="White";
		 }
		 
	  str = trim(x.firstname1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.firstname1.focus();
			 error=1;
			 x.firstname1.style.backgroundColor="red";
			 message=message + "- First Name field is required.\n";
		 }else{
		 x.firstname1.style.backgroundColor="White";
		 }
		 
	  str = trim(x.lastname1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.lastname1.focus();
			 error=1;
			 x.lastname1.style.backgroundColor="red";
			 message=message + "- Last Name field is required.\n";
		 }else{
		 x.lastname1.style.backgroundColor="White";
		 }
		 
	  str = trim(x.add1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.add1.focus();
			 error=1;
			 x.add1.style.backgroundColor="red";
			 message=message + "- Address 1 field is required.\n";
		 }else{
		 x.add1.style.backgroundColor="White";
		 }
		 
	  str = trim(x.add2.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.add2.focus();
			 error=1;
			 x.add2.style.backgroundColor="red";
			 message=message + "- Address 2 field is required.\n";
		 }else{
		 x.add2.style.backgroundColor="White";
		 }
		 
	  str = trim(x.postcode.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.postcode.focus();
			 error=1;
			 x.postcode.style.backgroundColor="red";
			 message=message + "- Post Code field is required.\n";
		 }else{
		 x.postcode.style.backgroundColor="White";
		 }
		 
    if(!isEmail(trim(x.email.value)))
	{
		if(error==0)
		error=1;
	    x.email.focus();
	    x.email.style.backgroundColor="red";
  	    message=message+"- Email field is required.\n";
	}else{
		x.email.style.backgroundColor="White";
		}
	
	if(!x.unknown.checked){

	  str = trim(x.saleadd1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.saleadd1.focus();
			 error=1;
			 x.saleadd1.style.backgroundColor="red";
			 message=message + "- Sale Address 1 field is required.\n";
		 }else{
		 x.saleadd1.style.backgroundColor="White";
		 }

	  str = trim(x.saleadd2.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.saleadd2.focus();
			 error=1;
			 x.saleadd2.style.backgroundColor="red";
			 message=message + "- Sale Address 2 field is required.\n";
		 }else{
		 x.saleadd2.style.backgroundColor="White";
		 }

	  str = trim(x.salepostcode.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.salepostcode.focus();
			 error=1;
			 x.salepostcode.style.backgroundColor="red";
			 message=message + "- Sale Post Code field is required.\n";
		 }else{
		 x.salepostcode.style.backgroundColor="White";
		 }
	}
		
	if(!x.unknown.checked){

	  str = trim(x.purchaseadd1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.purchaseadd1.focus();
			 error=1;
			 x.purchaseadd1.style.backgroundColor="red";
			 message=message + "- Purchase Address 1 field is required.\n";
		 }else{
		 x.purchaseadd1.style.backgroundColor="White";
		 }

	  str = trim(x.purchaseadd2.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.purchaseadd2.focus();
			 error=1;
			 x.purchaseadd2.style.backgroundColor="red";
			 message=message + "- Purchase Address 2 field is required.\n";
		 }else{
		 x.purchaseadd2.style.backgroundColor="White";
		 }

	  str = trim(x.purchasepostcode.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.purchasepostcode.focus();
			 error=1;
			 x.purchasepostcode.style.backgroundColor="red";
			 message=message + "- Purchase Post Code field is required.\n";
		 }else{
		 x.purchasepostcode.style.backgroundColor="White";
		 }
	}
		
	
	if(error==1)
       {
		 message="__________________________________________________\n\n The form was not submitted because of the following error(s). \n Please correct these error(s) and resubmit.\n __________________________________________________\n\n" + message ;
 	     alert(message);
	     return false;
       }
     return true;
	
  }

	function __addSalePurchase1(){
		x = document.frmInst;
		if(x.copy.checked){
			x.saleadd1.value = x.add1.value;
		}
	}
	
	function __addSalePurchase2(){
		x = document.frmInst;
		if(x.copy.checked){
			x.saleadd2.value = x.add2.value;
		}
	}
	
	function __addSalePurchase3(){
		x = document.frmInst;
		if(x.copy.checked){
			x.saleadd3.value = x.add3.value;
		}
	}
	
	function __addSalePurchase4(){
		x = document.frmInst;
		if(x.copy.checked){
			x.saleadd4.value = x.add4.value;
		}
	}
	
	function __postcodeSalePurchase(){
		x = document.frmInst;
		if(x.copy.checked){
			x.salepostcode.value = x.postcode.value;
		}
	}
	
function sale_property_address_add(){
	x = document.frmInst;
	if(x.copy.checked){
		x.saleadd1.value = x.add1.value;
		x.saleadd1.style.backgroundColor="White";
		
		x.saleadd2.value = x.add2.value;
		x.saleadd2.style.backgroundColor="White";
		
		x.saleadd3.value = x.add3.value;
		x.saleadd4.value = x.add4.value;
		
		x.salepostcode.value = x.postcode.value;
		x.salepostcode.style.backgroundColor="White";
	
	}else{
		x.saleadd1.value="";
		x.saleadd2.value="";
		x.saleadd3.value="";
		x.saleadd4.value="";
		x.salepostcode.value="";
	}	
	}
//**************************////////////////////



function formCheck(){
	
     var message="";
	 var error=0; 	
 	 x = document.frmNm;

	  str = trim(x.property_value.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.property_value.focus();
			 error=1;
			 x.property_value.style.backgroundColor="red";
			 message=message + "- The Price field is required.\n";
		 }else{
		 x.property_value.style.backgroundColor="White";
		 }
		str = trim(x.property_value.value);
		if( isNaN( str )){
			 if(error==0)
			 x.property_value.focus();
			 error=1;
			 x.property_value.style.backgroundColor="red";
			 message=message + "- Please enter numbers only in the 'price field'\n";
			 
		}
	
	  str = trim(x.postcode.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.postcode.focus();
			 error=1;
			 x.postcode.style.backgroundColor="red";
			 message=message + "- The PostCode field is required.\n";
		 }else{
		 x.postcode.style.backgroundColor="White";
		 }
		 
		 
	
	/*
	if (!checkRadio("frmNm","hip")){
		 	
	     if(error==0)
	  	 error=1;
	 	 message=message + "- The HIP field is required.\n";
	}*/
	 
	if(error==1)
       {
		 message="__________________________________________________\n\n The form was not submitted because of the following error(s). \n Please correct these error(s) and resubmit.\n __________________________________________________\n\n" + message ;
 	     alert(message);
	     return false;
       }
     return true;
	
  }
  
function formCheckSalePurchase(){

     var message="";
	 var error=0; 	
 	 x = document.frmNm;
   
	  str = trim(x.property_value1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.property_value1.focus();
			 error=1;
			 x.property_value1.style.backgroundColor="red";
			 message=message + "- The Sale Property field is required.\n";
		 }else{
		 x.property_value1.style.backgroundColor="White";
		 }
		str = trim(x.property_value1.value);
		if( isNaN( str )){
			 if(error==0)
			 x.property_value1.focus();
			 error=1;
			 x.property_value1.style.backgroundColor="red";
			 message=message + "- Please enter numbers only in the 'Sale Property Value'\n";
			 
		}
	
	
	  str = trim(x.postcode1.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.postcode1.focus();
			 error=1;
			 x.postcode1.style.backgroundColor="red";
			 message=message + "- The Sale PostCode field is required.\n";
		 }else{
		 x.postcode1.style.backgroundColor="White";
		 }
		 
		 
	  str = trim(x.property_value2.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.property_value2.focus();
			 error=1;
			 x.property_value2.style.backgroundColor="red";
			 message=message + "- The Purchase Property field is required.\n";
		 }else{
		 x.property_value2.style.backgroundColor="White";
		 }
		str = trim(x.property_value2.value);
		if( isNaN( str )){
			 if(error==0)
			 x.property_value2.focus();
			 error=1;
			 x.property_value2.style.backgroundColor="red";
			 message=message + "- Please enter numbers only in the 'Purchase Property Value'\n";
			 
		}
	
	
	  str = trim(x.postcode2.value); 
	  if(str == "")
		 {	
			 if(error==0)
			 x.postcode2.focus();
			 error=1;
			 x.postcode2.style.backgroundColor="red";
			 message=message + "- The Purchase PostCode field is required.\n";
		 }else{
		 x.postcode2.style.backgroundColor="White";
		 }
	/*
	if (!checkRadio("frmNm","hip")){
		 	
	     if(error==0)
	  	 error=1;
	 	 message=message + "- The HIP field is required.\n";
	}*/
	 
	if(error==1)
       {
		 message="__________________________________________________\n\n The form was not submitted because of the following error(s). \n Please correct these error(s) and resubmit.\n __________________________________________________\n\n" + message ;
 	     alert(message);
	     return false;
       }
     return true;
	
  }
// -->

function __submitFrm(){
     var message="";
	 var error=0; 	
 	 x = document.page1_form;
	
/*    if(!isEmail(trim(x.agentemail.value)))
	{
		if(error==0)
		error=1;
	    x.agentemail.focus();
	    x.agentemail.style.backgroundColor="red";
  	    message=message+"- The Agent email field is required.\n";
	}else{
		x.email.style.backgroundColor="White";
		}*/
		
		if (x.proceed.checked == false){
		error=1;
		message=message+"- The Term and condition field is required.\n";
		}
	
	
	
	if(error==1)
       {
		 message="__________________________________________________\n\n The form was not submitted because of the following error(s). \n Please correct these error(s) and resubmit.\n __________________________________________________\n\n" + message ;
 	     alert(message);
	     return false;
       }
     return true;
	
  }
  
  
function __submitRefFrm(){
     var message="";
	 var error=0; 	
 	 x = document.refFrmNm;
	

  str = trim(x.refnum.value); 
  if(str == "")
	 {	
	     if(error==0)
		 x.refnum.focus();
	  	 error=1;
		 x.refnum.style.backgroundColor="red";
	 	 message=message + "- The Refrence Number field is required.\n";
	 }else{
		 x.refnum.style.backgroundColor="White";
		 }
		
	
	
	
	if(error==1)
       {
		 message="__________________________________________________\n\n The form was not submitted because of the following error(s). \n Please correct these error(s) and resubmit.\n __________________________________________________\n\n" + message ;
 	     alert(message);
	     return false;
       }
     return true;
	
  }
/***********************************************************/