// JavaScript Document

// Function for loading functions  to be excuted on window.load
function addLoadListener(fn)
{
	if (typeof window.addEventListener != 'undefined'){
		window.addEventListener('load', fn, false);
	}
	else if (typeof document.addEventListener != 'undefined'){
		document.addEventListener('load', fn, false);
	} else if (typeof window.attachEvent != 'undefined'){
		window.attachEvent('onload', fn);
	} else {
		var oldfn = window.onload;
		if(typeof window.onload != 'function'){
			window.onload = fn;
		} else {
			window.onload = function()
			{
				oldfn();
				fn;
			};
		}
	}
}

document.onclick = function(e)
{
	var target = e ? e.target : window.event.srcElement;
	while(target && !/^(a|body)$/i.test(target.nodeName))
	{
		target = target.parentNode;
	}
	
	if(target && target.getAttribute('rel') && target.rel == 'new')
	{
		var external = window.open(target.href);
		return external.closed;
	}
}

function change(id){ 
	ulList = document.getElementById('col2').getElementsByTagName('ul');
	if(document.getElementById(id).style.display == "block"){
		document.getElementById(id).style.display = "none"; 
		document.getElementById(id+'_head').className = "headLink";
	} else {	
		document.getElementById(id).style.display = "block"; 
		document.getElementById(id+'_head').className = "headLinkSelected";
	}
	for(var i=0; i < ulList.length; i++){
	 	if(id != ulList[i].id){
			document.getElementById(ulList[i].id).style.display = "none";
			document.getElementById(ulList[i].id+'_head').className = "headLink";
		}
	 }
}
function changeImage(image, alt){
	if(chkObject(false, 'previewImg')){
		var img = document.getElementById('previewImg');
		img.src = image;
		img.alt = alt;
	}
}
function size(){
	self.moveTo(0,0);
	self.resizeTo(screen.availWidth,screen.availHeight)
}

function chkObject(inParent,theVal) {
	if(inParent){
		if (window.opener.document.getElementById(theVal) != null) {
			return true;
		} else {
			return false;
		}
	} else {
		if (document.getElementById(theVal) != null) {
			return true;
		} else {
		return false;
		}
	}
}

function toggleFolio(){ 
	if(document.getElementById('folioInfo').style.display == 'none'){
		document.getElementById('folioInfo').style.display = 'block';
	} else {
		document.getElementById('folioInfo').style.display = 'none';
	}
}

function loadFlash(galID) {
	 var so = new SWFObject("SE_flash/photoGallery.swf", "sotester", "469", "524", "8", "#757440");
	 so.addParam("quality", "high");
	 so.addParam("scale", "noscale");
	 so.addParam("wmode", "transparent");
	 so.addParam("salign", "lt");
	 so.addVariable("galID", galID);
	 so.write("galleryDisplay");
}

function checkForFile(id){
	var d = document.getElementById(id).value;
	if(d.length > 0){
		alert("You have selected a resume to upload. Please note that uploading a file may take a few minutes.\nPlease do not reclick the 'submit' button once you have submitted the form.");
	}
}

function disableField(field) {
	document.getElementById(field).disabled = true;
	document.getElementById(field).value="Submitting Form...";
}

								
