/* This was moved from inline on template 20100608 tww - why it was there, I don't know, but it was breaking the automated PCI scans */


function swapStyle(id,classLabel)
{
	if(document.getElementById(id))
	{
		ChangedElement = document.getElementById(id);
		ChangedElement.className = classLabel;
	}
}

/* Required by formProcess.php */
function UpdateFileUpload(fieldid,fileFieldVal)
{
	document.uniForm[fieldid].value = fileFieldVal;
}

/* Image Preloader */
function preloadImages()
{
	var d=document; if(d.images){ if(!d.p) d.p=new Array();
	var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

/* Find Element on Page */
function findObj(n, d)
{
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}

/* Mouseover Function */
function swapImage()
{
	var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/* Mouseover Function: Restore */
function swapImgRestore()
{
	var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

/* Popup Window */
function spawnWindow(theURL,winName,features,posX,posY)
{
	myWindow=window.open(theURL,winName,features);
	if (!myWindow.opener) myWindow.opener = self;
	myWindow.focus();
	if(posX || posY)
	{
		myWindow.moveTo(posX,posY);
	}
}

/* Get Window Size */
function getWinSize()
{
	if ((document.layers||document.getElementById)&&(!document.all))
	{
		winWidth = innerWidth;
		winHeight = innerHeight;
	}
	if (document.all)
	{
		winWidth = document.body.clientWidth;
		winHeight = document.body.clientHeight-3;
	}
}

/* Mmmm... Coookies! */
function setCookie(name, value, expires, path, domain, secure)
{
	var curCookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
	document.cookie = curCookie;
}
function getCookie(name)
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1)
	{
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	}
	else
	{
		begin += 2;
		var end = document.cookie.indexOf(";", begin);
		if (end == -1)
		end = dc.length;
		return unescape(dc.substring(begin + prefix.length, end));
	}
}
function deleteCookie(name, path, domain)
{
	if (getCookie(name))
	{
		document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

highZ = 1;

function showHide(el,showonly,hideonly)
{
	var elObj = document.getElementById(el);
	if(elObj.style.display == "none")
	{
		elObj.style.display = "";
		highZ++;
		elObj.style.zIndex = highZ;
	}
	else
	{
		elObj.style.display = "none";
	}
	if(showonly)
	{
		elObj.style.display = "";
		highZ++;
		elObj.style.zIndex = highZ;
	}
	if(hideonly)
	{
		elObj.style.display = "none";
	}
}

/* Event Listeners & Ident */
function addEvent(obj, evType, fn)
{
	if (obj.addEventListener)
	{
		obj.addEventListener(evType, fn, false);
		return true;
	}
	else if (obj.attachEvent)
	{
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	}
	else
	{
		return false;
	}
}

var NavMenus = new Array();
var LastViewed = '';

function ShowNav(picked)
{
	var ShowMe = document.getElementById(picked);
	for (i=0;i<NavMenus.length;i++)
	{
		if (document.getElementById(NavMenus[i]).style.display != 'none' && NavMenus[i] != picked)
		{
			document.getElementById(NavMenus[i]).style.display = 'none';
		}
	}
	if (LastViewed != picked)
	{
		ShowMe.style.display = 'inline';
	}
	clearInterval(checkOpen);
}

function HideNav()
{
	for (i=0;i<NavMenus.length;i++)
	{
		document.getElementById(NavMenus[i]).style.display = 'none';
	}
	clearInterval(checkOpen);
}


function whatClicked(obj)
{
	var targ
	if(!obj)
	{
		var obj = window.event
	}
	if(obj.target)
	{
		targ = obj.target
	}
	else if(obj.srcElement)
	{
		targ = obj.srcElement
	}
	if (targ.nodeType == 3)
	{
		targ = targ.parentNode
	}
	/* Tables with no ID - Try Parent TR */
	if(targ.tagName == 'TD' && targ.id == '')
	{
		targ = targ.parentNode
	}
	var result = new Array();
	result[0] = targ.tagName;
	result[1] = targ.id;
	if(targ.getAttribute('rel'))
	{
		result[2] = targ.getAttribute('rel');
	}
	if(targ.getAttribute('tt'))
	{
		result[3] = targ.getAttribute('tt');
	}
	return result;
}


var elObj = false;
var elID = false;
var elRel = false;
var checkOpen = false;

function menuMouseActions(event)
{
	click = whatClicked(event);

	elObj = click[0];
	elID = click[1];
	elRel = click[2];

	if(elID.substring(0,2) == 'sN' || elID.substring(0,2) == 'mN')
	{
		clearInterval(checkOpen);
	} else {
		clearInterval(checkOpen);
		checkOpen = setInterval('HideNav()',1500);
	}
	return elID;
}
