$(document).ready(function(){

	//check for tabbed content
	if ($("#tabBox")) {
		$("div[@id^='tabContent']").each(function(){
			$(this).addClass('tabContent');
			
			if(this.id != "tabContent1"){
				$(this).css({
					"display": "none"
				})
				
			}
		})
			
	}

	//Set external links to open in new windows
	$("a.external").each(function(){
		$(this).click(function(){
			
			popCustom($(this)[0].href, 'external','');
			return false;
		})
		
	})
	
	//Set popup links to open in new windows
	$("a.popup").each(function(){
		$(this).click(function(){
			
			pop($(this)[0].href, 'popup','');
			return false;
		})
		
	})
	
	//Set external image links to open in new windows
	$("img.external").each(function(){
		$(this).click(function(){
			
			popCustom($(this)[0].href, 'external','width=800,height=600,status=yes');
			return false;
		})
		
	})

});

function giscareer(career_id)
{
careerlink = "http://www.virtualjobshadow.com/frame/vjs_frm.asp?career_id=" + career_id +"&aff_id=esriiol93sk93sk39243";
mywin = window.open(careerlink,'myWindow','width=790,height=549,scrollbars=no,status=yes');
mywin.focus();
} 

function pop(URL, name) {
	bWindow = window.open(URL, name,"status=0,menubar=0,width=620,height=542");
} 

function popCustom(URL,name,options) {
	bWindow = window.open(URL,name,options);
} 
//use this to collapse/expand lists
function toggle(thisList){
	if (document.getElementById(thisList).style.display =="") {
		document.getElementById(thisList).style.display = "block";
		document.getElementById(thisList + "arrow").className = "selectedCategory";
	} else {
		document.getElementById(thisList).style.display ="";
		document.getElementById(thisList + "arrow").className = "arrow";
	}
}

//use this to "show" or "hide" all the things on a collapsable list, at the same time, currently used by the FAQ
tagState = "hidden";
function toggleAllTag(tagname) {
	tagArray = document.getElementsByTagName(tagname); // produces an array of all objects in the page that are the tag you requested
	for (i = 0; i < tagArray.length; i ++) {
		if (tagState == "hidden") {
			document.getElementById(tagArray[i].id).style.display = "block";
			document.getElementById(tagArray[i].id + "arrow").className = "selectedCategory";
		} else {
			document.getElementById(tagArray[i].id).style.display ="";
			document.getElementById(tagArray[i].id + "arrow").className = "arrow";
		}
	}
	tagState = (tagState == "hidden") ? "visible" : "hidden";
} 
//initialize a multi-collapsible list
function collapsibleList(listname){
	this.tagState = "hidden";
	this.listName = listname;
} 

//use this to "show" or "hide" all the things on a collapsable list without affecting another collapsible list on the page
function toggleAllTagMulti(tagname, baseName) {
	tagArray = document.getElementById(baseName.listName).getElementsByTagName(tagname); // produces an array of all objects in the page that are the tag you requested
	for (i = 0; i < tagArray.length; i ++) {
		if (baseName.tagState == "hidden") {
			document.getElementById(tagArray[i].id).style.display = "block";
			document.getElementById(tagArray[i].id + "arrow").className = "selectedCategory";
		} else {
			document.getElementById(tagArray[i].id).style.display ="";
			document.getElementById(tagArray[i].id + "arrow").className = "arrow";
		}
	}
	baseName.tagState = (baseName.tagState == "hidden") ? "visible" : "hidden";
} 

function tabBox(tabToShow, totalTabs){
	// start by hiding any displayed tab content and unselecting all tabs
	for (var i = 1; i <= totalTabs; i ++){
		var tmpTab = "tab" + i;
		var tmpContent = "tabContent" + i;
		document.getElementById(tmpTab).className = "";
		document.getElementById(tmpContent).style.display = "none";
	}
	
	//display the selected tab and contents
	tmpTab = "tab" + tabToShow;
	tmpContent = "tabContent" + tabToShow;
	document.getElementById(tmpTab).className = "selected";
	document.getElementById(tmpContent).style.display = "block";
} 
