<!--
///this function will be used to validate email id
function CheckEmail(field)
{
	if(field.value!='')
	{	
		var emailStr = new String();
		emailStr=field.value;
		var emailPat=/^(.+)@(.+)$/;
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
		var validChars="\[^\\s" + specialChars + "\]";
		var quotedUser="(\"[^\"]*\")";
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		var atom=validChars + '+';
		var word="(" + atom + "|" + quotedUser + ")";
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
		var matchArray=emailStr.match(emailPat);
       	if (matchArray==null) { 
			alert("Email address seems incorrect (check @ and .'s)");
			field.focus();
			field.select();
			return false;
			exit;
		}
		
		var user=matchArray[1];
		var domain=matchArray[2];

		if (user.match(userPat)==null) {
			alert("The username doesn't seem to be valid.");
			field.focus();
			field.select();

			return false;
			exit;
		}
		var IPArray=domain.match(ipDomainPat);
		if (IPArray!=null) 
			{
			for (var i=1;i<=4;i++) 
				{
				if (IPArray[i]>255) 
					{
					alert("Destination IP address is invalid!");
					field.focus();
					field.select();
					return false;
					exit;
					}
				}
			return true;
			}
		var domainArray=domain.match(domainPat);
		if (domainArray==null) 
			{
			alert("The domain name doesn't seem to be valid.");
			field.focus();
			field.select();
			return false;
			exit;
			}
		var atomPat=new RegExp(atom,"g");
		var domArr=domain.match(atomPat);
		var len=domArr.length;
		if (domArr[domArr.length-1].length<2 || 
			domArr[domArr.length-1].length>3) 
			{
		   // the address must end in a two letter or three letter word.
			alert("The address must end in a three-letter domain, or two letter country.");

			field.focus();
			field.select();
			return false;
			exit;
			}

		if (len<2) 
			{
			var errStr="This address is missing a hostname!";
			alert(errStr);
			field.focus();
			field.select();
			return false;
			exit;
			}
		return true;
	}

}
//function CheckEmail - to check email address ends here.

function alphanumeric(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
		  }
		else	{
			 return false;
		  }
		}
 return true;
}

function in_array( needle, haystack )
{
	for ( i=0; i < haystack.length; i++ )
		if ( haystack[i] == needle ) return true
	return false
}

function inputFocus( elmnt, msg )
{
	if ( elmnt.value == msg ) elmnt.value = ''
}

function inputBlur( elmnt, msg )
{
	if ( elmnt.value == '' ) elmnt.value = msg
}

function setDisplay( id , val )
{
	document.getElementById(id).style.display = val;
}



function profileFrmCheck() 
{
	var x = document.profileFrm;
	var skip = Array('other_sports', 'action','zip','othergoal' ,'province','city', 'other_interests','special_interests','how_hear','tr_certificat','tr_state','tr_city','tr_zip');
	
	if (!alphanumeric(x['username'].value)) {
		alert('Not correct characters in username. Only 0-9, a-z.');
		return false;
	}
	
	for (var i=0; i<x.length; i++)
	{
		if ( !in_array(x[i].name, skip) ){
		 if ( x[i].value == '' ) {
		 
			alert( 'All required fields must be filled:'+x[i].name);
			x[i].focus();
			return false;		
		 }
		}
	}
	
	if(!x.agreement.checked){
	 alert('You must check the agreement checkbox !');
	 return false;	
	}	
	
	if ( !CheckEmail( x['email'] ) )  return false 
	
	if ( x.email.value != x.emailConfirm.value ) 
	{
		alert( 'Please check your email address. Values are not equal' );
		x['email'].focus();
		return false;		
	}
/*	
	if ( x.password.value != x.passwordConfirm.value ) 
	{
		alert( 'Please check your password. Values are not equal' );
		x['password'].focus();
		return false;		
	}}*/
	
	return true;
}
function fitnessprofileFrmCheck()
{
	var x = document.profileFrm;
	var skip = Array('other_sports', 'other_classes','how_hear');
	
	if (x['name'].value == '' ) {
		alert('Field Name is required');
		return false;
	}
	
	for (var i=0; i<x.length; i++)
	{
		if ( !in_array(x[i].name, skip) ){
		 if ( x[i].value == '' ) {
		 
			alert( 'All required fields must be filled');
			x[i].focus();
			return false;		
		 }
		}
	}
	
	if(!x.agreement.checked){
	 alert('You must check the agreement checkbox !');
	 return false;	
	}	
	
	if ( !CheckEmail( x.email ) )  return false 
	
	if ( x.email.value != x.emailConfirm.value ) 
	{
		alert( 'Please check your email address. Values are not equal' );
		x['email'].focus();
		return false;		
	}
	
	if ( x.password.value != x.passwordConfirm.value ) 
	{
		alert( 'Please check your password. Values are not equal' );
		x['password'].focus();
		return false;		
	}
	
	return true;
}
function profileFrmCheck_new() 
{
	var x = document.profileFrm;
	var skip = Array('other_sports','zip','othergoal' ,'province','city',  'other_interests','hide_bodytype','hide_weight','special_interests','how_hear','tr_certificat','tr_zip');
	
	
	for (var i=0; i<x.length; i++)
	{
		if ( !in_array(x[i].name, skip) ){
		 if ( x[i].value == '' ) {
		 alert(x[i].value);
			alert( 'All required fields must be filled:'+x[i].name);
			x[i].focus();
			return false;		
		 }
		}
	}
	
	if(!x.agreement.checked){
	 alert('You must check the agreement checkbox !');
	 return false;	
	}	
	
	
/*	
	if ( x.password.value != x.passwordConfirm.value ) 
	{
		alert( 'Please check your password. Values are not equal' );
		x['password'].focus();
		return false;		
	}}*/
	
	return true;
}
function editProfileFrmCheck() 
{
	var x = document.profileFrm;
	for (var i=0; i<x.length; i++)
	{
		if ( x[i].name != 'fax' && x[i].name != 'website' )
		if ( x[i].value == '' ) {
			alert( 'All required fields must be filled' );
			x[i].focus();
			return false;		
		}
	}
	
	if ( !CheckEmail( x['email'] ) )  return false 
	
	return true;
}


function FrmCheck( ff ) 
{
	var x = document[ff];
	for (var i=0; i<x.length; i++)
	{
		if ( x[i].value == '' ) {
			alert( 'All required fields must be filled' );
			x[i].focus();
			return false;		
		}
	}	
	if ( !CheckEmail( x['email'] ) )  return false 
	
	return true;
}



function listFrmCheck( ff ) 
{
	var x = document[ff];
	var skip = Array('Subdivision','Area','state','bedrooms','Total_Full_Baths','Total_Half_Baths','Apx_Heated_SqFt','Type_Style', 'Fireplaces','Heat_Type','Cooling','Garage_Type','Exterior_Features','Waterfront','Apx_Acres','Lot_Size','img[]');
	
	for (var i=0; i<x.length; i++)
	{
		if ( !in_array(x[i].name, skip) )
		if ( x[i].value == '' ) {
			alert( 'All required fields must be filled  ');
			x[i].focus();
			return false;		
		}
	}	
	if ( x['terms'] != null  ) 
	{
		if ( !x['terms'].checked )
		{
			alert( 'You must agree with our Terms');
			return false;
		}
	}
	
	return true;
}


function popupQuest() {
  window.open('popup_design.php','popupWindow','toolbar=no,location=no, directories=no,status=no,menubar=no ,scrollbars=no,resizable=no,copyhistory=no,screenX=150,screenY=150,top=150,left=150')

} 


function contactFrmCheck( ff ) 
{
	var x = document[ff];
	for (var i=0; i<x.length; i++)
	{
		if ( x[i].name != 'Phone' )
		if ( x[i].value == '' ) {
			alert( 'All required fields must be filled' );
			x[i].focus();
			return false;		
		}
	}	
	if ( !CheckEmail( x['email'] ) )  return false 
	
	return true;
}
function checkgetperfect()
{
var x = document.frm;
	for (var i=0; i<x.length; i++)
	{
		
		if ( x[i].value == '' ) {
			alert( 'All required fields must be filled' );
			x[i].focus();
			return false;		
		}
	}	
	if ( !CheckEmail( x['email'] ) )  return false 
	
	return true;
}
function check_mls()
{
	var x = document['search_mls'];
	if (  isNaN(x.MLS.value) ) 
	{
		alert('MLS id must be a number');
		return false; 
	}
	else
		return true;
}

function isValidEmail(str)
{
	var emailStr = new String();
		emailStr=str;
		var emailPat=/^(.+)@(.+)$/;
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
		var validChars="\[^\\s" + specialChars + "\]";
		var quotedUser="(\"[^\"]*\")";
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		var atom=validChars + '+';
		var word="(" + atom + "|" + quotedUser + ")";
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
		var matchArray=emailStr.match(emailPat);
       	if (matchArray==null) { 
			alert("Email address seems incorrect (check @ and .'s)");
			return false;
			exit;
		}
		return true;

}

-->