var highlightNewsNav_YAH = "#7A7979";
var highlightNewsNav_OFF = "#333";
var highlightNewsNav_OVER = "#eee";
var bottomAccordion;
var runningxmlhttpPost = false;
var runEventsApp = true;

//Event.observe(window, 'load', loadAccordions, false);

function loadAccordions() {
	
}
function runFirst(){

}
/* ~~~~~~~~~~[ Breaking news ]~~~~~~~~~~~ */
function runBreakingNews(showId){
	var newsItems = document.forms['breakingNewsForm'].numberOfItems.value;
	
	if(parseInt(newsItems) > 1){
		for(z=1;z<=newsItems;z=z+1){
			document.getElementById('newsItem_' + z).style.display = 'none';
			document.getElementById('newsNavLink_' + z).style.background = 'url(/images/interface/dotNav.png) no-repeat';
		}
	
		document.getElementById('newsItem_' + showId).style.display = 'block';
		/* ~~~~~~~[ newsNav ] ~~~~~~~~~ */
		document.getElementById('newsNavLink_' + showId).style.background = 'url(/images/interface/dotNav_YAH.png) no-repeat';
		
		globalShowId = showId;
		
		if(showId == newsItems){
			showId = 1
		}else{
			showId = showId + 1;
		}	
		t = setTimeout('runBreakingNews(' + showId + ')',4000);
	}
}
function gotoBreakingNews(showId){
	clearTimeout(t);
	runBreakingNews(showId);
}
function highlightNewsNav(obj,state){
	var currentShowId = window.globalShowId;
	var idOn = obj.id;
	idOn = idOn.substring(idOn.indexOf('_')+1);
	
	if(state == 'over'){
		obj.style.background = 'url(/images/interface/dotNav_YAH.png) no-repeat';
	}else if(idOn == currentShowId){
		obj.style.background = 'url(/images/interface/dotNav_YAH.png) no-repeat';
	}else{
		obj.style.background = 'url(/images/interface/dotNav.png) no-repeat';
	}
}
/* ~~~~~~~~~~[ twitterFeed ]~~~~~~~~~~~ */
var rssIdstr = "";
var twitterIdstr = "";

function twitterFeed(rssId,twitterId){
	//Has to be loaded here because the vars are not ready until passed from within page	
	rssIdstr = rssId;
	twitterIdstr = twitterId; 
	
	//var ajaxFeedstr = '/O2Net/Applications/TransformDoc/default.aspx?XmlDoc=http://twitter.com/statuses/user_timeline/' + rssIdstr + '&XsltDoc=/xsltTemplate/twitterFeedGoogleFont.xslt&XmlVars=twitterId|' + twitterIdstr;	
	var ajaxFeedstr = '/O2Net/Applications/TransformDoc/default.aspx?XmlDoc=/xml/content/feeds/160553129.xml&XsltDoc=/xslt/twitterFeedGoogleFont.xslt&XmlVars=twitterId|' + twitterIdstr;	
	
	$.ajax({
		url: ajaxFeedstr,
		success: function(data){
			$('#twitterFeed').html(data);
		}
	});	
	/*
	//Works for PR feed and events panel
	if(document.getElementById('twitterFeed') && window.runningxmlhttpPost == false){
		runningxmlhttpPost = true;
		xmlhttpPost('/O2Net/Applications/TransformDoc/default.aspx?XmlDoc=http://twitter.com/statuses/user_timeline/' + rssId + '&XsltDoc=/xsltTemplate/twitterFeedGoogleFont.xslt&XmlVars=twitterId|' + twitterId,'twitterFeed');
	}else{
		setTimeout('twitterFeed(\'' + rssId + '\',\'' + twitterId + '\')',500);
	}	
	*/
}
/* ~~~~~~~~~~[ events ]~~~~~~~~~~~ */
function runEvents(pageConfig){
	if(runEventsApp == true){
		loadingMessage('/images/loading_3.gif',10);
		if(document.getElementById('httpReqResults') && window.runningxmlhttpPost == false){
			runningxmlhttpPost = true;
			xmlhttpPost('/O2Net/Applications/TransformDoc/default.aspx?XmlDoc=/xml/content/events.xml&XsltDoc=/xsltTemplate/eventsSub.xslt&XmlVars=pageConfig|' + pageConfig + ',version|home','httpReqResults');
		}else{
			setTimeout('runEvents(\'' + pageConfig + '\')',500);
		}
	}
}
/* ~~~~~~~~~~[ Careers ]~~~~~~~~~~~ */
function goGetUrl(formName,selectName){
	window.location.href = eval('document.' + formName + '.' + selectName).options[eval('document.' + formName + '.' + selectName).selectedIndex].value;
}
/* ~~~~~~~~~~[ Locator ]~~~~~~~~~~~ */
function explodeMapLocator(){
	//document.getElementById('locatorExplodeMap').style.display = 'block';
	//xmlhttpPost('/O2Net/Applications/TransformDoc/default.aspx?XmlDoc=/xml/content/events.xml&XsltDoc=/xslt/salesRepsUsImgMap.xslt','locatorExplodeMap');
}
function compressExplodedMap(){
		document.getElementById('locatorExplodeMap').style.display = 'none';
		//document.getElementById('mapThumb').style.display = 'block';
}
/* ~~~~~~~~~~[ About ]~~~~~~~~~~~ */
function loadAboutCopy(){
	if(document.getElementById('leftcontent')){
		document.getElementById('aboutText').innerHTML = document.getElementById('leftcontent').innerHTML;
			if(typeof(reDrawSifr) == 'undefined'){
			
			}else{
				reDrawSifr();	
			}	
	}else{
		setTimeout('loadAboutCopy()',200);
	}	
}
/* ~~~~~~~~~~[ Promo ]~~~~~~~~~~~ */
function promotion(totalPromos){
	if(typeof(getCookie) == 'undefined'){
		setTimeout('promotion(' + totalPromos + ')',500);
	}else{
		if(getCookie('promotion') == null){
			SetGetCookie('promotion',1);
		}else{
			if(parseFloat(getCookie('promotion')) >= parseFloat(totalPromos)){
				SetGetCookie('promotion',1)
			}else{
				SetGetCookie('promotion',(parseFloat(getCookie('promotion'))+1))
			}
		}
		var promoShow = 'promo' + getCookie('promotion');
		document.getElementById(promoShow).style.display = 'block'; 	
	}
}
/* ~~~~~~~~~~[ common ]~~~~~~~~~~~ */
function xmlhttpPostComplete(){
	runningxmlhttpPost = false;
}

function getStyle(el,styleProp)
{
	 /*
	  http://www.quirksmode.org/dom/getstyles.html
	  Pass styles in as style sheet declorations, IE wants javascript way
	 */ 
	 var x = document.getElementById(el);
	 if (x.currentStyle){
	  //ie
	  switch(styleProp)
	  {
	  case 'text-decoration':
	    styleProp = 'textDecoration';
	    break;    
	  default:
	  }
	  var y = x.currentStyle[styleProp];
	 }else if (window.getComputedStyle){
	  var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	 }
	 return y;
} 
