<!--
var xmlhttp = false;
var jsReady = false;
var swfReady = false;

$(function() {

    $("#navOverview").ImgMouseEventChange({
    	over:'/img/phoneDating/btn/overview_on.gif', 
    	down:null, 
    	out:'/img/phoneDating/btn/overview_off.gif'
    });

    $("#navComparison").ImgMouseEventChange({
    	over:'/img/phoneDating/btn/comparisons_on.gif', 
    	down:null, 
    	out:'/img/phoneDating/btn/comparisons_off.gif'
    });
    
    $("#navTips").ImgMouseEventChange({
    	over:'/img/phoneDating/btn/tips_on.gif', 
    	down:null, 
    	out:'/img/phoneDating/btn/tips_off.gif'
    });
    

    $("#getNumberBtn").ImgMouseEventChange({
    	over:'/img/phoneDating/findNumber/btn/getNumberOvr.gif', 
    	down:'/img/phoneDating/findNumber/btn/getNumberDwn.gif', 
    	out:'/img/phoneDating/findNumber/btn/getNumber.gif'
    });

	initHttpRequest();
	
	p_gender = getCookie("gender");
	p_zipCode = getCookie("zipcode");
	
	// Preset Gender Values
	var iAmIndex, lookForIndex
	switch(p_gender){
		case "m":
			iAmIndex = 0;
			lookForIndex = 1;
			break;
			
		case "n":
			iAmIndex = 0;
			lookForIndex = 0;
			break;
		
		case "f":
			iAmIndex = 1;
			lookForIndex = 0;
			break;
			
		case "g":
			iAmIndex = 1;
			lookForIndex = 1;
			break;
			
		default:
			iAmIndex = 1;
			lookForIndex = 0;
			break;
	}
		
	document.getElementById("iAm_list").selectedIndex	= iAmIndex;
	document.getElementById("seeking_list").selectedIndex	= lookForIndex;
	
	changeIcon("iAmIcon");
	changeIcon("lookingForIcon");
		
	document.getElementById("areaZip_txt").value = (p_zipCode == "undefined" || p_zipCode == null) ? "" : p_zipCode.substring(0,5);
	
	var comboBox = document.getElementById("city_list");
		comboBox.options.length = 0;
		comboBox.options[0] = new Option("----- Pick A State First -----","null");
		
	//loadXML("/html/xmlParser.asp?id=106", "<xdoc><MTSStateList></MTSStateList></xdoc>");
	loadStateXML("StateList.aspx", "<xdoc><MTSStateList></MTSStateList></xdoc>");
	
	jsReady = true;
});

function isDOMReady() {
	return jsReady;
}

function getGenderCode(){
	return $.cookie("gender");
}

function changeIcon(p_imgID){

	var gender

	switch(p_imgID){
		case "iAmIcon":
			gender = document.getElementById("iAm_list").selectedIndex
			break;
			
		case "lookingForIcon":
			gender = document.getElementById("seeking_list").selectedIndex
			break;
	
	}
	
	var imgPath = "../img/phoneDating/findNumber/icons/";
	var fileName = (gender == 0) ? "man.gif" : "woman.gif"
	
	document.getElementById(p_imgID).src = imgPath + fileName;
}
						
function getCityList(){
	var comboBox = document.getElementById("city_list");
		comboBox.options.length = 0;
		comboBox.options[0] = new Option("Loading...                        ","null");
		
		comboBox = document.getElementById("state_list");

	var state = comboBox.options[comboBox.selectedIndex].value;
	    loadCityXML("CityList.aspx?state=" + state, "")
}
									

function loadStateXML(p_page, p_postData){
	xmlhttp.open("POST", p_page, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			var xDoc = initXMLParser(xmlhttp.responseText);
			var comboBox = document.getElementById("state_list");
			comboBox.options[0] = new Option("--","null");
            populate_Combo(comboBox, "StateAbbr", xDoc.getElementsByTagName("StateAbbr"));
		}
	}
	 xmlhttp.send(p_postData)
}
	
function loadCityXML(p_page, p_postData){
	xmlhttp.open("POST", p_page, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			var xDoc = initXMLParser(xmlhttp.responseText);
		    var comboBox = document.getElementById("city_list");
			comboBox.options.length = 0;
			comboBox.options[0] = new Option("------- Please Choose -------","null");
			populate_Combo(comboBox, "City", xDoc.getElementsByTagName("City"));
		}
	}
	 xmlhttp.send(p_postData)
}

function populate_Combo(p_combo, p_attribute, p_xmlDoc){					
	var optionItem;
	for(var i=0, len = p_xmlDoc.length; i<len; i++){
		optionItem = p_xmlDoc[i].firstChild.nodeValue
		p_combo.options[(i+1)] = new Option(optionItem, optionItem);
	}
}

function zipCode_Change(){
	document.getElementById("areaZip_txt").value = "";
}

function cityList_Change(){
	document.getElementById("areaZip_txt").value = "";
	document.getElementById("areaCode_txt").value = "";
}

function initHttpRequest(){
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 }catch (e){
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	 }
	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
}

function initXMLParser(p_xmlString){

	// code for IE
	if (window.ActiveXObject){
		var doc=new ActiveXObject("Microsoft.XMLDOM");
			doc.async="false";
			doc.loadXML(p_xmlString);
	}else{
		// Try To Create Object
		var parser = new DOMParser();
		
		if(!parser){
			// Code For Safari
			var doc = p_xmlString
		}else{
			// code for Mozilla, Firefox, Opera, Safari etc.
			var doc=parser.parseFromString(p_xmlString,"text/xml");
		}
	}
	 return doc;
}

// this function gets the cookie, if it exists
function getCookie( p_name ) {
	
	var cookieArray = document.cookie.split(";");
		
	for(var i=0, len = cookieArray.length; i<len; i++){
		start = cookieArray[i].indexOf("=");
		if(leftTrim(cookieArray[i].substring(0, start)) == p_name){
			return unescape( cookieArray[i].substring((start + 1), cookieArray[i].length ));
			break;
		}
	}
	
	return null;
}

function leftTrim(sString) {
	while (sString.substring(0,1) == ' '){
		sString = sString.substring(1, sString.length);
	}
	return sString;
}

function chkForm(){

	var tmpIAm = document.getElementById("iAm_list").options[document.getElementById("iAm_list").selectedIndex].value
	var tmpSeeking = document.getElementById("seeking_list").options[document.getElementById("seeking_list").selectedIndex].value;
	var tmpAreaZip = document.getElementById("areaZip_txt").value;
	
	var tmpAreaCode = document.getElementById("areaCode_txt").value;
	var tmpState = document.getElementById("state_list").options[document.getElementById("state_list").selectedIndex].value;
	var tmpCity = document.getElementById("city_list").options[document.getElementById("city_list").selectedIndex].value;
	var system = (tmpIAm == tmpSeeking) ? "Mega" : "Tele";

	if(tmpState != "null" && tmpCity != "null"){
		if(tmpState != "null" && tmpCity == "null"){
			alert("Please select city.");
			return false;
		}
	}
	else if(tmpAreaCode.length > 0){
		// Request By Area Code
		if(tmpAreaCode.length != 3 || isNaN(tmpAreaCode)){
			alert("Please enter a valid 3 digit area code.");
			return false;
		}
	}
	else if(tmpAreaZip.length > 0){
		if(tmpAreaZip.length != 5 ||isNaN(tmpAreaZip)){
			alert("Please enter a valid 5 digit zip code.");
			return false;
		}
	}else{
		alert("Please enter either a zip code, area code or choose a city and state.");
		return false;
	}

	document.location = "/phone-dating/local-number-list.aspx?zipcode=" + tmpAreaZip + "&areacode=" + tmpAreaCode + "&city=" + tmpCity + "&state=" + tmpState + "&megatele=" + system
}

// -->