var imgOut = new Array();
var imgAlt = new Array();

// Sets up the page
function setupPage() {
	// Loop through all links
	var siteLinks = window.document.getElementsByTagName('a');
	for (var i=0; i < siteLinks.length; i++) {
		// Set up navigation options
		
		if (siteLinks[i].id != 'jobsearch')
		{
  			if (siteLinks[i].className == 'navImg') 
			{
				siteLinks[i].onmouseover = rollOver;
				siteLinks[i].onmouseout  = rollOver;
				siteLinks[i].onfocus	 = rollOver;
				siteLinks[i].onblur	     = rollOver;

				imgOut[siteLinks[i].id] = window.document.images['img_' + siteLinks[i].id].src;
		   	}
		}

		// Set up external links
  		if (siteLinks[i].rel == 'external') {
			siteLinks[i].target = '_blank';
	   	}
	}
}


// Does the actual image rollover
function rollOver(e) {
	if (!e) var e = window.event;

	if (typeof(imgAlt) == 'undefined' || typeof(imgOut) == 'undefined') {
		return;
	}

	if (e.type == 'mouseover' || e.type == 'focus' && typeof(imgAlt[this.id]) != 'undefined') {
		window.document.images['img_' + this.id].src = 'images/nav/' + imgAlt[this.id];
	}
	else if (e.type == 'mouseout' || e.type == 'blur' && typeof(imgOut[this.id]) != 'undefined') {
		window.document.images['img_' + this.id].src = imgOut[this.id];
	}
}


function hideSub() 
{
	themenu = document.getElementById("subnavbar");
	themenu.style.display = 'none';
	
	theaddress = document.getElementById("address");
	theaddress.style.left = '420px';

	theaddressnudge = document.getElementById("address-nudge");
	theaddressnudeg.style.left = '420px';	
}


function showSub() 
{
	themenu = document.getElementById("subnavbar");
	themenu.style.display = 'block';

	theaddress = document.getElementById("address");
	theaddress.style.left = '540px';

	theaddressnudge = document.getElementById("address-nudge");
	theaddressnudeg.style.left = '540px';	
}


// Check to make sure the users browser supports images
if (window.document.images) {	
	imgAlt['home'] = 'harp-nav-home-over.gif';
	imgAlt['candidates'] = 'harp-nav-cand-over.gif';
	imgAlt['jobsearch'] = 'harp-nav-j-search-over.gif';
	imgAlt['clients'] = 'harp-nav-clients-over.gif';
	imgAlt['useful'] = 'harp-nav-u-links-over.gif';
	imgAlt['contact'] = 'harp-nav-contact-over.gif';
	imgAlt['workfor'] = 'harp-nav-wfu-over.gif';
	imgAlt['permanent'] = 'harp-nav2-perm-over.gif';
	imgAlt['temporary'] = 'harp-nav2-temp-over.gif';

	for (var item in imgAlt) {
		new Image().src = 'images/nav/' + imgAlt[item];
	}

	window.onload = setupPage;
}

// Break out of frames
if (window.top.location != window.document.location) {
	window.top.location.href = window.document.location.href;
}