var productLastHighlighted;
var linkLastHighlighted;

function runXmlXslt(){
	//Product Browser
	if(document.getElementById('TestOutput')){
		var siteBase = baseURL();
		var divToWrite = '';
		siteBase = siteBase.toLowerCase();
		
		if(siteBase.indexOf('products_7017') > 0){
			divToWrite = "TestOutput";
		}else{
			divToWrite = "vertical_container";
		}
		
		xmlhttpPost('/O2NetDev/Applications/TransformDoc/default.aspx?XmlDoc=http://spreadsheets.google.com/feeds/list/pRtmodZF-c5KZRzPuMKqTKQ/default/public/basic?alt=rss&XsltDoc=/xslt/products.xslt',divToWrite);
		setTimeout('loadAccordions()',1550);
		loadNewsDealerLinks();
	}else{
		setTimeout('runXmlXslt()',250);
	}
}

runXmlXslt();

function loadNewsDealerLinks(){
	var HTMLDisp = '';
	HTMLDisp = HTMLDisp + '';
	//HTMLDisp = HTMLDisp + '<h3 id=\"dealerFlyerLink\"><a href="javascript:runFlyerPromo();">Charger Water Specials ' + currentDate() + '</a></h3>';
	//HTMLDisp = HTMLDisp + '<div id=\"emailReminderLink\"><a href="FilterReminder_7076.aspx"><img src=\"/images/trans.gif\" width=\"450\" height=\"30\" alt=\"Filter Reminder\" /></a></div>';
	document.getElementById('newsHeadlines').innerHTML = HTMLDisp;
	reDrawSifr();
}
function runFlyerPromo(){
	xmlhttpPost('/O2NetDev/Applications/TransformDoc/default.aspx?XmlDoc=http://spreadsheets.google.com/feeds/list/pRtmodZF-c5KZRzPuMKqTKQ/default/public/basic?alt=rss&XsltDoc=/xslt/flyerFeature.xslt','productInfo');
}
function currentDate(){
	var months=new Array(13);
	months[1]="January";
	months[2]="February";
	months[3]="March";
	months[4]="April";
	months[5]="May";
	months[6]="June";
	months[7]="July";
	months[8]="August";
	months[9]="September";
	months[10]="October";
	months[11]="November";
	months[12]="December";
	var time=new Date();
	var lmonth=months[time.getMonth() + 1];
	var date=time.getDate();
	var year=time.getYear();
	if (year < 2000)
	year = year + 1900;
	return lmonth + " " + ", " + year;
}
function loadAccordions() {
	if(document.getElementById('vertical_container')){
		var bottomAccordion = new accordion('vertical_container', {
			resizeSpeed : 8,
			classNames : {
			    toggle : 'accordion_toggle',
			    toggleActive : 'accordion_toggle_active',
			    content : 'accordion_content'
			},
			direction : 'vertical',
			onEvent : 'click'
		});
	}else{
		setTimeout('loadAccordions()',250);
	}	
}

function showProduct(prodImage,productName,productDescript,modelNumbs,pdfBroch){
	var HTMLDisp = '';
	var modelsHTML = '';
	
	var mySplitResult = modelNumbs.split("|");
	
	modelsHTML = modelsHTML + '<ul>';
	for(i = 0; i < mySplitResult.length; i++){
		modelsHTML = modelsHTML + '<li>';
		modelsHTML = modelsHTML + mySplitResult[i]; 
		modelsHTML = modelsHTML + '</li>';
	}	
	modelsHTML = modelsHTML + '</ul>';
	
	HTMLDisp = HTMLDisp + '<div id=\"prodImg\">';
	HTMLDisp = HTMLDisp + '<img src=\"/images/products/' + prodImage + '\">';
	HTMLDisp = HTMLDisp + '</div>';
	HTMLDisp = HTMLDisp + '<div id=\"prodTitle\">';
	HTMLDisp = HTMLDisp + productName;
	HTMLDisp = HTMLDisp + '		<div id=\"prodDesc\">';
	HTMLDisp = HTMLDisp + '			<div id=\"prodModels\">';
	HTMLDisp = HTMLDisp + 				modelsHTML;
	HTMLDisp = HTMLDisp + '			</div>';
	HTMLDisp = HTMLDisp + 			productDescript;
	HTMLDisp = HTMLDisp + '			<p />';
	if(pdfBroch.length > 3){
		HTMLDisp = HTMLDisp + '			<br />';
		HTMLDisp = HTMLDisp + '			<a href=\"' + pdfBroch + '\" target=\"_blank\">';
		HTMLDisp = HTMLDisp + '			<img src=\"/images/interface/prodLit.jpg\" />';
		HTMLDisp = HTMLDisp + '			</a>';
	}
	HTMLDisp = HTMLDisp + '			<p />';
	HTMLDisp = HTMLDisp + '			<a href=\"RequestForm_1146.aspx?subject=' + productName + '\">';
	HTMLDisp = HTMLDisp + '			<img src=\"/images/interface/prodRfi.jpg\" />';
	HTMLDisp = HTMLDisp + '			</a>';	
	HTMLDisp = HTMLDisp + '		</div>';	
	HTMLDisp = HTMLDisp + '</div>';

	HTMLDisp = HTMLDisp + '';
	document.getElementById('productInfo').innerHTML = HTMLDisp;
	document.getElementById('productInfo').style.background = 'url(/images/interface/productsBack.jpg) no-repeat';
}
function removeProduct(){
	var HTMLDisp = '';
	HTMLDisp = HTMLDisp + '<img src=\"/images/trans.gif\">';
	document.getElementById('productInfo').innerHTML = HTMLDisp;
	document.getElementById('productInfo').style.background = 'url(/images/trans.gif) no-repeat';
}
function highLight(obj){
	var lastProductHighlighted = window.productLastHighlighted;
	var thisProductHighlighted = obj;
	
	if(typeof(lastProductHighlighted)!='undefined'){
		if(thisProductHighlighted != lastProductHighlighted){
			lastProductHighlighted.style.background = "transparent url(/images/trans.gif) no-repeat 0px 0px";
			lastProductHighlighted.style.textDecoration = 'underline';
		}
	}
	obj.style.background = "transparent url(/images/interface/prodUrHere.gif) no-repeat 0px 1px";
	//obj.style.background = "transparent url(/images/trans.gif) no-repeat 0px 0px";
	obj.style.textDecoration = 'none';
	productLastHighlighted = obj;
}
function highLightLink(obj){
	var lastLinkHighlighted = window.linkLastHighlighted;
	var thisLinkHighlighted = obj;
	
	if(typeof(lastLinkHighlighted)!='undefined'){
		if(thisLinkHighlighted != lastLinkHighlighted){
			lastLinkHighlighted.style.color = "#1771c5";
			lastLinkHighlighted.style.textDecoration = 'underline';
		}
	}
	obj.style.color = "#777777";
	obj.style.textDecoration = 'none';
	linkLastHighlighted = obj;
}
function getMapSwitchNavStyles(){
	mapSwitchNavColor = getStyle('mapSwitchNav_INT','color');
	mapSwitchNavTextDecoration = getStyle('mapSwitchNav_INT','text-decoration');
}
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;
} 
function setUpDealerEcomAd(){
	var HTMLDisp = '';
	
	HTMLDisp = HTMLDisp + '<div id=\"ecomPanel\">';
	HTMLDisp = HTMLDisp + '';
	HTMLDisp = HTMLDisp + '<form onsubmit=\"validate(this)\" action=\"http://www.crawfordsupply.com/eserv/eclipse.ecl\" name=\"login\" method=\"post\">';
	HTMLDisp = HTMLDisp + 	'<input type=\"hidden\" value=\"WEBPROC.WOE.AUTH\" name=\"PROCID\"/>';
	HTMLDisp = HTMLDisp + 	'<input type=\"hidden\" value=\"0\" name=\"TRACKNO\"/>';
	HTMLDisp = HTMLDisp + 	'<input type=\"hidden\" name=\"SEARCHSTR\"/>';
	HTMLDisp = HTMLDisp + 	'<input type=\"hidden\" name=\"FX\"/>';
	HTMLDisp = HTMLDisp + 	'<input type=\"hidden\" value=\"B\" name=\"VER\"/>';
	HTMLDisp = HTMLDisp + 	'<input type=\"hidden\" value=\"CHARGER\" name=\"WEB.COMPANY\"/>';
	HTMLDisp = HTMLDisp + 	'<input type=\"hidden\" value=\"1\" name=\"SITE.AUTH\"/>';
	
	HTMLDisp = HTMLDisp + 	'<div id=\"ecomPanelLogIn\">';
	HTMLDisp = HTMLDisp + 	'<input type=\"text\" name=\"D1\" /><br />';
	HTMLDisp = HTMLDisp + 	'<input type=\"password\" name=\"D2\" /><br />';
	HTMLDisp = HTMLDisp + 	'<input type=\"submit\" value=\"SEND\"/><br />';
	HTMLDisp = HTMLDisp + '</div>';
	HTMLDisp = HTMLDisp + '</form>';
	HTMLDisp = HTMLDisp + '<a href=\"/ECommerce_7075.aspx\"><img id=\"clickSpot\" src=\"/images/trans.gif\" /></a>'; 
	HTMLDisp = HTMLDisp + '<a href=\"/ECommerce_7075.aspx\"><img id=\"clickSpot2\" src=\"/images/trans.gif\" /></a>';
	HTMLDisp = HTMLDisp + '</div>';
		
	if(document.getElementById('events')){
		document.getElementById('events').innerHTML = HTMLDisp;
		document.getElementById('events').style.visibility = 'visible';
	}else{
		setTimeout('setUpDealerEcomAd()',250);
	}
}
setUpDealerEcomAd();