var highlightNewsNav_YAH = "#7A7979";
var highlightNewsNav_OFF = "#333";
var highlightNewsNav_OVER = "#eee";
var bottomAccordion;

Event.observe(window, 'load', loadAccordions, false);
	
function loadAccordions() {
	bottomAccordion = new accordion('vertical_container', {
		resizeSpeed : 9,
		classNames : {
		    toggle : 'accordion_toggle',
		    toggleActive : 'accordion_toggle_active',
		    content : 'accordion_content'
		},
		direction : 'vertical',
		onEvent : 'click'
	});
	setTimeout(runFirst,1000);
}
function runFirst(){
	//bottomAccordion.activate($$('#vertical_container .accordion_toggle')[0]);
}
/* ~~~~~~~~~~[ 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';
	}
}
/* ~~~~~~~~~~[ 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');
	//xmlhttpPost('/O2NetDev/Applications/TransformDoc/default.aspx?XmlDoc=/xml/include/listing.xml&XsltDoc=/xslt/dealerLocator.xslt','locatorExplodeMap');
	xmlhttpPost('/O2NetDev/Applications/TransformDoc/default.aspx?XmlDoc=/xml/content/dealerLocatorRequest.xml&XsltDoc=/xslt/dealerLocatorRequest.xslt','locatorExplodeMap');
	setFocus();
}
function setFocus(){
	if(document.getElementById('dealerLocator')){
		document.searchDealer.zip.focus();
	}else{
		setTimeout('setFocus()',200);
	}
}
function runSearch(){
	var zipSearch = document.searchDealer.zip.value;
	if(isZip(zipSearch)){
		xmlhttpPost('/O2NetDev/Applications/TransformDoc/default.aspx?XmlDoc=/xml/include/listing.xml&XsltDoc=/xslt/dealerLocator.xslt&XmlVars=searchString|'+zipSearch,'locatorExplodeMap');
		//window.location = "/O2NetDev/Applications/TransformDoc/default.aspx?XmlDoc=/xml/include/listing.xml&#x0026;XsltDoc=/xslt/dealerLocator.xslt&#x0026;XmlVars=searchString|" + zipSearch;
		setTimeout('reDrawSifrPause()',1000);
	}
}
function isZip(s) {
     reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
     if (!reZip.test(s)) {
          alert("Not a valid US zip code");
		  document.searchDealer.zip.focus();
          return false;
     }
	return true;
}
function disableEnterKey(e)
{
     var key;      
     if(window.event){
          key = window.event.keyCode; //IE
     }else{
          key = e.which; //firefox      
	 }
     if(key == 13){
	 	runSearch();
	 }
	 return (key != 13);
	 
}
function reDrawSifrPause(){
	reDrawSifr();
}
function logSearch(searchType,searchString){
	var searchData = eval("document.forms.searchDealer." + searchType).value;
	var searchLog = "/include/logDealers.aspx";
	if(searchData.length > 0){
		searchLog = searchLog + "?logType=" + searchType + "&hits=" + searchData + "&searchString=" + searchString;
		document.images[searchType].src = searchLog;
	}
	
}
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;
		reDrawSifr();
	}	
}
/* ~~~~~~~~~~[ Promo ]~~~~~~~~~~~ */
function promotion(totalPromos){
	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 reDrawSifr(){
     sIFR.replace(sifrFont1, {
     selector: 'h2'
    ,css: [
    	'.sIFR-root { text-align: left; font-weight: bold; }'
    	,'a { text-decoration: none; }'
    	,'a:link { color: #000000; }'
    	,'a:hover { color: #CCCCCC; }'
	]
    ,
   wmode: 'transparent'   
   });
} 

