function swapLogos() {
	pickLogo();
	//logoA, logoB, logoCaption
}

function init(){
	pickLogo();
	initButtons();
	//initNav();
}

function initButtons(){
	var image;
	for(var i=0; i<document.images.length; i++){
		image = document.images[i];
		if (image.className.indexOf("button") != -1){
			image.onmouseover = buttonRollOver;
			image.onmouseout = buttonRollOut;
		}
	}
}

function buttonRollOver(){
	this.origSrc = this.src;
	var path = this.src.substring(0, this.src.lastIndexOf('.'));
	var ext = this.src.substring(this.src.lastIndexOf('.'), this.src.length);
	this.src = path + "_ov" + ext;
}

function buttonRollOut(){
	this.src = this.origSrc;
}

/**
function buttonRollOver2(newImg, thisImg){
	thisImg.src = newImg;
}
***/


//var imagePath = "http://info.jobster.com/images/";
var imagePath = "images/";

var logos = new Array();
logos[0] = "logo_1.gif";
logos[1] = "logo_1.gif";
logos[2] = "logo_2.gif";
logos[3] = "logo_3.gif";
logos[4] = "logo_4.gif";


function pickLogo(){
	var num = getRandomInt(0,4);
	document.images["jobsterLogo"].src = imagePath + logos[num];
}

var quoteLogos = new Array();
quoteLogos[0] = "logo_adlergroup.gif";
quoteLogos[1] = "logo_massgeneral.gif";
quoteLogos[2] = "logo_globallearning.gif";

var quoteText = new Array();
quoteText[0] = "quote_louadler.gif";
quoteText[1] = "quote_massgeneral.gif";
quoteText[2] = "quote_globallearning.gif";

function pickQuote(){
	var num = getRandomInt(0,2);
	document.images["quoteLogo"].src = imagePath + quoteLogos[num];
	document.images["quoteText"].src = imagePath + quoteText[num];
}


function getRandomInt(min, max){
	return Math.round(Math.random()*(max-min))+min;
}

function popup(url, width, height, params){
	var winWidth = (width != null) ? width : 640;
	var winHeight = (height != null) ? height : 480;
	var winParams = "width=" + winWidth + ",height=" + winHeight;
	if (params != null){
		winParams += "," + params;
	} else {
		winParams += ",scrollbars=no";
	}
	
	var newWin = window.open(url, "demo", winParams);
	newWin.focus();
}


var currDir = null;

function showDirections(id){

	if (currDir != null && currDir != id){
		document.getElementById(currDir).style.display = "none";
	}
	currDir = id;
	document.getElementById(id).style.display = "block";

}


/*  JavaScript code for navigation */

//hide menu from Safari 1.0
var isSafari1_0 = false;

var agt = navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();

var is_safari = (agt.indexOf("safari") != -1);
var build = appVer.substring(appVer.lastIndexOf("/")+1);

if ( is_safari && build < 86) {
	isSafari1_0 = true;
}


var images = new Array();

images["navEmployers"] = new Image();
images["navEmployers"].src = "images/nav/nav_employers_up_ov.gif";
images["navJobSeekers"] = new Image();
images["navJobSeekers"].src = "images/nav/nav_jobseekers_up_ov.gif";
images["navNewsEvents"] = new Image();
images["navNewsEvents"].src = "images/nav/nav_newsEvents_up_ov.gif";
images["navCompanyInfo"] = new Image();
images["navCompanyInfo"].src = "images/nav/nav_comapnyInfo_up_ov.gif";
images["navContactUs"] = new Image();
images["navContactUs"].src = "images/nav/nav_contactUs_up_ov.gif";



var offimages = new Array();

images["navEmployers"] = new Image();
images["navEmployers"].src = "images/nav/nav_employers_up.gif";
images["navJobSeekers"] = new Image();
images["navJobSeekers"].src = "images/nav/nav_jobseekers_up.gif";
images["navNewsEvents"] = new Image();
images["navNewsEvents"].src = "images/nav/nav_newsEvents_up.gif";
images["navCompanyInfo"] = new Image();
images["navCompanyInfo"].src = "images/nav/nav_comapnyInfo_up.gif";
images["navContactUs"] = new Image();
images["navContactUs"].src = "images/nav/nav_contactUs_up.gif";


initNav = function() {

	var node;
	var subNode;
	if (document.getElementById) {
		navRoot = document.getElementById("nav");
		for (var i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=mainNavRollOver;
				node.onmouseout=mainNavRollOut;
				node.onclick=navClick;
				
				for (var j=0; j<node.childNodes.length; j++){
					subNode = node.childNodes[j];
					if (subNode.nodeName == "UL"){
						initSubNav(subNode);
					}
				}
				
			}
		}
	}

}
initSubNav  = function(subNavRoot){
	var node;
	for (var i=0; i<subNavRoot.childNodes.length; i++) {
		node = subNavRoot.childNodes[i];
		if (node.nodeName=="LI") {
			node.onmouseover=subNavRollOver;
			node.onmouseout=subNavRollOut;
			node.onclick=navClick;
		}
	}
}

function navClick(){
	var url = this.getElementsByTagName('a')[0].getAttribute("href");
	
	if (window.event){
		event.cancelBubble = true;
	}
	
	if (url.indexOf("javascript:") == -1){
		window.location = url;
	} else {
		eval(url.substring(11, url.length));
	}
}

function mainNavRollOver(){
	//change class to show subnav
	if (!isSafari1_0){
		this.className = "over";
	} else {
		this.getElementsByTagName('ul')[0].style.display = "none";
	}
	
	var navImage = this.getElementsByTagName('div')[0].getElementsByTagName('a')[0].getElementsByTagName('img')[0];
	var id = navImage.getAttribute("id");
	navImage.src = images[id].src;
	
}
function mainNavRollOut(){
	this.className="";
	
	var navImage = this.getElementsByTagName('div')[0].getElementsByTagName('a')[0].getElementsByTagName('img')[0];
	var id = navImage.getAttribute("id");
	navImage.src = offimages[id].src;
}

function subNavRollOver(){
	this.className = "over";
}
function subNavRollOut(){
	this.className = "";
}


function mainNavOver(id){
	var navItem = this.getElementById(id);
	
}


/************************************/
//toggle, show, hide
function toggle(targetId){
  if (document.getElementById){
  	var element = document.getElementById(targetId);
  	if (element.style.display == "none"){
  		show(element);
  	} 
  	else{
  		hide(element);
  	}
  }
}
function show(element){
	element.style.display = "";	
}

function hide(element){
	element.style.display = "none";
}

function showNode(nodeID){
	if (document.getElementById){		
		var element = document.getElementById(nodeID);
		element.style.display = "";
	}
}
function hideNode(nodeID){	
	if (document.getElementById){	
		var element = document.getElementById(nodeID);
		element.style.display = "none";
	}
}
/************************************/