function onLoadFuncs(){
	// removes "oneticker has started"
	window.status = "";
	// Fix for strange hover-popup
	Effect.Fade('hoverpopup');
}

function showTab(thisId, thisNum, totalNum) {
	

	// turn off all elements
	for (p=1; p < (totalNum + 1); p++) {
	   document.getElementById(thisId+p).style.display = 'none';
	}
	// turn on selected element
	document.getElementById(thisId+thisNum).style.display = '';
}


function swapTabs(tabID, thisTab, totalNum) {
	
	
	// turn off all elements
	for (x=1; x < (totalNum + 1); x++) {
	   document.getElementById(tabID + x).className = 'tab';
	}
	// turn on selected element
	 document.getElementById(tabID + thisTab).className = 'tab_active';
}

function swapMenu(menuID, tabID, thisTab, totalNum) {
	
	
	// turn off all elements
	for (x=1; x < (totalNum + 1); x++) {
	   document.getElementById(tabID + x).className = 'tab';
	   document.getElementById(menuID + x).style.display = 'none';
	}
	// turn on selected element
	 document.getElementById(tabID + thisTab).className = 'tab_active';
	 document.getElementById(menuID + thisTab).style.display = '';
}
/////////////////////////////////////////////////////
//Ken Aug 20, 2007
// for "Can't collapse an item unless you select another item to expand"
/////////////////////////////////////////////////////
function showMenu(thisId, thisNum, totalNum) {
 if(document.getElementById(thisId+thisNum+'_open').style.display == ''){ // if on, turn off
	  // turn off all elements
	    for (p=1; p < (totalNum + 1); p++) {
	    	document.getElementById(thisId+p+'_closed').style.display = '';
	        document.getElementById(thisId+p+'_open').style.display = 'none';
	        }
	}else{//if off , turn on
		// turn off all elements
	    for (p=1; p < (totalNum + 1); p++) {
	    	document.getElementById(thisId+p+'_closed').style.display = '';
	        document.getElementById(thisId+p+'_open').style.display = 'none';
	        }
  	   // turn on selected element			
		document.getElementById(thisId+thisNum+'_open').style.display = '';
	    document.getElementById(thisId+thisNum+'_closed').style.display = 'none';
   } 
}
/////////////////////////////////////////////////////
//Ken Aug 20, 2007
// for "Check it out & News Update links reload the homepage if you are already on the homepage"
/////////////////////////////////////////////////////
function checkCurrentLink(num) {

//for live
//    var domainName="http://www.theenergynews.com/";   
//    var domainName1="http://theenergynews.com/";

//for localhost
      var domainName="http://localhost/energynews/";
      var domainName1="http://theenergynews.com/";

  	  switch(num)
       {
              case '1':
                    if  (window.location.href != domainName && window.location.href != domainName1){
		                 window.location.href= domainName;
	                     }
              break    
              case '2':
                    if  (window.location.href != domainName+"financial/" && window.location.href != domainName1 +"financial/"){
		                 window.location.href= domainName+"financial/";
	                     }
              break    
              case '3':
                    if  (window.location.href != domainName+"directory/" && window.location.href != domainName1 +"directory/"){
		                 window.location.href= domainName+"directory/";
	                     }
              break    
              case '4':
                    if  (window.location.href != domainName+"events/" && window.location.href != domainName1 +"events/"){
		                 window.location.href= domainName+"events/";
	                     }
              break    
              case '5':
                    if  (window.location.href != domainName+"employment/" && window.location.href != domainName1 +"employment/"){
		                 window.location.href= domainName+"employment/";
	                     }
              break 
              case '6':
                    if  (window.location.href != domainName+"weather/" && window.location.href != domainName1 +"weather/"){
		                 window.location.href= domainName+"weather/";
	                     }
              break    
              case '7':
                    if  (window.location.href != domainName+"mapping/" && window.location.href != domainName1 +"mapping/"){
		                 window.location.href= domainName+"mapping/";
	                     }
              break 
              case '8':
                    if  (window.location.href != domainName+"safety/" && window.location.href != domainName1 +"safety/"){
		                 window.location.href= domainName+"safety/";
	                     }
              break    
              case '9':
                    if  (window.location.href != domainName+"rfp/" && window.location.href != domainName1 +"rfp/"){
		                 window.location.href= domainName+"rfp/";
	                     }
			  break 			 
			  case '10':
                    if  (window.location.href != domainName+"equipment/" && window.location.href != domainName1 +"equipment/"){
		                 window.location.href= domainName+"equipment/";
	                     }
			  break 			 			 
       }
}

function toggleDiv(objid,vis) {
	
	var obj;
	try {
		if(objid.parentNode){
			//it's an object. we needn't do anything
			obj = objid;
		} else {
			//it's not an object
			obj = document.getElementById(objid);
		}
	} catch(e) {
		//it's not an object and the browser errors on undefined properties
		obj = document.getElementById(objid);
	}
	if(vis){		
		if (obj.style.visibility == 'hidden') {
			obj.style.visibility = 'visible';
		} else {
			obj.style.visibility = 'hidden';
		}
	} else {
		if (obj.style.display == 'none') {
			obj.style.display = 'block';
		} else {
			obj.style.display = 'none';
		}
	}
}


function togglePlusMinus(imgID,imgPath,imgPlus,imgOpen) {	
	var imgObj = document.getElementById(imgID);
	var imgSrc = imgObj.src;
	var imgSrcLen = imgSrc.length;
	
	var imgPathLen = imgPath.length;
	var imgPlusLen = imgPlus.length;
	var imgOpenLen = imgOpen.length;
	
	var imgSrc = imgSrc.substring(imgSrcLen-imgPathLen-imgPlusLen);
	
	if (imgSrc == imgPath + imgPlus) {
		imgObj.src = imgPath + imgOpen;
	} else {
		imgObj.src = imgPath + imgPlus;
	}
	
}


function popUp(pURL, pWidth, pHeight) {
	
	day = new Date();
	id = day.getTime();
	
	if (ie) {
		var newWindow = window.open("../" + pURL, "window"+id, "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+pWidth+",height="+pHeight+",left = 20,top = 20");

	} else {
		var newWindow = window.open(pURL, "window"+id, "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+pWidth+",height="+pHeight+",left = 20,top = 20");
	}

}


function findWeather(cityName){
	xmlHttp = createXmlHttp();
	
	if (xmlHttp) {
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
            
			xmlHttp.open('GET','weather/_weatherData.php?city='+cityName, true);  
			
			xmlHttp.onreadystatechange = function(){
				if (xmlHttp.readyState == 4) {
					// status of 200 indicates the transaction completed successfully
					if (xmlHttp.status == 200) {
						//data exchange was successful:
						var xmlResponse = xmlHttp.responseXML;
		 				var xmlRoot = xmlResponse.documentElement;  
						
						
						if(!xmlRoot.getElementsByTagName('error')[0]){
							// errbody in the club gettin' tips'
					    	
					    	document.getElementById('weatherCity').innerHTML = xmlRoot.getElementsByTagName('city')[0].firstChild.data;
					    	document.getElementById('weatherTemp').innerHTML = xmlRoot.getElementsByTagName("temp")[0].firstChild.data;
					    	document.getElementById('weatherPressure').innerHTML = xmlRoot.getElementsByTagName("pressure")[0].firstChild.data;
					    	document.getElementById('weatherWind').innerHTML = xmlRoot.getElementsByTagName("windspeed")[0].firstChild.data;
					    	document.getElementById('weatherHumidity').innerHTML = xmlRoot.getElementsByTagName("humidity")[0].firstChild.data;
					    	//document.getElementById('weatherChill').innerHTML = xmlRoot.getElementsByTagName("windchill")[0].firstChild.data;
						}else{
							// couldn't find the city :(
							//alert(xmlRoot.getElementsByTagName('error')[0].firstChild.data);
							document.getElementById('weatherCity').innerHTML = '<style="color: #ff0000;">Cannot Find City.<br/></span>Please try again.';
					    	document.getElementById('weatherTemp').innerHTML = 'n/a';
					    	document.getElementById('weatherPressure').innerHTML = 'n/a';
					    	document.getElementById('weatherWind').innerHTML = 'n/a';
					    	document.getElementById('weatherHumidity').innerHTML = 'n/a';
						}
					
					}
				}
				
			}
			xmlHttp.send(null);
			
		} else {
			// if the connection is busy, try again after 1/4 second  
			setTimeout('findWeather('+cityName+')', 250);
		}
			
		
	} else {
		alert('There was an error creating the XML Object.');
	}
}

function loadNewVideo(vidPath) {

	
	
	var playerID = "mainPlayer";
	var vidBase  = "http://hwcdn.net/j8a4w3e7/wms";
	//var vidBase  = "http://wm.world.mii-streaming.net/media/convergent/theenergynews/windows";


	
	if(vidPath == "GoExpoGoLive"){
		//we are loading /push/3
		
		vidPath = "http://wm-live.world.mii-streaming.net/live/convergent/curltv/push/4";
		
	} else {
		vidPath = vidBase + vidPath;	
	}
	
	
	//alert(vidPath);

	
	if(ie){
		var vidPlayer = document.getElementById(playerID);
		vidPlayer.filename = vidPath;
		vidPlayer.autostart = true;
	}else{
		var vidArea = document.getElementById('vidPlayer');
		var vidTag =  "<embed " + 
				"src=\""+vidPath+"\" " + 
				"width=\"320\" " + 
				"height=\"293\" " + 
				"autostart=\"false\" " + 
				"loop=\"false\" " + 
				"type=\"application/x-mplayer2\" " + 
				"pluginspage=\"http://microsoft.com/windows/mediaplayer/en/download/\" " + 
				"id=\""+playerID+"\" " + 
				"AllowChangeDisplaySize=\"1\" " + 
				"displaysize=\"4\" " + 
				"autosize=\"-1\" " + 
				"bgcolor=\"darkblue\" " + 
				"showcontrols=\"true\" " + 
				"showtracker=\"-1\" " + 
				"showdisplay=\"0\" " + 
				"showstatusbar=\"0\" " + 
				"videoborder3d=\"-1\" " + 
				"designtimesp=\"5311\" " + 
				"filename=\""+vidPath+"\" " + 
				"animationatstart=\"true\" " + 
				"transparentatstart=\"false\"> " + 
				"</embed> ";
				vidArea.innerHTML = vidTag;
	}
}

/*
Created By: Chris Mackney
Date:       June 28th-ish

paramters:  (hoveritem, time, theText)
hoveritem: The Item you want the hover to appear over
time: time in MS
theText: The text you want in the box

comment:    This is used for the "hover pop-up" help.

 */
function ShowPopup(hoveritem, time, theText){
	h = hoveritem;
	t = theText;

	timer = setTimeout("realShowPop(h, t)", time);
}

function realShowPop(hoveritem, theText){

hp = document.getElementById("hoverpopup");
hp.style.visibility = "Visible";



hp.innerHTML = theText
// Set position of hover-over popup

hp.style.top = findY(hoveritem)+20+"px";
hp.style.left = findX(hoveritem)+20+"px";

// Set popup to visible
Effect.Appear("hoverpopup", {duration:0.3});


}

function HidePopup()
{
 clearTimeout(timer);
Effect.Fade("hoverpopup", {duration:0.3});
}

function findX(obj) {
var x = 0;
while (obj) {
x += obj.offsetLeft
obj = obj.offsetParent;
}
//alert(x);
return(x);
}

function findY(obj) {
var y = 0;
while (obj) {
y += obj.offsetTop
obj = obj.offsetParent;
}
return(y);
}
/* End ShowPopup() */
