
// Check Browser CSS Compatibility

// alert(document.compatMode);

// Supress BOM Script Errors	

function errorsuppressor(){
return true;
}

if(location.href.indexOf("localhost") == -1){

	window.onerror = errorsuppressor;

}

// Multiple Onload Utility

function addLoadEvent(func) {

	var oldonload = window.onload;

	if (typeof window.onload != 'function') {

		window.onload = func;

	} else {

		window.onload = function() {
		oldonload();
		func();

		}

	}

}

// Insert-after Function

function insertAfter(newElement, targetElement) {

var parent = targetElement.parentNode;

if (parent.lastChild == targetElement) {

	parent.appendChild(newElement);

} else {

	parent.insertBefore(newElement, targetElement.nextSibling);

	}

}

// Toggle, Show/Hide Element(s)

function toggleElement(val, obj){

	if(document.getElementById(val).style.display == "none") { 

		obj.className = "expandon";
		document.getElementById(val).style.display = "block";

	} else {

		obj.className = "expand";
		document.getElementById(val).style.display = "none";

	}

}

// Global Pop-up (parse through DOM, if viewpage class exists, append event)

function newWinLinks() {

	for (var i=0; i < document.links.length; i++) {

		if (document.links[i].className == "newwindow") {

			document.links[i].target = "_blank";

		}

		if (document.links[i].className == "viewjob") {

			document.links[i].onclick = openMyModal;

		}

		if (document.links[i].className == "viewvideo") {

			document.links[i].onclick = openMyVideo;

		}

	}

}

addLoadEvent(newWinLinks);

// Primary Nav (IE 6 only)

primarynavhover = function() {

	if (!document.getElementById) return false;
	if (!document.getElementById("primarynav")) return false;

	var listElements = document.getElementById("primarynav").getElementsByTagName("li");

	for (var i=0; i < listElements.length; i++) {

		listElements[i].onmouseover = function() {

			this.className+=" iehover";

		}

		listElements[i].onmouseout = function() {

			this.className-= this.className.replace(new RegExp(" iehover\\b"));

		}

	}

}

if (window.attachEvent) window.attachEvent("onload", primarynavhover);

function setlastnode() {

	// Set Last node - This is only a quick hack and will need to 
	// be re-written to apply to every last node of parent node...maybe. Just an FYI. -Spell

	var the_node = document.getElementById("pn-about").getElementsByTagName("li")[2];
	the_node.setAttribute("id", "news-awards");

	var the_node = document.getElementById("pn-stories").getElementsByTagName("li")[1];
	the_node.setAttribute("id", "profiles");

}

addLoadEvent(setlastnode);

function addOptionTitle() { 

// Add title attribute to all select boxes for usability

if (!document.getElementsByTagName("select")) return false;

var list = document.getElementsByTagName("select");

for(var i = 0; i < list.length; i++) {

	var option = list[i].getElementsByTagName("option")

		for(var j = 0; j < option.length; j++) {
			option[j].setAttribute("title", option[j].text);

		}

	}

}

addLoadEvent(addOptionTitle);

// Job Description Navigation Scroll

var timer;
var scrollspeed = 2;

// Element to scroll left 

function scrollleft(){

	if (document.all){

		document.all.scrollarea.scrollLeft -= scrollspeed;

	} else {

		document.getElementById("scrollarea").scrollLeft -= scrollspeed;

	}

}

function startLeftScroll(){

	timer = setInterval(scrollleft,2);

}

// Element to scroll right 

function scrollright(){

	if (document.all){

		document.all.scrollarea.scrollLeft += scrollspeed;

	} else {

		document.getElementById("scrollarea").scrollLeft += scrollspeed;

	}

}

function startRightScroll(){

	timer = setInterval(scrollright,2);

}

// Stop scroll 

function stopScroll(){

	clearInterval(timer);

}

// Append event and function to scroll buttons

function appendTickerEvent() {

	if (!document.getElementById("jobdescrip")) return false;

	var scrolllft = document.getElementById("scrolllt");
	var scrollrht = document.getElementById("scrollrt");

	scrolllft.onmouseover = function() {

		startLeftScroll();

	}

	scrolllft.onmouseout = function() {

		stopScroll();

	}

	scrollrht.onmouseover = function() {

		startRightScroll();

	}

	scrollrht.onmouseout = function() {

		stopScroll();

	}

}

addLoadEvent(appendTickerEvent);

// ****** jQuery Calls and Properties ******

/* Quick and Dirty Modal Window */

var openMyModal = function() {

		modalWindow.windowId = "jobview";
		modalWindow.width = 898;
		modalWindow.height = 557;
		modalWindow.content = "<iframe width=\"898\" height=\"537\" frameborder=\"0\" scrolling=\"no\" allowtransparency=\"true\" src=\"" + this.href + "\">&lt/iframe>";
		modalWindow.open();
		return false;

};

var openMyVideo = function() {

		modalWindow.windowId = "viewvideo";
		modalWindow.width = 434;
		modalWindow.height = 398;
		modalWindow.content = "<iframe width=\"434\" height=\"398\" frameborder=\"0\" scrolling=\"no\" allowtransparency=\"true\" src=\"" + this.href + "\">&lt/iframe>";
		modalWindow.open();
		return false;

};