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 WeAttractPopup()
{
	window.open(weattractpopup,null,'height=600,width=800,channelmode=0,directories=0,fullscreen=0,location=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0');
}

function IndexAbandonPopup()
 {
		var prop='toolbar=1,directories=1,menubar=1,scrollbars=1,resizable=1,locationbar=1,width=840,height=600';     
			if (unloadPopup) 
			{
				msg=window.open(indexAbandonPopupUrl,'exitdatingwindowert',prop);              
			}
		return true;
 }

function friendsIndexSwap(drop1,drop2)
{
	var friendsdrop = document.getElementById(drop1);
	var datingdrop = document.getElementById(drop2);
	
	
	friendsdrop.style.display = "block";
	datingdrop.style.display = "none";
		
}

function datingIndexSwap(drop1,drop2)
{
	var friendsdrop = document.getElementById(drop1);
	var datingdrop = document.getElementById(drop2);
	

	friendsdrop.style.display = "none";
	datingdrop.style.display = "block";
		
}

function resyncDivState()
{
	var searchByDating = document.getElementById(searchByDatingName);
	var searchByFriends = document.getElementById(searchByFriendsName);
	

	if (searchByDating != null)
	{
		if (searchByDating.checked)
		{
			datingIndexSwap('ds_friendsdrop','ds_datingdrop');
		}
		else
		{
			if (searchByFriends != null)
			{
				if (searchByFriends.checked)
				{
					friendsIndexSwap('ds_friendsdrop','ds_datingdrop');
				}
			}
		
		}
	}
}
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');
	}
}

function clearPostalCode(postalTxtbox)
{
   if (document.getElementById(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("Please enter a valid ZIP code.");
		document.formName.action = "";
		document.formName.target = "";
		return false;
	} else {
		document.formName.action = "http://cityguides.msn.com";
		document.formName.target = "_new";
		document.formName.submit();
		return true;
	}
	return isNotAlpha;
}

function showMatchWordsHelp(show) {
	document.getElementById('matchWordsHelp').style.display = (show) ? '' : 'none';
}

function partnerRegSearch(targetURLStr)
{
	var gender = document.getElementById('PartnerQuickSearchForm_GenderCode').value;
	var themGender = document.getElementById('PartnerQuickSearchForm_ThemRelationship').value;
	var lAge = document.getElementById('PartnerQuickSearchForm_M_LAGE_A0').value;
	var uAge = document.getElementById('PartnerQuickSearchForm_M_UAGE_A1').value;
	var postal = document.getElementById('PartnerQuickSearchForm_POSTALCODE').value;
    var requestParams = "GC="+gender;
        requestParams += "&TR="+themGender;
        requestParams += "&LAge="+lAge;
        requestParams += "&UAge="+uAge;
        requestParams += "&ua="+uAge;
        requestParams += "&PC="+postal;

        //Default to 50 miles
        requestParams += "&DIST=50";

	var targetURL = targetURLStr +"&"+requestParams;
	window.open(targetURL);
}

function QuickSearchSubmit(lidNumberString)
{
	var gender = document.getElementById('GenderCode').value;
	var themGender = document.getElementById('GenderSeek').value;
	var lAge = document.getElementById('LAge').value;
	var uAge = document.getElementById('UAge').value;
	var postal = document.getElementById('PostalCode').value;
	var distance = document.getElementById('Distance').value;
	var photosonly = document.getElementById('PhotosOnly').checked==true? 1 : 0;
	var onlinenow = document.getElementById('OnlineNow').checked==true? 1 : 0;
	
  var requestParams = "";
  if ((lidNumberString != undefined) & (lidNumberString != "" )) requestParams = "&lid=" + lidNumberString;
  
  requestParams += "&GC="+gender;
			requestParams += "&TR="+themGender;
			requestParams += "&LAge="+lAge;
			requestParams += "&UAge="+uAge;
			requestParams += "&ua="+uAge;
			requestParams += "&PC="+postal;
			requestParams += "&PO="+photosonly;
			requestParams += "&OLN="+onlinenow;
			requestParams += "&DO="+displayoption;
	    
			if (distance != "")
			{
				if ( isNumeric(distance) && (distance > 5000) )
				{ 
					distance = "5000";
				}
				else if (! isNumeric(distance))
				{
					distance = "50";
				}
			}
			else
			{
				distance = "50";
			}
			
	   requestParams += "&DIST="+distance;
        
	var targetURL = "/search/search.aspx?EXEC=go&sb=radius" + requestParams;   
	
	location.href=targetURL;
}
function isNumeric(test_string){
  
	var regex=/[^0-9]/;
	if(regex.test(test_string))
		return false;
	else 
		return true;
}
function UsernameSearchSubmit()
{
  location.href='../usearch/usearchdl.aspx?lid=226&handle=' + document.getElementById('txtHandle').value;
}
function KeywordSearchSubmit()
{
  location.href='../kwsearch/kwsearch.aspx?lid=108&KW=' + document.getElementById('txtKeyword').value;
}
function MatchWordsSearchSubmit()
{
  location.href='../mwsearch/mwsearch.aspx?EXEC=go&TAG=' + document.getElementById('txtMatchWords').value;
}


