
function LoadPopup()
 {
		var prop='toolbar=1,directories=1,menubar=1,scrollbars=1,resizable=1,locationbar=1,width=800,height=600';     
			if (unloadPopup) 
			{
				msg=window.open(indexAbandonPopupUrl,'exitdatingwindowert',prop);              
			}
		return true;
 }
 
function handleEnterKeyPress(newEvent)
{
	var isIE = (navigator.appVersion.toLowerCase().indexOf("msie") > -1) ? true : false;
	var isMac = (navigator.appVersion.toLowerCase().indexOf("mac") > -1) ? true : false;
	if(isIE)
	{
		if(event){newEvent = event;}
	}
	jsMatchPage.BlockEnterKey = false;
	if(newEvent != null)
	{
		if(parseInt(newEvent.keyCode) == 13)
		{
			if((isIE) && (!isMac))
			{
				document.getElementById(buttonToSubmit).click();
			}
			return false;
		}
	}
}

function enableEmailOnSaveSearches(savedChkbox, emailChkbox)
{
    var emailChk = document.getElementById(emailChkbox);
	if(document.getElementById(savedChkbox).checked)
	{
	   emailChk.disabled = false;
	   //span tag is wrapped around checkbox in generated html.
	   //Need to remove it, to enable
	   emailChk.parentElement.removeAttribute('disabled');
	  
	} else {
	   emailChk.checked = false;
	   emailChk.disabled = true;
	   emailChk.parentElement.setAttribute('disabled','true');
	}
    
	//alert("enableEmailOnSaveSearches:end");
		
}

function clearPostalCode(postalTxtbox)
{
   var postalTxt = document.getElementById(postalTxtbox);
   
   if((postalTxt.value == "city/zip/postal") ||
      (postalTxt.value == "city")||
      (postalTxt.value == "city/postcode")||
      (postalTxt.value == "city or ZIP code"))
   {
       postalTxt.value = "";
  
   }
}
function alphaNumericCheck(){
  
	var regex=/[^0-9a-zA-Z]/;
	if(regex.test(document.formName.zip.value)){
		//alert("fail");
		alert("Please enter a valid ZIP code.");
		document.formName.action = "";
		document.formName.target = "";
		return false;
	} else {
		//alert("pass");
		document.formName.action = "http://local.msn.com/t3/default.asp";
		document.formName.target = "_new";
		document.formName.submit();
		return true;
	}
	return isNotAlpha;
}

function showMatchWordsHelp(show) {
	document.getElementById('matchWordsHelp').style.display = (show) ? '' : 'none';
}



function FlipDisplayOptionState()
{
    var currentState = document.forms['matchMainForm'].elements[photosOnly].checked;
    document.forms['matchMainForm'].elements[displayOption].className = (currentState == true ? "visible" : "hidden");
}

function EnableSearchByElements(searchBy)
{
    var searchByRadius = document.getElementById('SrchtypeRadiusForm');
    var searchByRegion = document.getElementById('SrchtypeRegionForm');

    if (searchBy == "radius")
    {
       searchByRadius.className = 'visible';
       searchByRegion.className = 'hidden';

    }
    else if (searchBy == "region")
    {
       searchByRegion.className = 'visible';
       searchByRadius.className = 'hidden';

    }
}

function PopulateHiddenFields()
{
    document.forms['matchMainForm'].elements['hdnCountryList'].value = countryListValue ;
    document.forms['matchMainForm'].elements['hdnStateList'].value = stateListValue;
}

function toggleAccordian(paneLegend) {
	var pane = paneLegend.parentNode;
	
	if (pane.className.indexOf('accordianPaneOpen') > -1) 
		pane.className = pane.className.replace('accordianPaneOpen', 'accordianPaneClosed');
	else
		pane.className = pane.className.replace('accordianPaneClosed', 'accordianPaneOpen');
}

///////////////////////////////////////////////////////////////////////
// lib.search.refine.js
// This javascript library handles all javascript operations for the 
// refine on the fly module, including collapsing and expanding menus,
// fly-outs, etc...
//

///////////////////////////////////////////////////////////////////////
// Main script block. This is run on the page every page load.
// This script block just initializes all the elements on the page to hidden.
var max			= 4;  //Set the number of elements to expand/collapse
					  //JM: Changed to max=5 to max=4 after removing Interests section	
var shown		= new Array();
var menu;
var image;

///////////////////////////////////////////////////////////////////////
// Function to expand the form elements once open
function subexpand(section){

	for (var i=1;i<=max;i++)
	{
		menu = document.getElementById('menu'+ i);
		image = document.getElementById('foldoutarrow' + i);
		if (i == section)
		{
			if (menu.style.display == 'none')
			{
				menu.style.display = 'block';
				image.src = imageServer + "search/foldoutmenu_arrow_open.gif";
			}
			else if (menu.style.display == 'block')
			{
				menu.style.display = 'none';
				image.src = imageServer + "search/foldoutmenu_arrow.gif";
			}
			else
			{
				menu.style.display = 'block';
				image.src = imageServer + "search/foldoutmenu_arrow_open.gif";
			}
		}
		else
		{
			menu.style.display = 'none';
			image.src = imageServer + "search/foldoutmenu_arrow.gif";
		}
	}
}

// Set objects in array to false
for (var i = 1; i <= max; i++)
{
	shown[i] = false;
}

///////////////////////////////////////////////////////////////////////
function openFullMenu(n, n1)
{
	var y1 = document.getElementById(n);	
	var y2 = document.getElementById(n1);	

	if (y1.style.display == "block")
	{
		y1.style.display = "none";
	}
	else if (y1.style.display == "none")
	{
		y1.style.display = "block";
	}
	else
	{
		y1.style.display = "none";
	}

	if (y2.style.display == "none")
	{
		y2.style.display = "block";
	}
	else if (y2.style.display == "block")
	{
		y2.style.display = "none";
	}
	else
	{
		y2.style.display = "block";
	}			
}

///////////////////////////////////////////////////////////////////////
function openAndExpandMenuItems(el)
{
    openFullMenu('rotf_MenuOuterContainerClosed', 'rotf_MenuOuterContainerOpen');
    subexpand(el);
}

///////////////////////////////////////////////////////////////////////
function closeAllMenuItems() 
{
    openFullMenu('rotf_MenuOuterContainerClosed', 'rotf_MenuOuterContainerOpen');
    subexpand();
}


function HideFemaleFeatures(controlName)
{
		
	var gender = document.getElementById(controlName);
	if (gender!= null)
	{
		
		if (document.forms[0].M_Build!=null)
		{
		var checkArray = document.forms[0].M_Build;
		var index = 0;
		var controlMax = checkArray.length;
		
		
			if (gender.value==1 ) // Man
			{
				document.getElementById("M_Build_08").style.visibility = 'hidden';
				document.getElementById("M_Build_09").style.visibility = 'hidden';
				document.getElementById("M_Build_10").style.visibility = 'hidden';
			}
			else if (gender.value==2) //Woman
			{
				document.getElementById("M_Build_08").style.visibility = 'visible';
				document.getElementById("M_Build_09").style.visibility = 'visible';
				document.getElementById("M_Build_10").style.visibility = 'visible';
			}
				
			for (index = 0; index < controlMax; index++)
			{		
				if (checkArray[index].value=="M_Build_08" || 
					checkArray[index].value=="M_Build_09" ||
					checkArray[index].value=="M_Build_10")
				{
					if (gender.value==1 ) // Man
					{
						checkArray[index].style.visibility = 'hidden';
						checkArray[index].checked=false;
					}
					else if (gender.value==2) //Woman
					{
						checkArray[index].style.visibility = 'visible';
						checkArray[index].checked=false;					
					}
				}
			}
		}
	}

}	

HideFemaleFeatures();


function CheckAny(refControlArray,strAny,me)
{
	var formIndex;
	var controlMax = refControlArray.length
	for (formIndex = 0; formIndex < controlMax; formIndex++)
	{
		if (refControlArray[formIndex].value==strAny)
		{
		refControlArray[formIndex].checked = true;
		}
		else
		{
		refControlArray[formIndex].checked = false;
		}
	}
}
function UnCheckAny(refControlArray,strAny,me)
{
	var formIndex;
	var controlMax = refControlArray.length
	for (formIndex = 0; formIndex < controlMax; formIndex++)
	{
		if (refControlArray[formIndex].value==strAny)
		{
		refControlArray[formIndex].checked = false;
		}
	}
}
function SubmitForm(strURL)
{
	document.forms['matchMainForm'].target = "_self";
	document.forms['matchMainForm'].action = strURL;
	document.forms['matchMainForm'].submit();
}
function FlipDisplayOptionState()
{
    var po = document.getElementById('checkPhoto');
    if (po.checked != true)
    {
		document.getElementById('disOptions').disabled = true;
    }
    else
    {
    	document.getElementById('disOptions').disabled = false;
    }
}
function divSwap(div1,div2)
{
	var show = document.getElementById(div1);
	var hide = document.getElementById(div2);
		
	hide.style.display = "none";
	show.style.display = "block";
}

