/*Use Object Detection to detect IE6*/
    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 IE = document.all?true:false

    //load xml file
	// code for IE
/*
	if (window.ActiveXObject)
	{
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=false;
		xmlDoc.load("/c/config/Glossary.xml");
		//getmessage();
	}
	// code for Mozilla, Firefox, Opera, etc.
	else if (document.implementation && document.implementation.createDocument)
	{
		xmlDoc=document.implementation.createDocument("","",null);
		xmlDoc.load("/c/config/Glossary.xml");
		//xmlDoc.onload=getmessage;
	}
	else
	{
		alert('Your browser cannot handle this script');
	}
*/
	
	var prevPopupId;//   the_popupname;	// used for "click away hide" functionality
	var prevPlayerId;
	
	
/*
	onload = function(){
	glospopup();
	}
	
	
	
	function glospopup(){
	    
	    function popup(){
	        var type;
	        var link;
	    }   
	    
		//alert(xmlDoc.getElementsByTagName("name")[0].childNodes[0].nodeValue)
		
		var links = document.getElementsByTagName('a');
		var popuplinks = new Array();
		 
		var e = 0;
			
		for (var i=0; i<links.length; i++){
		
		    if(links[i].name=="popup"){
    			
			    var popupObj = new popup();
			    popupObj.link = links[i];
			    popupObj.type = 1;
			    popuplinks[e] = popupObj;
			    e++;
    									
		    }else if(links[i].name=="flashpopup"){
		        var popupObj = new popup();
			    popupObj.link = links[i];
			    popupObj.type = 2;
			    popuplinks[e] = popupObj;
			    e++;
			}
		    
		}
		
		
		//popuplinks.length NUMBER OF glossary LINKS ON THE PAGE (2)
		for (var j=0; j<popuplinks.length; j++){ 
				
			//xmlDoc.getElementsByTagName("name").length
			//NUMBER OF "<name>" TAGS IN THE XML (3)
			for (var jj=0; jj<xmlDoc.getElementsByTagName("name").length; jj++){	
							
				//CHECK BROWSER TO SEE IF ITS IE (.text) OR FIREFOX (.textContent) good 'ol browser bs

				var divTitle = '';
				var divText = '';
				var matchFound = false;
				
				
				//(xmlDoc.getElementsByTagName("glossary")[0].text === undefined)
				if(xmlDoc.getElementsByTagName("glossary")[0].text === undefined){
					//FF
					if(xmlDoc.getElementsByTagName("link")[jj].textContent.trim() == popuplinks[j].link.innerHTML){
						divTitle = xmlDoc.getElementsByTagName("name")[jj].textContent
						divText = xmlDoc.getElementsByTagName("description")[jj].textContent
						matchFound = true;
					}
				} else {
					//IE
					if(xmlDoc.getElementsByTagName("glossary")[0].childNodes[jj].childNodes[2].text == popuplinks[j].link.innerHTML){
						divTitle = xmlDoc.getElementsByTagName("glossary")[0].childNodes[jj].childNodes[0].text
						divText = xmlDoc.getElementsByTagName("glossary")[0].childNodes[jj].childNodes[1].text
						matchFound = true;
					}
				}
				
				if (matchFound) {
				        
				        var divIdTitle = popuplinks[j].link.id + popuplinks[j].link.name + "title";
					    var divIdText = popuplinks[j].link.id + popuplinks[j].link.name + "text";
					    var divIdName = popuplinks[j].link.id + popuplinks[j].link.name;
					    var divIdNameTop = popuplinks[j].link.id + popuplinks[j].link.name + "top";
					    var divIdNameMid = popuplinks[j].link.id + popuplinks[j].link.name + "mid";
					    var divIdClose = popuplinks[j].link.id + popuplinks[j].link.name + "close";
					    
					    var newdiv = document.createElement('div');
					    var newdivTop = document.createElement('div');
					    var newdivMid = document.createElement('div');
					    var newdivBtm = document.createElement('div');
					    var newdivTitle = document.createElement('div');
					    var newdivText = document.createElement('div');
					    var newdivClose = document.createElement('div');					
    											
					    newdiv.setAttribute('id', divIdName);
					    newdivTop.setAttribute('id',divIdNameTop);
					    newdivMid.setAttribute('id',divIdNameMid);
					    newdivTitle.setAttribute('id', divIdTitle);
					    newdivText.setAttribute('id', divIdText);
					    newdivClose.setAttribute('id', divIdClose);
				
				    if(popuplinks[j].type == 1){				    
    					
					    newdiv.setAttribute('class',"glossary_popup");
					    newdivTop.setAttribute('class',"glossary_popup_top");
					    newdivMid.setAttribute('class',"glossary_popup_mid");
					    newdivBtm.setAttribute('class',"glossary_popup_btm");
					    newdivTitle.setAttribute('class',"glossary_popup_title");
					    newdivText.setAttribute('class',"glossary_popup_text");
					    newdivClose.setAttribute('class',"glossary_popup_close");
					    newdivClose.setAttribute('onclick',"closePopup('"+divIdName+"')");   					
					    
				    }
				    else if (popuplinks[j].type == 2){
    				    
    				    newdiv.setAttribute('class',"flash_popup");
					    newdivTop.setAttribute('class',"flash_popup_top");
					    newdivMid.setAttribute('class',"flash_popup_mid");
					    newdivBtm.setAttribute('class',"flash_popup_btm");
					    newdivTitle.setAttribute('class',"flash_popup_title");
					    newdivText.setAttribute('class',"flash_popup_text");
					    newdivClose.setAttribute('class',"flash_popup_close");
					    newdivClose.setAttribute('onclick',"closePopup('"+divIdName+"')");   
				    }
				    
				    newdivTitle.innerHTML = divTitle;
					    newdivText.innerHTML = divText;
    												
					    document.getElementById("main").appendChild(newdiv);
    					
					    document.getElementById(divIdName).appendChild(newdivTop);
					    document.getElementById(divIdName).appendChild(newdivMid);
					    document.getElementById(divIdName).appendChild(newdivBtm);
					    document.getElementById(divIdNameTop).appendChild(newdivClose);						
					    document.getElementById(divIdNameTop).appendChild(newdivTitle);
					    document.getElementById(divIdNameMid).appendChild(newdivText);
				    
				  break;
				}
			}// for jj
		}//for j
	}
*/
	function closePopup(popupname, playerId)
	{
		document.getElementById(popupname).style.display="none";
		
		if ((playerId != '') && (playerId != undefined) && IE) {
			//alert(playerId + "close");
			document.getElementById(playerId).removeVid();
		}
		
		//removeMouseDownEvent();
	}
	
	function playerReady(playerId) {
		//alert(playerId + "ready");
		document.getElementById(playerId).playVid();
	}
	
	function showglos(popupname, playerId, e)
	{
	   
	 
		//if(the_popupname)
		//	closePopup(the_popupname);		// If there is already a glossary item open, close it before opening the new one. 
		if (prevPopupId)
			closePopup(prevPopupId, prevPlayerId);
		
		
		
		//the_popupname = popupname;
		prevPopupId = popupname;
		prevPlayerId = playerId;
		
		var xPos;
		var yPos;
		var popupheight;
		if(IE)
		{
			xPos = window.event.x;
			yPos = window.event.y;
			yPos = yPos + document.documentElement.scrollTop	
		}
		else
		{
			xPos = e.pageX;
			yPos = e.pageY;
		}	
		
		
		//alert(xPos - 200);
		document.getElementById(popupname).style.display="block";
		popupheight = document.getElementById(popupname).offsetHeight;
		
		yPos = (yPos - (popupheight-10));
		if(yPos < 0)
		{
			yPos=0;
		}
		document.getElementById(popupname).style.top = yPos+"px";
		document.getElementById(popupname).style.left = (xPos-60)+"px";
		
		if ((playerId != '') && (playerId != undefined)) {
			//alert(playerId + "open");
			document.getElementById(playerId).playVid();
		}
		
		//addMouseDownEvent(popupname);
		
	}
	
	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)
	{
		return;
		var newEvent = e;
		
		if(newEvent)
			element = e.target;
		else
			element = window.event.srcElement;
			
		//alert(the_popupname.indexOf("flash"));
		if(the_popupname.indexOf("flash") > 0){
		    var arrayOfStrings = the_popupname.split('flashpopup');
		}else{
		    var arrayOfStrings = the_popupname.split('popup');
		}
		
		var linkId = arrayOfStrings[0];
		var linkIdimg = linkId + 'img'
		
		//alert(element.id + " - " + linkId + " - " + linkIdimg)
		if(element.id != linkId && element.id != linkIdimg)
		{
			var parentId = element.parentNode.id;
			var superParentId = element.parentNode.parentNode.id;
			//alert(parentId + " - " + the_popupname + " - " + superParentId)
			if(!(parentId == the_popupname || superParentId == the_popupname))
				closePopup(the_popupname);
		}
		
	}
*/