function ValidateAccountForm(frm) {
	if (frm.CURRENT_PASSWORD.value == '') {
		alert ("Please enter your current password");
		return false;
	}
	if(ResetPWDValidator(frm)) {
		frm.submit();
	}
}
function checkAname(frm) {
	if (frm.Agent_YN[1].checked && frm.Agent_Name.value=="") {
		alert( "Pleasae enter your real estate agent name.");
		frm.Agent_Name.focus();
		return false;
	}
	if (frm.Agent_YN[0].checked) {
		frm.Agent_Name.value="";
	}
	return true;
}
function ValidateLoginForm(frm){
	if (frm.username.value < '' || !isEmail(frm.username.value) )	{
		alert('Please type in your E-mail address.');
		frm.username.focus();
		return false;
	}

	if (frm.password.value < ' ')	{
		alert('Please type in your password.');
		frm.password.focus();
		return false;
	}
	return true;
}

function ValidateSignup(theForm)
 {
	 if (theForm.EMAIL.value == "" || !isEmail(theForm.EMAIL.value) ) {
		alert("Please enter a valid value for the \"Email\" field.");
		theForm.EMAIL.focus();
		return (false);
	 }                  
	if(ResetPWDValidator(theForm) && checkAname(theForm)) {
		 return true;
	}
	return false;
 }

function confirmCloseAcct(){
	var input_box = false;
	input_box=confirm("You have chosen to close your My HomeFinder account. All you saved information will be deleted. \n\n Are you sure you'd like to continue? ")
	if (input_box) {
			input_box = confirm("Please note that once you have closed your account, you will no longer have the access to My HomeFinder using your this login. All saved information will be deleted.\n ");
	}
	if (input_box==true){ 
		location.href = 'myhf_doDeactivate.cfm';
	}
}
function EmailValidator(theForm){
	if (!isEmail(theForm.EMAIL.value) || trim(theForm.EMAIL.value) == ""){
		alert("Please enter a value for the \"Email\" field.");
		theForm.EMAIL.focus();
		return (false);
	}                  
	return (true);
}
	


function isEmail(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
	var pindex = theStr.indexOf(".",index);
	if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function doSubmitOpt(theForm) {
  if(!theForm.OPT_PREF[0].checked && !theForm.OPT_PREF[1].checked){
		alert("Please make a selection to receive(YES) or not receive(NO) additional information \nfrom the participating listing firm.");
		return (false);	
  }
  return (true);
}


					  
function ChangePasswordVal(theForm) {
	
	  var alertsay = ""; // define for long lines
	  // alertsay is not necessary for your code,
	  // but I need to break my lines in multiple lines
	  // so the code won't extend off the edge of the page
	
	   // check if EMAIL field is blank
	  if (theForm.PASSWORD1.value != theForm.PASSWORD2.value)
	  {
	  alert("Both Password Should Match");
	  theForm.PASSWORD1.focus();
	  return (false);
	  }
	  	  
	  if (theForm.PASSWORD1.value == "" && theForm.PASSWORD2.value == "")
	  {
	  alert("Please enter Your Password field.");
	  theForm.PASSWORD1.focus();
	  return (false);
	  }               
				  
								
	  // because this is a sample page, don't allow to exit to the post action
	  // comes in handy when you are testing the form validations and don't
	  // wish to exit the page
	 
	  return (true);
	  // replace the above with return(true); if you have a valid form to submit to
}
	  


function changePage(newLoc)
 {
   nextPage = newLoc.options[newLoc.selectedIndex].value;
		
   if (nextPage != "")
   {
      document.location.href = nextPage;
   }
 }


function confirmSubmit(frm) {  
	if (confirm("Click Ok If You Want to Delete This Bookmark")) {
		document.form1.action = "doUpdateBookMark.cfm"
		document.form1.delact.value="Delete Selected Bookmark";
		document.form1.submit();
	
	}
	
}

function goEdit() {
	var mlnumSel = "";
	document.form1.action = "dispFrmBookMark.cfm"
	if (document.form1.mlnum.checked==true){
		mlnumSel = document.form1.mlnum.value;
	}
	else {
		for (i=0; i<document.form1.mlnum.length; i++) {
			if (document.form1.mlnum[i].checked == true) {
				mlnumSel = document.form1.mlnum[i].value;
			}
		}
	}
	obj = eval('document.form1.photo' + mlnumSel)
	document.form1.photolink.value = obj.value;
	document.form1.submit();
}

function doSubmit(vval ){
	var yesSubmit=true;
	document.BookmarkForm.Submit.value=vval;
	if(vval=="Delete Notes"){
		if(!confirm('Are You Sure You Want To delete This Note ?')){
			yesSubmit=false;
		}
	}
	if(yesSubmit)document.BookmarkForm.submit();
}

function ValidatePassword(frm){
	if (frm.Current_Password.value == '')
	{
		alert('Please specify your current password.');
		frm.Current_Password.focus();
		return false;
	}

	if (frm.New_Password.value == '')
	{
		alert('Please specify your new password.');
		frm.New_Password.focus();
		return false;
	}

	if (frm.Confirm_Password.value == '')
	{
		alert('Please type in your new password again to confirm it.');
		frm.Confirm_Password.focus();
		return false;
	}
	
	if (frm.New_Password.value != frm.Confirm_Password.value)
	{
		alert('You did not correctly confirm your new password.');
		frm.Confirm_Password.select();
		return false;
	}
	
	return true;
}




function gotab(m) {
	if(m) {
		showdiv('divSignup');
		hidediv('divLogin');
		document.getElementById('item_2').className="selected";
		document.getElementById('item_1').className="";
	}
	else {
		showdiv('divLogin');
		hidediv('divSignup');
		document.getElementById('item_1').className="selected";
		document.getElementById('item_2').className="";
	}
}
function showdiv(id){
	var elem = document.getElementById(id);
	if (elem) {
		elem.style.display = 'block';
	}
}
function hidediv(id){
	if (document.getElementById(id)) {
		document.getElementById(id).style.display = 'none';
	}
}

function changeCRTab(menu) {
	aryMenu=[1,2,3,4];
	aryDiv=['ptFrmPnl','locFrmPnl','lcFrmPnl','ldaFrmPnl'];
	
	for(i=0;i<4;i++) {			
		if (i==menu) {	
			document.getElementById('item_'+aryMenu[i]).className='selected';
			document.getElementById(aryDiv[i]).style.display = 'block'
		}
		else {
			document.getElementById('item_'+aryMenu[i]).className = '';
			document.getElementById(aryDiv[i]).style.display = 'none';
		}
	}
	
}
function fnCheckAll(checkbox1, checkbox2) {
	var  YN= checkbox1.checked
	//if only lenght = 1
	if (checkbox2.length) {
		for (x=0; x<checkbox2.length; x++) {
			checkbox2[x].checked = YN;	
		}
	}
	else {
		checkbox2.checked = YN;	
	}
}


