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","img/ico_res_sma_on.gif") }
	
	iconMediumImg = document.getElementById("icon_resize_medium");
	if (iconMediumImg) { iconMediumImg.setAttribute("src","img/ico_res_med_on.gif") }
	
	iconLargeImg = document.getElementById("icon_resize_large");
	if (iconLargeImg) { iconLargeImg.setAttribute("src","img/ico_res_lar_on.gif") }
}

function setActiveIcon(title) {
	if (title == "Medium Text") {
		iconMediumImg = document.getElementById("icon_resize_medium");
		if (iconMediumImg) { iconMediumImg.setAttribute("src","img/ico_res_med.gif") }
	} else if (title == "Large Text") {
		iconLargeImg = document.getElementById("icon_resize_large");
		if (iconLargeImg) { iconLargeImg.setAttribute("src","img/ico_res_lar.gif") }
	} else {
		iconSmallImg = document.getElementById("icon_resize_small");
		if (iconSmallImg) { iconSmallImg.setAttribute("src","img/ico_res_sma.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 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('img/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 = "img/ico_res_sma.gif";
	
	image2 = new Image();
	image2.src = "img/ico_res_med.gif";
	
	image3 = new Image();
	image3.src = "img/ico_res_lar.gif";
	
	image4 = new Image();
	image4.src = "img/ico_res_sma_on.gif";
	
	image5 = new Image();
	image5.src = "img/ico_res_med_on.gif";
	
	image6 = new Image();
	image6.src = "img/ico_res_lar_on.gif";
	
	image7 = new Image();
	image7.src = "img/topnavitem_bg.gif";
	
	image8 = new Image();
	image8.src = "img/topnavitem_bg_over.gif";
	
	image9 = new Image();
	image9.src = "img/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";
	}
}

var loginInProgress = false;

function isLoginInProcess() {
	if(loginInProgress == true)
	{
		return false;
	}
	else
	{
		loginInProgress = true;
		return true;
	}
}

function resetLoginInProcess()
{
	loginInProgress = false;
}
