// POP UP
function popUp(url, width, height, windowName, ypos, xpos, scrollbars) { 
	params = "toolbar=0,";
	params += "location=0,";
	params += "directories=0,";
	params += "status=0,";
	params += "menubar=0,";
	params += "resizable=1,"; 
	
	params += "width="+width+",";
	params += "height="+height;
	if (xpos != null) { params += ",screenX="+xpos; }
	if (ypos != null) { params += ",screenY="+ypos; }
	if (scrollbars != null) 
	{ 
		params += ",scrollbars=" + scrollbars; 
	} else {
		params += ",scrollbars=yes";
	}
	win = window.open(url, windowName, params);
	//win.target =  windowName;
	win.opener.name = "opener";
	win.focus();
}

//pop screen shot gallery-fixed width to 725x600
function SSpopUp(url, windowName, scrollbars) { 
	params = "toolbar=0,";
	params += "location=0,";
	params += "directories=0,";
	params += "status=0,";
	params += "menubar=0,";
	params += "resizable=1,"; 

	if (scrollbars != null) 
	{ 
		params += ",scrollbars=" + scrollbars; 
	} else {
		params += ",scrollbars=yes";
	}
	win = window.open(url, windowName, "width=725,height=660,"+params);
	//win.target =  windowName;
	win.opener.name = "opener";
	win.focus();
}

// POP UP with headers
function popUpHeaders(url, width, height, windowName, ypos, xpos, scrollbars) { 
	params = "toolbar=1,";
	params += "location=1,";
	params += "directories=0,";
	params += "status=1,";
	params += "menubar=1,";
	params += "resizable=1,"; 
	
	params += "width="+width+",";
	params += "height="+height;
	if (xpos != null) { params += ",screenX="+xpos; }
	if (ypos != null) { params += ",screenY="+ypos; }
	if (scrollbars != null) 
	{ 
		params += ",scrollbars=" + scrollbars; 
	} else {
		params += ",scrollbars=yes";
	}
	win = window.open(url, windowName, params);
	//win.target =  windowName;
	win.opener.name = "opener";
	win.focus();
}




//OBJECT REFERENCES

//getObj: returns a browser-independent object reference
function getObj(sObj) 
{
	var theObj;
	if (typeof sObj == "string")
	{
		if (mBrowser.isNS6plus || mBrowser.isIE6plus || mBrowser.isDOM1)
		{
			theObj = document.getElementById(sObj);
		}
		else if (mBrowser.isIE)
		{
			theObj = eval("document." + mBrowser.col1 + sObj);
		}
		else if (mBrowser.isNS4)
		{
			//check the images in this layer
			theObj = getImage(window,sObj);
			if (theObj)
			{
				return theObj;
			}
			
			//check the forms in this layer
			theObj = getFormOrElement(window,sObj);
			if (theObj)
			{
				return theObj;
			}
				
			//check the anchors in this layer
			theObj = getAnchor(window,sObj);
			if (theObj)
			{
				return theObj;
			}	
			
			//check the layers in this layer
			var oLayers = document.layers;
			var oLayer;
			for (var i=0; i < oLayers.length; i++) 
			{
				oLayer = oLayers[i];
				theObj = checkLayer(oLayer,sObj);
				if (theObj)
				{
					return theObj;
				}
			}
			return null;
		}
	} 
	else 
	{
		theObj = sObj;
	}
	return theObj;
}

//getForm: returns a form
function getForm(sForm)
{
	var oForms = document.forms;
	var iNumForms = oForms.length;
		
	//iterate through each element in the form
	for (var i=0; i < iNumForms; i++)
	{
		var oForm = oForms[i];
		
		//look for an element that matches sElement
		if (oForm.name == sForm)
		{
			return oForm;
		}
	}
	return null;
}

//getFormElement: returns an element in a form
function getFormElement(oForm,sElement)
{
	var oElements = oForm.elements;
	var iNumElements = oElements.length;
		
	//iterate through each element in the form
	for (var i=0; i < iNumElements; i++)
	{
		var eElement = oElements[i];
		
		//look for an element that matches sElement
		if (eElement.name == sElement)
		{
			return eElement;
		}
	}
	return null;
}

//getDIVs: returns a collection of DIVs
function getDIVs() 
{
	var aDIVs;
	
	if (mBrowser.isNS4)
	{
		aDIVs = document.layers;
	} 
	if (mBrowser.isNS6 || mBrowser.isIE6plus || mBrowser.isDOM1)
	{
		aDIVs = document.getElementsByTagName("DIV");
	}
	else 
	{
		aDIVs = document.all.tags("DIV");
	}
	return aDIVs;
}


//checkLayer: iterates through layers to find an image whose name matches a value (NS only)
function checkLayer(oLayer,sObj)
{
	var theObj;
	
	//see if this layer's name matches
	if (oLayer.name == sObj)
	{
		return oLayer;
	}

	//check the images in this layer
	theObj = getImage(oLayer,sObj);
	if (theObj)
	{
		return theObj;
	}
	
	//check the anchors in this layer
	theObj = getAnchor(window,sObj);
	if (theObj)
	{
		return theObj;
	}	

	//check the forms in this layer
	theObj = getFormOrElement(window,sObj);
	if (theObj)
	{
		return theObj;
	}

	//check child layers
	var oChildLayer;
	var oChildLayers = oLayer.document.layers;
	for (var i=0; i < oChildLayers.length; i++) {
		oChildLayer = oChildLayers[i];
		theObj = checkLayer(oChildLayer,sObj);
		if (theObj)
		{
			return theObj;
		}
	}	
	return null;
}

//getImage: looks through a layer to find an image (NS only)
function getImage(oLayer,sObj)
{
	var oCollection = oLayer.document.images;
	for (var i=0; i < oCollection.length; i++) 
	{
		var eElement = oCollection[i];
		if (eElement.name == sObj)
		{
			return eElement;
		}
	}
	return null;
}

//getAnchor: looks through a layer to find an anchor (NS only)
function getAnchor(oLayer,sObj)
{
	var oCollection = oLayer.document.anchors;
	for (var i=0; i < oCollection.length; i++) 
	{
		var eElement = oCollection[i];
		if (eElement.name == sObj)
		{
			return eElement;
		}
	}
	return null;
}

//getFormOrElement: looks through a layer to find a form or element (NS only)
function getFormOrElement(oLayer,sObj)
{
	var oCollection = oLayer.document.forms;
	var iNumForms = oCollection.length;
	
	for (var i=0; i < iNumForms; i++) 
	{
		var eElement = oCollection[i];
		if (eElement.name == sObj)
		{
			return eElement;
		}
		getFormElement(eElement,sObj);
	}
	return null;
}





//STYLE REFERENCES

//getStyleObj: creates a browser-independent reference to an object's styles
function getStyleObj(sObj) 
{
	var theObj;
	if (mBrowser.isIE)
	{
		theObj = eval("document.all['" + sObj + "']" + mBrowser.styleObj);
	}
	else if (mBrowser.isNS4)
	{
		theObj = eval("document.layers['" + sObj + "']" + mBrowser.styleObj);
	}
	else if (mBrowser.isNS6 || mBrowser.isDOM1)
	{
		theObj = getObj(sObj).style;
	}
	return theObj;
}

//setClassName: sets the classname on an element (IE only)
function setClassName(e,sClass) 
{
	if (!mBrowser.isNS4)
	{
		e.className = sClass;
	}
}

//getClassName: returns the classname of an element (IE only)
function getClassName(e) 
{	
	if (!mBrowser.isNS4)
	{
		//return the HTML element's class name if it contains one. Otherwise return null.
		if (eSrc.className != null) {
			return eSrc.className;
		} else {
			return null;
		}
	}
}



//OBJECT OFFSETS & SIZES

//getOffset: calculates an element's absolute offset on the page
function getOffset(eStart,sDirection) 
{
	var oStart = getObj(eStart);
	var iOffset = 0;
	
	if (!mBrowser.isNS4)
	{
		var bRecurse = true;
		var eTarget = oStart;
			
		//initializes the offset based on the direction
		switch (sDirection) 
		{
			case "left":
				iOffset = oStart.offsetLeft;
				break;
			case "top":
				iOffset = oStart.offsetTop;
				break;
		}			
		while (bRecurse) 
		{
			if (eTarget.offsetParent) 
			{
				eTarget = eTarget.offsetParent;
			} 
			else 
			{
				bRecurse = false;
				break;
			}
			switch (eTarget.tagName) 
			{
				//stop when the BODY tag is reached
				case "BODY":
					bRecurse = false;
					break;
				default:
					//increment the offset
					switch (sDirection) 
					{
						case "left":
							iOffset = iOffset + eTarget.offsetLeft;
							break;
						case "top":
							iOffset = iOffset + eTarget.offsetTop;
							break;
					}			
					break;
			}
		}
	}
	else
	{
		var sObj = oStart.name;
		
		//check the images in this layer
		theObj = getImage(window,sObj);
		if (theObj)
		{
			switch (sDirection) 
			{
				case "left":
					return theObj.x;
					break;
				case "top":
					return theObj.y;
					break;
			}			
		}
		
		//check the anchors in this layer
		theObj = getAnchor(window,sObj);
		if (theObj)
		{
			switch (sDirection) 
			{
				case "left":
					return theObj.x;
					break;
				case "top":
					return theObj.y;
					break;
			}			
		}
		
		//check the layers in this layer
		var oLayers = document.layers;
		var oLayer;
		for (var i=0; i < oLayers.length; i++) 
		{
			oLayer = oLayers[i];
			iLayerOffset = getLayerOffset(oLayer,sObj,sDirection);
			if (iLayerOffset)
			{
				iOffset += iLayerOffset;
			}
		}
		return iOffset;
	}
	return iOffset;
}

//getLayerOffset: determines an element's offset within a layer (NS only)
function getLayerOffset(oLayer,sObj,sDirection)
{
	var iOffset = 0;
	
	//check the images in this layer
	theObj = getImage(oLayer,sObj);
	if (theObj)
	{
		switch (sDirection) 
		{
			case "left":
				return theObj.x + oLayer.pageX;
				break;
			case "top":
				return theObj.y + oLayer.pageY;
				break;
		}			
	}

	//see if this layer's name matches
	if (oLayer.name == sObj)
	{
		switch (sDirection) 
		{
			case "left":
				return oLayer.pageX;
				break;
			case "top":
				return oLayer.pageY;
				break;
		}			
	}

	//check child layers
	var oChildLayer;
	var oChildLayers = oLayer.document.layers;
	for (var i=0; i < oChildLayers.length; i++) 
	{
		oChildLayer = oChildLayers[i];
		var iLayerOffset = getLayerOffset(oChildLayer,sObj,sDirection);
		if (iLayerOffset)
		{
			switch (sDirection) 
			{
				case "left":
					iOffset += oLayer.pageX;
					break;
				case "top":
					iOffset += oLayer.pageY;
					break;
			}			
			return iOffset + iLayerOffset;
		}
	}	
	return null;
}

//getWidth: x-browser width of an object
function getWidth(oElement,sType)
{
	oElement = getObj(oElement);
	var iWidth;
	
	if (mBrowser.isIE)
	{
		if (mBrowser.isIE4)
		{
			iWidth = oElement.style.posWidth;
		}
		else
		{
			iWidth = oElement.offsetWidth;
		}
	}
	else if (mBrowser.isNS4)
	{
		if (sType == "Img")
		{
			iWidth = oElement.width;
		}
		else
		{
			iWidth = oElement.clip.width;
		}
	}
	else if (mBrowser.isNS6 || mBrowser.isDOM1)
	{
		if (sType == "Img")
		{
			iWidth = oElement.width;
		}
		else
		{
			iWidth = parseInt(oElement.offsetWidth);
		}
	}
	return iWidth;
}

//setWidth: sets the x-browser width of an object
function setWidth(oElement,iWidth)
{
	oElement = getObj(oElement);
	if (mBrowser.isNS4)
	{
		oElement.clip.width = iWidth;
	}
	else if (mBrowser.isIE)
	{
		oElement.style.posWidth = iWidth;
	}
	else if (mBrowser.isNS6 || mBrowser.isDOM1)
	{
		oElement.style.width = iWidth + "px";
	}
	return iWidth;
}

//getHeight: x-browser height of an object
function getHeight(oElement,sType)
{
	oElement = getObj(oElement);
	var iHeight;
	
	if (mBrowser.isIE)
	{
		if (mBrowser.isIE4)
		{
			iHeight = oElement.style.posHeight;
		}
		else
		{
			iHeight = oElement.offsetHeight;
		}
	}
	else if (mBrowser.isNS4)
	{
		if (sType == "Img")
		{
			iHeight = oElement.height;
		}
		else
		{
			iHeight = oElement.clip.height;
		}
	}
	else if (mBrowser.isNS6 || mBrowser.isDOM1)
	{
		if (sType == "Img")
		{
			iHeight = oElement.height;
		}
		else
		{
			iHeight = parseInt(oElement.offsetHeight);
		}
	}
	return iHeight;
}

//setHeight: sets the x-browser height of an object
function setHeight(oElement,iHeight)
{
	oElement = getObj(oElement);
	if (mBrowser.isNS4)
	{
		oElement.clip.height = iHeight;
	}
	else if (mBrowser.isIE)
	{
		oElement.style.posHeight = iHeight;
	}
	else if (mBrowser.isNS6 || mBrowser.isDOM1)
	{
		oElement.style.height = iHeight + "px";
	}
	return iHeight;
}

//getTop: x-browser height of an object
function getTop(oElement)
{
	var iTop;
	
	if (mBrowser.isNS4)
	{
		iTop = getOffset(oElement,"top");
	}
	else
	{
		iTop = getOffset(oElement,"top");
	}
	return iTop;
}

//getLeft: x-browser left of an object
function getLeft(oElement)
{
	var iLeft = getOffset(oElement,"left");
	return iLeft;
}



