
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) { //v3.0
  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); 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];}
}

function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function SwitchColor(objname,thiscolor){
	var theObj;
	if (document.all) {
		// if it's IE...
		// get object
		theObj = eval('document.all.' + objname + '.style');
		// change color
		theObj.backgroundColor = thiscolor;
	} else {
		// for not IE, check to see if old NS
		if (document.layers) {
			// this is old NS
			// get object
			theObj = eval('document.' + objname);
			// change color
			theObj.backgroundColor = thiscolor;
		} else {
			// check to see if uses new DOM, like new Mozillas (Firefox, NS, and Mozilla)
			// note: this check assumes that objname refers to a valid id in the document
			if (document.getElementById(objname)) {
				// it does
				// get object
				theObj = document.getElementById(objname);
				// change color
				theObj.style.backgroundColor = thiscolor;
			}
		}
	}
}

function MakeDark(objname,thecolor){
	//var thecolor = "#ffffff";
	SwitchColor(objname,thecolor);
}

function MakeLight(objname,thecolor){
	//var thecolor = "#e6e6e6";
	SwitchColor(objname,thecolor);
}

// determine browser support
pop_ns4 = (document.layers)?true:false
pop_dom = (document.all)?true:false

var pop_collection="";
var pop_styleObj="";
if (pop_dom) {
	pop_collection="all.";
	pop_styleObj=".style";
	//document.write("dom is true<br>");
}

if (pop_ns4) {
	//document.write("ns4 is true<br>");
}

function GetObject(objname) {
	var theObj;
	if (pop_ns4 || pop_dom) {
		theObj= eval("document." + pop_collection + objname);
	} else {
		if (document.getElementById(objname)) {
			theObj = document.getElementById(objname);
		}
		
	}
	return theObj;
}

function SwitchHTML(thisguy,newhtml){
	thisobj = GetObject(thisguy);
	//if(document.all &&! window.opera) {
	//	thisobj.filters.revealTrans.apply();
	//}
	thisobj.innerHTML = newhtml;
	//if(document.all &&! window.opera) {
	//	thisobj.filters.revealTrans.play();
	//}
}

function SwitchDivs(objnameone,objnametwo) {
	HideDiv(objnameone); 
	ShowDiv(objnametwo); 
}

function HideDiv(objname) {
	var divHide = GetObject(objname); 
	SlideObjOpacity(objname, 100, 0, 2);
	divHide.style.display = 'none';
	ChangeObjOpacity(objname, 100);
}

function ShowDiv(objname) {
	var divShow = GetObject(objname); 
	ChangeObjOpacity(objname, 0);
	divShow.style.display = 'block';
	SlideObjOpacity(objname, 0, 100, 5);
}

function URLEncodeString(inString) { 
	var outString = escape(inString); 
	outString = outString.replace('+', '%2B'); 
	outString = outString.replace('/', '%2F');  
	return outString; 
}

function SlideObjOpacity(inObjName, inStartOpacity, inEndOpacity, inSlideFrameTime) {
	// initialize frame count
	var thisFrame = 0;
	
	// figure out if we're going up or down
	if (inStartOpacity < inEndOpacity) {
		for (var s = inStartOpacity; s <= inEndOpacity; s++) {
			setTimeout('ChangeObjOpacity(\'' + inObjName +'\', ' + s + ');', (thisFrame * inSlideFrameTime));
			thisFrame++;
		}
	}
	else if (inStartOpacity > inStartOpacity) {
		for (var s = inStartOpacity; s <= inEndOpacity; s--) {
			setTimeout('ChangeObjOpacity(\'' + inObjName +'\', ' + s + ');', (thisFrame * inSlideFrameTime));
			thisFrame++;
		}
	}
	else {
		// do nothing
	}
}

function ChangeObjOpacity(inObjName, inOpacity) {
	var theObj = GetObject(inObjName);
	
	theObj.style.filter = 'alpha(opacity=' + inOpacity +')';
	theObj.style.MozOpacity = (inOpacity / 100);
	theObj.style.KhtmlOpacity = (inOpacity / 100);
	theObj.style.opacity = (inOpacity / 100);
}

function LoadScript(theSource,theChildName) {
	// function takes the input src url and creats a new script element that loads it
	var scriptChild = document.createElement('script');
	scriptChild.src = theSource;
	scriptChild.type='text/javascript';
	if (typeof theChildName != 'undefined') {
		scriptChild.name = theChildName;
		scriptChild.id = theChildName;
	}
	document.getElementsByTagName('head')[0].appendChild(scriptChild);
}

function RemoveScript(theChildName) {
	var scriptChild = GetObject(theChildName);
	if (typeof scriptChild != 'undefined') {
		document.getElementsByTagName('head')[0].removeChild(scriptChild);
	}
}

function AlignObject(objName, leftAlignObjName, topAlignObjName) {
	var leftAlignObj = GetObject(leftAlignObjName);
	var leftVal = returnPosXofObj(leftAlignObj); 
	var topAlignObj = GetObject(topAlignObjName);
	var topVal = returnPosYofObj(topAlignObj);
	MoveObject(objName, leftVal, topVal);
}

function MoveObject(objName, theLeftVal, theTopVal) {
	var theObj = GetObject(objName);
	theObj.style.position = 'absolute';
	ShowMenu(objName,theLeftVal,theTopVal);
}


function blend(theObj) {
	//if(document.all &&! window.opera) {
	//	theObj.filters.revealTrans.apply(); 
	//	theObj.filters.revealTrans.play(); 
	//} 
} 

function returnPosYofObj(obj) {
	var objtop = 0;
	// check to see if obj has a container
	if(obj.offsetParent)
	while(1) {
		objtop += obj.offsetTop;
		// if there is no further container, get out of while
		if(!obj.offsetParent)
			break;
		obj = obj.offsetParent;
	}
	else if(obj.y)
		objtop += obj.y;
	return objtop;
}

function returnPosXofObj(obj) {
	var objleft = 0;
	// check to see if obj has a container
	if(obj.offsetParent)
	while(1) {
		objleft += obj.offsetLeft;
		// if there is no further container, get out of while
		if(!obj.offsetParent)
			break;
		obj = obj.offsetParent;
	}
	else if(obj.x)
		objleft += obj.x;
	return objleft;
}

function returnCurrentWindowYOffset() {
	if (document.all) {
		// if it's IE...
		return document.body.scrollTop;
	} else {
		return window.pageYOffset;
	}
}

function returnCurrentWindowXOffset() {
	if (document.all) {
		// if it's IE...
		return document.body.scrollLeft;
	} else {
		return window.pageXOffset;
	}
}

function ShowMenu(objname,xVal,yVal,doOpacitySlide) {
	//alert(objname);
	// function gets the object name, then conditionally grabs the object and moves its x,y coords to where we want them
	var theObj = GetObject(objname);
	var slideOpacity = true;
	if (doOpacitySlide != null) {
		slideOpacity = doOpacitySlide;
	}
	if (document.all) {
		// if it's IE...
		if (returnPosXofObj(theObj) == xVal && returnPosYofObj(theObj) == yVal){
			// do nothing
		}
		else {
			// change opacity to 0
			if (slideOpacity) {
				ChangeObjOpacity(objname, 0);
			}
			// move it
			theObj.style.pixelLeft = xVal;
			theObj.style.pixelTop = yVal;
			// slide opacity from 0 to 100
			if (slideOpacity) {
				SlideObjOpacity(objname, 0, 90, 2);
			}
		}
	} else {
		// for not IE, check to see if old NS
		if (document.layers) {
			// this is old NS
			if (returnPosXofObj(theObj) == xVal && returnPosYofObj(theObj) == yVal){
				// do nothing
			}
			else {
				// change opacity to 0
				if (slideOpacity) {
					ChangeObjOpacity(objname, 0);
				}
				// move it
				theObj.left = xVal;
				theObj.top = yVal;
				// slide opacity from 0 to 100
				if (slideOpacity) {
					SlideObjOpacity(objname, 0, 90, 2);
				}
			}
		} else {
			// check to see if uses new DOM, like new Mozillas (Firefox, NS, and Mozilla)
			// note: this check assumes that objname refers to a valid id in the document
			if (document.getElementById(objname)) {
				// it does
				if (returnPosXofObj(theObj) == xVal && returnPosYofObj(theObj) == yVal){
					// do nothing
				}
				else {
					// change opacity to 0
					if (slideOpacity) {
						ChangeObjOpacity(objname, 0);
					}
					// move it
					theObj.style.left = xVal;
					theObj.style.top = yVal;
					// slide opacity from 0 to 100
					if (slideOpacity) {
						SlideObjOpacity(objname, 0, 90, 2);
					}
				}
			}
		}
	}
}

function PrintActiveContent(objname, inHTML){
	// THIS FUNCTION ASSUMES THE GetObject FUNCTION IS AVAILABLE
	var myActiveObj = GetObject(objname);
	if (typeof myActiveObj != 'undefined') {
		myActiveObj.innerHTML = inHTML;
	}
}

