function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



//--------------------------------------------------------------
// Common helper functions to determine browser compatability
function isCSS() { return ( (document.body && document.body.style) ? true : false ); }
function isW3C() { return ( (isCSS && document.getElementById) ? true : false ); }
function isIE()  { return ( (isCSS && document.all) ? true : false ); }
function isNS4() { return ( (document.layers) ? true : false ); }
//--------------------------------------------------------------

//--------------------------------------------------------------
// Convert object name string or object reference into a 
// valid element object reference
function getObject(obj) {
	var theObj;
	if (typeof obj == "string") {
		if (isW3C) {
			theObj = document.getElementById(obj);
			if( !theObj ) { theObj = document.getElementByName(obj); }
		}
		else if (isIE) {
			theObj = document.all[obj];
		}
		else if (isNS4) {
			theObj = document.layers[obj];
		}
	} 
	else {
		// pass through object reference
		theObj = obj;
	}
	return theObj;
}
//--------------------------------------------------------------

//--------------------------------------------------------------
// Convert object name string or object reference into a 
// valid style for modifying style properties (ie. visibility)
function getObjectStyle(obj) {
	var theObj = getObject(obj);
	if (theObj && isCSS) { theObj = theObj.style; }
	return theObj;
}
//--------------------------------------------------------------

//--------------------------------------------------------------
// Set the visibility of an object to visible
function show(obj) {
	var theObj = getObjectStyle(obj);
	if (theObj) {
		theObj.visibility = "visible";
		theObj.display = "block";
	}
}
// Set the visibility of an object to hidden
function hide(obj) {
	var theObj = getObjectStyle(obj);
	if (theObj) {
		theObj.visibility = "hidden";
		theObj.display = "none";
	}
}
//--------------------------------------------------------------

//--------------------------------------------------------------
// Capture Enter keypress and click the appropriate button.
// Only works with MS Internet Explorer.
function CheckEnterKey( buttonToClick ) {
	if (isIE) {
		//if ( document.all && event.keyCode == 13 ) {
		if ( event.keyCode == 13 ) {
			event.cancelBubble = true;
			event.returnValue = false;
			var objButton = getObject( buttonToClick );
			if ( objButton ) {
				objButton.focus();
				objButton.click();
			}
		}
	}
}
// Capture Enter keypress and prevent anything from happening.
function StopEnterKey() {
	if (isIE) {
		if ( event.keyCode == 13 ) {
			event.cancelBubble = true;
			event.returnValue = false;
		}
	}
}

//--------------------------------------------------------------
// Open a new window
function winopen(url, title, width, height) {
	window.open(url, title, 'width='+width+',height='+height+',scrollbars=yes,resizable=yes');
}
//--------------------------------------------------------------

//--------------------------------------------------------------
// Hides the Waiting Screen if it exists
function HideWaitMsg() {
	if (isCSS) { document.body.style.cursor='default'; }
	hide( 'waitScreen' );
	hide( 'wsShim' ); // Used for IE-specific
}
// Show the Waiting Screen if it exists
function ShowWaitMsg() {
	if (isCSS) { document.body.style.cursor='wait'; }
	show( 'waitScreen' );
	show( 'wsShim' ); // Used for IE-specific
	
	// Center the Waiting Screen
	getObjectStyle('waitScreen').pixelTop=(document.body.clientHeight/2)-(getObject('waitScreen').offsetHeight/2)+(document.body.scrollTop);
	getObjectStyle('waitScreen').pixelLeft=(document.body.clientWidth/2)-(getObject('waitScreen').offsetWidth/2)+(document.body.scrollLeft);
	getObjectStyle('wsShim').pixelTop=(document.body.clientHeight/2)-(getObject('wsShim').offsetHeight/2)+(document.body.scrollTop);
	getObjectStyle('wsShim').pixelLeft=(document.body.clientWidth/2)-(getObject('wsShim').offsetWidth/2)+(document.body.scrollLeft);
}
//--------------------------------------------------------------
