/*Use Object Detection to detect IE6*/
    
	var the_popupname;	// used for "click away hide" functionality	
				    
    var  m = document.uniqueID /*IE*/
    && document.compatMode  /*>=IE6*/
    && !window.XMLHttpRequest /*<=IE6*/
    && document.execCommand;
    
    try{
        if(!!m){
            m("BackgroundImageCache", false, true) /* = IE6 only */
        }
        
    }catch(oh){};

    var sPath = window.location.pathname;
    var IE = document.all?true:false

	function closePopup(popupname)
	{
		document.getElementById(popupname).style.display="none";
		removeMouseDownEvent();
		//alert("hiding");
	}
	function showref(popupname, e)
	{

	    
		if(the_popupname)
			closePopup(the_popupname);		// If there is already a ref item open, close it before opening the new one. 
		
		the_popupname = "popup" + popupname;
		
		var xPos;
		var yPos;
		var popupheight;
		var adjX;
		adjX = Math.round((window.screen.width - 984)/2);
		
		if(adjX < 0)
		{
		    adjX = 0;
		}

		if(IE)
		{
			xPos = window.event.x;
			yPos = window.event.y;
			yPos = yPos + document.body.scrollTop
			//yPos = yPos + document.documentElement.scrollTop				
		}
		else
		{
			xPos = e.pageX - adjX;
			yPos = e.pageY;
		}	
		
		
		var curPopup = "popup" + popupname;
		document.getElementById(curPopup).style.display="block";
		//alert("showing");
		popupheight = document.getElementById(curPopup).offsetHeight;		
		yPos = (yPos - (popupheight-10));
		
		if(yPos < 0)
		{
			yPos=0;
		}
		
	    document.getElementById(curPopup).style.top = yPos+"px";
	    
		if(IE)
		{
		    document.getElementById(curPopup).style.left = (xPos-60)+"px";
		}
		else
		{
		    document.getElementById(curPopup).style.left = (xPos-50)+"px";
		}

		//addMouseDownEvent(curPopup);
		
	}
	
	String.prototype.trim=function()
	{
		return this.replace(/^\s*|\s*$/g,'');
	}	
	
	// For "click-away hide" functionality 
	
	function addMouseDownEvent(pname)
	{		
		var popupname = pname;
		
		if( document.captureEvents && Event.CLICK )
			document.captureEvents(Event.CLICK);
			
        document.onclick = clickHandler;
	}
	
	function removeMouseDownEvent()
	{
		if(document.captureEvents && Event.CLICK)
			document.releaseEvents(Event.CLICK);
	}
	
	function clickHandler(e)
	{
		var newEvent = e;
		
		if(newEvent)
			element = e.target;
		else
			element = window.event.srcElement;
			
		var arrayOfStrings = the_popupname.split('popup');
		var linkId = arrayOfStrings[0];
		var linkIdimg = linkId + 'img'
		
		if(element.id != linkId && element.id != linkIdimg)
		{
			var parentId = element.parentNode.id;
			var superParentId = element.parentNode.parentNode.id;
			
			if(!(parentId == the_popupname || superParentId == the_popupname))
				closePopup(the_popupname);
		}
	}
			

	
	
	
