function removeCommas( strValue ) {
   var objRegExp = /,/g; //search for commas globally
   //replace all matches with empty strings
   return strValue.replace(objRegExp,'');
}
// http://lists.evolt.org/pipermail/javascript/2006-June/010710.html

function openService(id) {
	   $(id).toggle();
 }


function openBox() {

var boxes=new Array()
//this is an associative array with the criteria as the item and the id of the box that needs
//to be made visible. this is necessary b/c if you hit the back button in IE 6 (7?) any javascript-opened
//elements are closed (boo!). this behavior doesn't apply to Firefox - back button maintains state.

boxes["heardAbout.selectedIndex==2"]="heardAboutRadioBox"
boxes["heardAbout.selectedIndex==8"]="heardAboutOtherBox"
boxes["heardAbout.selectedIndex==3"]="heardAboutSoundInvestingBox"

boxes["maritalStatus.selectedIndex==1 || document.qic.maritalStatus.selectedIndex==2"]="spouseBox"
boxes["spouseEmployed[0].checked"]="spouseOccupationBox"

boxes["ownHome[0].checked"]="homeBox"
boxes["haveMortgage[0].checked"]="mortgageBox"


for (var i in boxes) { //loop through the array
	field=i.split("."); //find the name of the field to check whether it exists on the page
		if(eval("document.qic." + field[0].replace('[0]',''))){ 
			if(eval("document.qic." + i)) {
				eval("document.getElementById('" + boxes[i] + "').style.display='block'");
			}
		} //make sure field exists
	}
}

// What to do on Page load...
$(document).ready(function(){
	// add topNav hover functions	
    $("#topNav li").not(".active").hover(      
		function(){ $(this).addClass('hover'); $("ul", this).show(); }, 
        function() { $(this).removeClass('hover'); $("ul", this).hide(); } 
    );
    if (document.all) {
        $("#topNav li").hoverClass("hover");
    }
});

$.fn.hoverClass = function(c) {
    return this.each(function(){
        $(this).hover( 
            function() { $(this).addClass(c);  },
            function() { $(this).removeClass(c); }
        );
    });
};  

/* cookies and text widget stolen from wired.com. NOTE: the on state of the indicator is in the ALT style sheet. */

/* begin common cookie functions.  see http://techweb/javascript_commons/docs/cookies.html for documentation. */
/* Set cookie value */
function setCookie(name, value, escapeValue, expires, path, domain, secure) {

    var cookieToken = name + '=' + ((escapeValue) ?  escape(value) : value) + ((expires) ? '; expires=' + expires.toGMTString() : '') + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + ((secure) ? '; secure' : '');
    document.cookie = cookieToken;

}

/* Get cookie value */
function getCookie(name) {
    var allCookies = document.cookie;
    
    var cookieName = name + "=";
    var start = allCookies.indexOf("; " + cookieName);
    
    if (start == -1) {
        start = allCookies.indexOf(cookieName);
        if (start != 0) return null;
    }
    else start += 2;
    
    var end = document.cookie.indexOf(";", start);
    if (end == -1) end = allCookies.length;
    
    return unescape(allCookies.substring(start + cookieName.length, end));
}

/* Delete a cookie */
function deleteCookie(name, path, domain) {
    var value = getCookie(name);
    if (value != null) document.cookie = name + '=' + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + '; expires=Thu, 01-Jan-70 00:00:01 GMT';
    return value;
}

/* Test for cookie support */
function verifyCookieSafe() {
    setCookie('pingCookies', 'hello');
    if (getCookie('pingCookies')) return true;
    else return false;
}

/* end common cookie functions. */

/* begin text size widget */
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) {
      	a.disabled = false;
      	}
    }
  }
}

function getActiveStyleSheet() { 
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

window.onunload = function(e) {
    var title = getActiveStyleSheet();
    //var expiration = new Date();
    //var expDuration = expiration.getTime() + (365*24*60*60*1000);
    //expiration.setTime(expDuration);
    setCookie("style", title, false, "", "/", "", false);
}

var textPref = getCookie("style");
var title = textPref ? textPref : getPreferredStyleSheet();
setActiveStyleSheet(title);

/* end text size widget */





/*
function subnavOn(panel,onState) {
		if(panel=='starting') {
			panelColor="#f68e51"
			panelBorder="#d97d47"
			hideOther1="#gettingNav"
			hideOther2="#livingNav"
		}

		if(panel=='getting') {
			panelColor="#f2bb47"
			panelBorder="#d7a640"
			hideOther1="#startingNav"
			hideOther2="#livingNav"
		}

		if(panel=='living') {
			panelColor="#c2c85c"
			panelBorder="#a6ab4f"
			hideOther1="#gettingNav"
			hideOther2="#startingNav"
		}

		if(onState != 'starting') {
		eval("document.getElementById('starting').style.background='#737361'");
		eval("document.getElementById('starting').style.borderTop='4px solid #4d4d41'");
		eval("document.getElementById('starting').style.borderRight='8px solid #4d4d41'");
		eval("document.getElementById('starting').style.color='#dfe4d3'");
		}
		
		
		if(onState != 'getting') {
		eval("document.getElementById('getting').style.background='#737361'");
		eval("document.getElementById('getting').style.borderTop='4px solid #4d4d41'");
		eval("document.getElementById('getting').style.borderRight='8px solid #4d4d41'");
		eval("document.getElementById('getting').style.color='#dfe4d3'");
		}
		
		if(onState != 'living') {
		eval("document.getElementById('living').style.background='#737361'");
		eval("document.getElementById('living').style.borderTop='4px solid #4d4d41'");
		eval("document.getElementById('living').style.borderRight='8px solid #4d4d41'");
		eval("document.getElementById('living').style.color='#dfe4d3'");
		}

		if(panel != 'none') {
			eval("document.getElementById('" + panel + "').style.background='" + panelColor + " url(/nav/top_nav_arrow.gif) no-repeat 174px 18px'");
			eval("document.getElementById('" + panel + "').style.borderTop='4px solid " + panelBorder + "'");
			eval("document.getElementById('" + panel + "').style.borderRight='8px solid " + panelBorder + "'");
			eval("document.getElementById('" + panel + "').style.color='#000'");
		}

	// turn all three off
		$("#startingNav").hide()
		$("#gettingNav").hide()
		$("#livingNav").hide()
	
		if(panel != 'none') {
			p="div#" + panel + "Nav"
			$(p).fadeIn(250,function(){$(hideOther1).hide();$(hideOther2).hide();});
			document.getElementById('mo').style.display='block';
		} else {
			document.getElementById('mo').style.display='none';
		}
	}

*/