function validate_key(){

   var key=document.key_check.key.value;

   if(key==''){

     alert('Please enter your unlock key');

	 document.key_check.key.focus();

	 return false;

   }

}
function trim(str)
{
   return str.replace(/^\s+|\s+$/g,'');
}

function replaceAll (streng, soeg, erstat)
{ 
  var st = streng;
  if (soeg.length == 0)
     return st;
  var idx = st.indexOf(soeg);
  while (idx >= 0)        
  {  st = st.substring(0,idx) + erstat + st.substr(idx+soeg.length);
     idx = st.indexOf(soeg);
  }
  return st;
}

function Validate()

{ 

	
	var fname=document.frm.txtFname.value;

	var lname=document.frm.txtLname.value;

	var email=document.frm.txtEmail.value;

	var pass=document.frm.txtPass.value;

	var cpass=document.frm.txtCPass.value;

	var phone=document.frm.txtPhone.value;
	
	var saletype=document.frm.saletype;
	
	var area=document.frm.area;
	
	var price=document.frm.price;

	if(trim(fname) == ''){ 

		alert('Please enter your first name');

		document.frm.txtFname.focus();

		return false;

	}

	if(trim(lname)==''){

		alert('Please enter your last name');

		document.frm.txtLname.focus();

		return false;

	}

	if(trim(email)==''){

		alert('Please enter your email');

		document.frm.txtEmail.focus();

		return false;

	}

	if(trim(email)!=''){

	   if(emailcheck(email)==false)

	   {

	   	  document.frm.txtEmail.value='';	

	      document.frm.txtEmail.focus();

		  return false;

		}  

	   

	}

	if(trim(pass)==''){

		alert('Please enter your password');

		document.frm.txtPass.focus();

		return false;

	

	}

	if(trim(cpass)==''){

		alert('Please enter your confirm password');

		document.frm.txtCPass.focus();

		return false;

    }

	if(pass!=cpass){

	   alert("Your password doesn't match");

	   document.frm.txtPass.value='';

	   document.frm.txtCPass.value='';

	   document.frm.txtPass.focus();

	   return false;

	}

	if(trim(phone)==''){

		alert('Please enter your phone');

		document.frm.txtPhone.focus();

		return false;

	}

	if(trim(phone)!=''){
 		
	   if( isNaN(replaceAll(phone, " ", ""))  ){

	      alert('Please enter numeric values only');

		  document.frm.txtPhone.value='';

		  document.frm.txtPhone.focus();

		  return false;

	   }
	    if(phone.replace(' ' , '') ==0){

	      alert('Please enter numeric values only');

		  document.frm.txtPhone.value='';

		  document.frm.txtPhone.focus();

		  return false;

	   } 
	   
 	}   
	   if(saletype.selectedIndex==0){
 		alert('Please choose Property Type');
 		document.frm.saletype.focus();
 		return false;
 	  }
	   
	   if(area.selectedIndex==0){
 		alert('Please choose Property Area');
 		document.frm.area.focus();
 		return false;
 	  }
	  
	   if(price.selectedIndex==0){
 		alert('Please choose Max Price');
 		document.frm.price.focus();
 		return false;
 	  }
	   
	  
	

	document.frm.action = 'member_registration.php';
	document.frm.submit();
}

function display(value){
 	if(value ==4 ){
		document.getElementById("memberbedrooms").style.display='none';
		document.getElementById("bathrooms").style.display='none';

	}else{
		document.getElementById("memberbedrooms").style.display='';
		document.getElementById("bathrooms").style.display='';
	}	
}
function emailcheck(str) 

{

if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(str))

//if((str.indexOf('@')<0) ||(str.indexOf('@')!=-1) && (str.charAt(str.length-4)!='.') && (str.charAt(str.length-3)!='.') && str.charAt(0)=='@'))

{

alert("Please enter a valid email address eg: username@domainname.com");

return false;

}

}
function echeck(str) {

if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(str))

//if((str.indexOf('@')<0) ||(str.indexOf('@')!=-1) && (str.charAt(str.length-4)!='.') && (str.charAt(str.length-3)!='.') && str.charAt(0)=='@'))

{

alert("Invalid Email");

return false;

}

}

//Numeric validation

function isInteger(s)

{

	//var s=document.frm.text.value;

	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 fnCheck()

{

	

	for (var i=0; i < document.frm.mem_type.length; i++)

   	{

   		if (document.frm.mem_type[i].checked)

      	{

      		var val = document.frm.mem_type[i].value;

			

      	}

   }



	if(val!=2){	

		fnShow('upload');

		fnShow('upload1');

		fnShow('upload2');

	}	

	else{

		fnHide('upload');

		fnHide('upload1');

		fnHide('upload2');

	}	

}

	

function fnHide(){

	args=fnHide.arguments;

	for(i=0;i<args.length;i++)

		x=document.all[args[i]];

		x.style.visibility='hidden';

	}

	

function fnShow(){

	args=fnShow.arguments;

	for(i=0;i<args.length;i++)

		x=document.all[args[i]];

		x.style.visibility='visible';

}	

function radio_check()

{

	var radioCheck = false;

	for (i = 0; i < document.frm.gender.length; i++) {

			if (document.frm.gender[i].checked)

		radioCheck = true;

	}

	if (!radioCheck) {

		

		return false;

	}

}

function testURL(frmSample, Ctrl) {

    if (Ctrl.value == "" || Ctrl.value.indexOf("www",0) == -1) {

       alert("Please provide valid URL");

 		return false;

 	} else

return true;

 }
 <!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->