// SOM sitewide JavaScripts
// alert('this page is including:/res/scripts/sitewide.js');


// image rollover functionality - modified version of macromedia scripts
/*
EXAMPLE IMAGE ROLLOVER
<a href="#" onMouseOut="EN_swapImgRestore()" onMouseOver="EN_swapImage('image_lo','','image_hi.gif',0)"><img name="image_lo" border="0" src="image_lo.gif"></a>
*/

function EN_swapImgRestore() { //v3.0
  var i,x,a=document.EN_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function EN_findObj(n, d) { //v4.01
  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=EN_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function EN_swapImage() { //v3.0
  var i,j=0,x,a=EN_swapImage.arguments; document.EN_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=EN_findObj(a[i]))!=null){document.EN_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// quickIndex functionality 
function doQuickIndex(){
	if (siteToolForm.quickIndex.value != '')
	{
		document.location.href = siteToolForm.quickIndex.value;
	}
}

function doSiteSearch(_default)
{
	if (siteToolForm.coSiteSearch_term.value == '' || siteToolForm.coSiteSearch_term.value == _default)
	{
		alert('Please provide a search term');
	}
	else
	{
		siteToolForm.submit();
	}
}

function popupWindow(_url, _width, _height, _name)
{
	window.open(_url, _name, "status,height=" + _height + ",width=" + _width + ",scrollbars=no");
}

function somSwitchDisplayMode(_mode, _target, _action)
{
	document.somDisplayModeForm.target = _target;
	document.somDisplayModeForm.action = _action;
	document.somDisplayModeForm.displayMode.value = _mode;
	document.somDisplayModeForm.submit();
}

function clearText(thefield)
{
	if (thefield.defaultValue==thefield.value)
	thefield.value = ""
}


var gLoadFunctions = new Array();

function addOnload(func)

{
	if (!gLoadFunctions.length && window.onload)
		 gLoadFunctions[gLoadFunctions.length] = window.onload;
		 
	gLoadFunctions[gLoadFunctions.length] = func;
	window.onload = winOnLoad;
}

// The master onLoad function.
function winOnLoad()

{
	var index = 0;

	for (index = 0; index < gLoadFunctions.length; index++) {
		gLoadFunctions[index]();
	}
}
