function printWindow() {
	if (window.print) {
    	window.print();
  	} else {
		alert("Your browser may not be able to call the print option from a link. Please print this page as you normally would.");
	}
}

function toggleTheme() {
	var title = "Theme";
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if (a.getAttribute("rel").indexOf("style") != -1
		&& a.getAttribute("title")) {
			if (a.getAttribute("title") == title) {
				if (a.disabled == false) {
					a.disabled = true;
				} else {
					a.disabled = false;
				}
			}
		}
	}
}

function resetImageIcons() {
	iconSmallImg = document.getElementById("icon_resize_small");
	if (iconSmallImg) { iconSmallImg.setAttribute("src","uib/images/icon_resize_small_on.gif") }
	
	iconMediumImg = document.getElementById("icon_resize_medium");
	if (iconMediumImg) { iconMediumImg.setAttribute("src","uib/images/icon_resize_medium_on.gif") }
	
	iconLargeImg = document.getElementById("icon_resize_large");
	if (iconLargeImg) { iconLargeImg.setAttribute("src","uib/images/icon_resize_large_on.gif") }
}

function setActiveIcon(title) {
	if (title == "Medium Text") {
		iconMediumImg = document.getElementById("icon_resize_medium");
		if (iconMediumImg) { iconMediumImg.setAttribute("src","uib/images/icon_resize_medium.gif") }
	} else if (title == "Large Text") {
		iconLargeImg = document.getElementById("icon_resize_large");
		if (iconLargeImg) { iconLargeImg.setAttribute("src","uib/images/icon_resize_large.gif") }
	} else {
		iconSmallImg = document.getElementById("icon_resize_small");
		if (iconSmallImg) { iconSmallImg.setAttribute("src","uib/images/icon_resize_small.gif") }
	}
}

function resetActiveStyleSheet() {
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if (a.getAttribute("rel").indexOf("style") != -1
		&& a.getAttribute("rel").indexOf("alt") != -1) {
			a.disabled = true;
		}
	}
	resetImageIcons();
	setActiveIcon("Normal Text");
}

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;
		}
	}
	resetImageIcons();
	setActiveIcon(title);
}

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 createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else {
		expires = "";
	}
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for (var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	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;
}

function initActiveStyleSheet() {
	var cookie = readCookie("style");
	var title = cookie ? cookie : getPreferredStyleSheet();
	setActiveStyleSheet(title);
}

window.onunload = function(e) {
	var title = getActiveStyleSheet();
	createCookie("style", title, 365);
}

var windowpop = '';
function closePop() {
	if (windowpop && windowpop.open && !windowpop.closed) windowpop.close();
}
function openPop(winURL) {
	closePop();
	var winOptions = 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=500,height=400';
	windowpop = window.open(winURL, 'windowpop', winOptions);
}
function openPopPrint(winURL) {
	closePop();
	var winOptions = 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=600,height=400';
	windowpop = window.open(winURL, 'windowpop', winOptions);
}

function openPopTour(winURL) {
	closePop();
	var winOptions = 'scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no,width=720,height=485';
	windowpop = window.open(winURL, 'windowpop', winOptions);
}

function openPopWide(winURL) {
	closePop();
	var winOptions = 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=779,height=500';
	windowpop = window.open(winURL, 'windowpop', winOptions);
}
function highlightAreaReset() {
	// reset the backgrounds to white
	document.getElementById("improve_block").style.background="none";
	document.getElementById("protect_block").style.background="none";
	document.getElementById("control_block").style.background="none";
}

function highlightArea(section) {
	// reset the backgrounds to white
	document.getElementById("improve_block").style.background="none";
	document.getElementById("protect_block").style.background="none";
	document.getElementById("control_block").style.background="none";
	
	// set the background to selected state
	document.getElementById(section).style.background="url('uib/images/home_"+section+"_bg.gif') no-repeat";
}

function chooseProduct() {
	box = document.product_select.product;
	destination = box.options[box.selectedIndex].value;
	if (destination) window.location.href = destination;
}

if (document.images) {
	image1 = new Image();
	image1.src = "uib/images/icon_resize_small.gif";
	
	image2 = new Image();
	image2.src = "uib/images/icon_resize_medium.gif";
	
	image3 = new Image();
	image3.src = "uib/images/icon_resize_large.gif";
	
	image4 = new Image();
	image4.src = "uib/images/icon_resize_small_on.gif";
	
	image5 = new Image();
	image5.src = "uib/images/icon_resize_medium_on.gif";
	
	image6 = new Image();
	image6.src = "uib/images/icon_resize_large_on.gif";
	
	image7 = new Image();
	image7.src = "uib/images/topnavitem_bg.gif";
	
	image8 = new Image();
	image8.src = "uib/images/topnavitem_bg_over.gif";
	
	image9 = new Image();
	image9.src = "uib/images/topnavsubitem_bg_over.gif";
}

function HelpWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function GetHelp() {
	HelpWindow('http://www.iamhr.com/Help/iamCareerHelp.htm', 'HelpWindow', '750', '550', 'no')
}

function setDefaultPage(page) {
	createCookie("defaultpage", page, 365);
	document.getElementById("defaultpage_toggle").style.display="none";
}

function readDefaultPage() {
	var pagecookie = readCookie("defaultpage");
	if (pagecookie == "personal" || pagecookie == null) {
		document.getElementById("defaultpage_toggle").style.display="none";
	}
}
// Populates rate types based on selected rate category
function changeRateType() {
	var catSel = document.getElementsByName("smtLoanCat");
	catSel = catSel[0];
	var typeSel = document.getElementsByName("smtLoanType");
	typeSel = typeSel[0];
	
	
	// Begin loan type arrays by category  (cat[0] = Mortgage), (cat[1] = Auto), (cat[2] = home equity)
	var cat = new Array();
	cat[0] = ['30 yr Fixed Conforming','30 yr Fixed Non-Conforming','15 yr Fixed Conforming','15 yr Fixed Non-Conforming','1 yr ARM Conforming','1 yr ARM Non-Conforming','3 yr ARM Conforming','3 yr ARM Non-Conforming','5 yr ARM Conforming','5 yr ARM Non-Conforming','7 yr ARM Conforming','7 yr ARM Non-Conforming','10 yr ARM Conforming','10 yr ARM Non-Conforming'];
	cat[1] = ['36 month New Auto','48 month New Auto','60 month New Auto','48 month Used Auto'];
	cat[2] = ['10 yr Fixed HE Loan','15 yr Fixed HE Loan','HELOC $50,000 80% LTV','HELOC $50,000+ 80% LTV'];
	// End loan type arrays by category
	// Option values
	var optVal = ['mort','auto','heloan'];
	// Clear out previous options
	typeSel.options.length = 0;
	// Begin filling in new options
	var catVal = catSel.options[catSel.selectedIndex].value;
	for(var i=0;i<cat[catVal].length;i++) {
		if(i<9) {
			var increment = "0"+(i+1);
		} else {
			var increment = i+1;
		}
		typeSel.options[i] = new Option(cat[catVal][i],optVal[catVal]+increment);
	}

	// End filling in new options
}
//alert(catSel.options[catSel.selectedIndex].text);

function createLink()
{
	var form= document.forms[0];
	var loanSubmit = document.getElementById("loanTypeSubmit");
	var link = form.linkHid.value;
	link = link + '&categorySelected='+ form.smtLoanCat.value + '&typeSelected=' + form.smtLoanType.value + '&stateSelected='+ form.loanTypeState.value + '#header03'; 
	//alert('the link is ' + link);
	loanSubmit.href = link;
	return true;
}
function setDefaultValues()
{
	var form= document.forms[0];
	if (form.categHid.value != '')
	{
		form.smtLoanCat.value= form.categHid.value;
		form.smtLoanCat.onchange();
		form.smtLoanType.value= form.typeHid.value;
		form.loanTypeState.value= form.stateHid.value;
	}
}

function setDefaultIntLoanRate()
{
	var form= document.loanTypeForm;
	if (form.categHid.value != '')
	{
		form.smtLoanCat.value= form.categHid.value;
		form.smtLoanCat.onchange();
		form.smtLoanType.value= form.typeHid.value;
		form.loanTypeState.value= form.stateHid.value;
	}
}

function submit_form()
{
	document.forms[0].submit();
    return true;
}

// Added to solve styles clash between IE & Netscape
function changeStyle()
{
	var subMenu = document.getElementById("ListItem5002");
	if(subMenu!= null && navigator.appName != 'Microsoft Internet Explorer')
		subMenu.style.margin="4px 0px 4px 30px";
	
	subMenu = document.getElementById("ListItem5003");
	if(subMenu!= null && navigator.appName != 'Microsoft Internet Explorer')
		subMenu.style.margin="4px 0px 4px 0px";
}

//Start of Funtion add for request 75976-2 - Get Well
var isEquifax = false;
function printPopupWarning(winURL) {
    openPopPrint(winURL);
}
    
function setEquifax(){
	isEquifax = true;
}

function resetEquifax(){
	isEquifax = false;
}
	
function openWarning(e) {
	if(isEquifax != true) {
	    printPopupWarning('sitepage.ehtml?forward=pop_print_warning');
    }
}

function addUnloadEventHandler() {
    
	if (navigator.appName == "Netscape") {
	  window.captureEvents(Event.UNLOAD);
	  window.addEventListener('unload', openWarning, false);
	}
	
    window.attachEvent('onunload', openWarning);
}

function addLinkClickEventHandler() {
	
	if (navigator.appName == "Netscape") {
	  document.captureEvents(Event.CLICK);
	}

	var numLinks = document.links.length;
	
	for(i = 0; i < numLinks; i++) {
		if (navigator.appName == "Netscape") {
	        document.links[i].addEventListener('click', onLinkClickEvent, false);
		} else {
		    document.links[i].attachEvent('onclick', onLinkClickEvent);
		}
	}
}

function addFormSubmitEventHandler() {
	
	
	if (navigator.appName == "Netscape") {
	  document.captureEvents(Event.SUBMIT);
	}

	var numForms = document.forms.length;
	
	for(i = 0; i < numForms; i++) {
		if (navigator.appName == "Netscape") {
		    document.forms[i].addEventListener('submit', onFormSubmitEvent, false);
		} else {
		    document.forms[i].attachEvent('onsubmit', onFormSubmitEvent);
		}
	}
}

function onLinkClickEvent(e) {
    var target = '';
    var tparent = '';
    if (navigator.appName == "Microsoft Internet Explorer"){
        target = target + event.srcElement;
        tparent = tparent + event.srcElement.parentNode;
    } else {
        target = target +  e.target;
        tparent = tparent + e.target.parentNode;
    }


    if((target.indexOf('.ehtml') >= 0) || (tparent.indexOf('javascript') >= 0) ||
        (tparent.indexOf('.ehtml') >= 0)) {
	    setEquifax();
    } else {
        resetEquifax();
    }    
}

function onFormSubmitEvent(e) {
    setEquifax();
}

function addPopupEventHandlers() {
    addLinkClickEventHandler();
    addFormSubmitEventHandler();
    addUnloadEventHandler();
}
//End of Funtion add for request 75976-2 - Get Well