// finToolMenuState cookie values
var isOpen = 'menuIsOpen';
var isClosed = 'menuIsClosed';

// set up up vars based on brand directory, financial tools menu item bgs, text and hover state colours are set here, initial states are set in brand level CSS files
var thisBrand = '';
var thisBrandCode = '';
var thisBrandColor = '';
var thisBrandDfltColor = '';
var thisLoc = location.toString();

if (thisLoc.indexOf('/buick/') != -1) { 
	thisBrand = 'buick'
	thisBrandCode = 'buic';	
	thisBrandColor = '#FFF';	
	thisBrandDfltColor = '#FFF';		
	setCookie("thisBrand",thisBrand, "", "/");
	setCookie("thisBrandCode",thisBrandCode, "", "/");
	setCookie("thisBrandColor",thisBrandColor, "", "/");
	setCookie("thisBrandDfltColor",thisBrandDfltColor, "", "/");
} else if (thisLoc.indexOf('/cadillac/') != -1) { 
	thisBrand = 'cadillac';
	thisBrandCode = 'cadi';	
	thisBrandColor = '#FFF';	
	thisBrandDfltColor = '#FFF';
	setCookie("thisBrand",thisBrand, "", "/");
	setCookie("thisBrandCode",thisBrandCode, "", "/");
	setCookie("thisBrandColor",thisBrandColor, "", "/");
	setCookie("thisBrandDfltColor",thisBrandDfltColor, "", "/");	
} else if (thisLoc.indexOf('/chevrolet/') != -1) { 
	thisBrand = 'chevrolet';
	thisBrandCode = 'chev';	
	thisBrandColor = '#FFF';	
	thisBrandDfltColor = '#000';
	setCookie("thisBrand",thisBrand, "", "/");
	setCookie("thisBrandCode",thisBrandCode, "", "/");
	setCookie("thisBrandColor",thisBrandColor, "", "/");
	setCookie("thisBrandDfltColor",thisBrandDfltColor, "", "/");
		
} else if (thisLoc.indexOf('/chevytrucks/') != -1) { 
	thisBrand = 'chevrolet';
	thisBrandCode = 'chev';	
	thisBrandColor = '#FFF';	
	thisBrandDfltColor = '#000';
	setCookie("thisBrand",thisBrand, "", "/");
	setCookie("thisBrandCode",thisBrandCode, "", "/");
	setCookie("thisBrandColor",thisBrandColor, "", "/");
	setCookie("thisBrandDfltColor",thisBrandDfltColor, "", "/");	
} else if (thisLoc.indexOf('/gmc/') != -1) { 
	thisBrand = 'gmc';
	thisBrandCode = 'gmct';	
	thisBrandColor = '#FFF';	
	thisBrandDfltColor = '#FFF';
	setCookie("thisBrand",thisBrand, "", "/");
	setCookie("thisBrandCode",thisBrandCode, "", "/");
	setCookie("thisBrandColor",thisBrandColor, "", "/");
	setCookie("thisBrandDfltColor",thisBrandDfltColor, "", "/");	
} else if (thisLoc.indexOf('/hummer/') != -1) { 
	thisBrand = 'hummer';
	thisBrandCode = 'humm';	
	thisBrandColor = '#000';	
	thisBrandDfltColor = '#000';
	setCookie("thisBrand",thisBrand, "", "/");
	setCookie("thisBrandCode",thisBrandCode, "", "/");
	setCookie("thisBrandColor",thisBrandColor, "", "/");
	setCookie("thisBrandDfltColor",thisBrandDfltColor, "", "/");	
} else if (thisLoc.indexOf('/pontiac/') != -1) { 
	thisBrand = 'pontiac';
	thisBrandCode = 'pont';	
	thisBrandColor = '#FFF';	
	thisBrandDfltColor = '#000';
	setCookie("thisBrand",thisBrand, "", "/");
	setCookie("thisBrandCode",thisBrandCode, "", "/");
	setCookie("thisBrandColor",thisBrandColor, "", "/");
	setCookie("thisBrandDfltColor",thisBrandDfltColor, "", "/");		
} else if (thisLoc.indexOf('/showroom/') != -1) { 
	thisBrand = 'showroom';
	thisBrandCode = 'corp';	
	thisBrandColor = '#FFF';	
	thisBrandDfltColor = '#000';	
	setCookie("thisBrand",thisBrand, "", "/");
	setCookie("thisBrandCode",thisBrandCode, "", "/");
	setCookie("thisBrandColor",thisBrandColor, "", "/");
	setCookie("thisBrandDfltColor",thisBrandDfltColor, "", "/");	
} else if (thisLoc.indexOf('/chevrolet/') != -1) {
	thisBrand = 'chevrolet';
	thisBrandCode = 'chev';	
	thisBrandColor = '#FFF';	
	thisBrandDfltColor = '#000';
	setCookie("thisBrand",thisBrand, "", "/");
	setCookie("thisBrandCode",thisBrandCode, "", "/");
	setCookie("thisBrandColor",thisBrandColor, "", "/");
	setCookie("thisBrandDfltColor",thisBrandDfltColor, "", "/");	
} else {
	thisBrand = getCookie("thisBrand");
	thisBrandCode = getCookie("thisBrandCode");
	thisBrandColor = getCookie("thisBrandColor");
	thisBrandDfltColor = getCookie("thisBrandDfltColor");
}



// read cookie and set menu state open/closed
function setMenuState(){
	
	var menuState = getCookie('finToolMenuState');
	var headerObject = getRef('finToolsHeader');
	var headerObjectAnchor = getRef('finToolsHeaderAtag');
	var openObject = getRef('finToolsList'); 
		
	if(menuState==null){
		headerObject.style.background = 'url(/images/vehicles/common/' + thisBrand + '/' + thisBrandCode + '_finTool_header.gif) no-repeat';
		headerObjectAnchor.style.color = thisBrandDfltColor;
		openObject.style.visibility = 'hidden'; 
		openObject.style.display = 'none';	
	}
	else if(menuState=='menuIsClosed'){
		headerObject.style.background = 'url(/images/vehicles/common/' + thisBrand + '/' + thisBrandCode + '_finTool_header.gif) no-repeat';
		headerObjectAnchor.style.color = thisBrandDfltColor;
		openObject.style.visibility = 'hidden'; 
		openObject.style.display = 'none';	
	}	
	else if(menuState=='menuIsOpen'){
		headerObject.style.background = 'url(/images/vehicles/common/' + thisBrand + '/' + thisBrandCode + '_finTool_slctd_header.gif) no-repeat';
		headerObjectAnchor.style.color = thisBrandColor;
		openObject.style.visibility = 'visible'; 
		openObject.style.display = 'block';	
	}	

}

// open or close menu on click
function showHideObject(objectId){ 
        var theObject = getRef(objectId); 	
		var headerObject = getRef('finToolsHeader');
		var headerObjectAnchor = getRef('finToolsHeaderAtag');
		var closeObject = getRef('finToolsList');
		
		if (theObject.style.visibility == 'visible') {
			theObject.style.visibility = 'hidden'; 
			theObject.style.display = 'none';	
			headerObject.style.background = 'url(/images/vehicles/common/' + thisBrand + '/' + thisBrandCode + '_finTool_header.gif) no-repeat';	
			headerObjectAnchor.style.color = thisBrandColor;
			setCookie('finToolMenuState',isClosed,'','/');
		}
		else {
			theObject.style.visibility = 'visible'; 
			theObject.style.display = 'block';
			headerObjectAnchor.style.color = thisBrandColor;
			headerObject.style.background = 'url(/images/vehicles/common/' + thisBrand + '/' + thisBrandCode + '_finTool_slctd_header.gif) no-repeat';	
			setCookie('finToolMenuState',isOpen,'','/');
		}
		
} 

function finToolItemOn(itemId,litemId){ 
        var theObject = getRef(itemId); 
		var theLinkObject = getRef(litemId);	
		theLinkObject.style.color = thisBrandColor;
		theObject.style.background = 'url(/images/vehicles/common/' + thisBrand + '/' + thisBrandCode + '_shop_hvr_item_bg.gif) 0px 0px no-repeat';
}

function finToolItemOff(itemId,litemId){ 
        var theObject = getRef(itemId); 	
		var theLinkObject = getRef(litemId);
		
		theLinkObject.style.color = thisBrandDfltColor;
		theObject.style.background = 'url(/images/vehicles/common/' + thisBrand + '/' + thisBrandCode + '_shop_item_bg.gif) 0px 0px no-repeat';
}

function finToolTopItemOn(itemId,litemId){ 
        var theObject = getRef(itemId); 
		var theLinkObject = getRef(litemId);	
				
		theLinkObject.style.color = thisBrandColor;
		theObject.style.background = 'url(/images/vehicles/common/' + thisBrand + '/' + thisBrandCode + '_finTool_hvr_shdw.gif) 0px 0px no-repeat';
}

function finToolTopItemOff(itemId,litemId){ 
        var theObject = getRef(itemId); 	
		var theLinkObject = getRef(litemId);
		
		theLinkObject.style.color = thisBrandDfltColor;
		theObject.style.background = 'url(/images/vehicles/common/' + thisBrand + '/' + thisBrandCode + '_finTool_shdw.gif) 0px 0px no-repeat';
}

function finToolBtmItemOn(itemId,litemId){ 
        var theObject = getRef(itemId); 
		var theLinkObject = getRef(litemId);	
				
		theLinkObject.style.color = thisBrandColor;
		theObject.style.background = 'url(/images/vehicles/common/' + thisBrand + '/' + thisBrandCode + '_finTool_hvr_btm.gif) 0px 0px no-repeat';
}

function finToolBtmItemOff(itemId,litemId){ 
        var theObject = getRef(itemId); 	
		var theLinkObject = getRef(litemId);
		
		theLinkObject.style.color = thisBrandDfltColor;
		theObject.style.background = 'url(/images/vehicles/common/' + thisBrand + '/' + thisBrandCode + '_finTool_btm.gif) 0px 0px no-repeat';
}

function finToolDblItemOn(itemId,litemId){ 
        var theObject = getRef(itemId); 
		var theLinkObject = getRef(litemId);	
		theLinkObject.style.color = thisBrandColor;
		theObject.style.background = 'url(/images/vehicles/common/' + thisBrand + '/' + thisBrandCode + '_shop_lrg_hvr_item_bg.gif) 0px 0px no-repeat';
}

function finToolDblItemOff(itemId,litemId){ 
        var theObject = getRef(itemId); 	
		var theLinkObject = getRef(litemId);

		theLinkObject.style.color = thisBrandDfltColor;
		theObject.style.background = 'url(/images/vehicles/common/' + thisBrand + '/' + thisBrandCode + '_shop_lrg_item_bg.gif) 0px 0px no-repeat';
}

function finToolHeaderOn(itemId,litemId){ 
        var theObject = getRef(itemId); 
		var theLinkObject = getRef(litemId);	
		var isOpen = getRef('finToolsList');
		
		if (isOpen.style.visibility == 'visible') {
			theLinkObject.style.color = thisBrandColor;
			theObject.style.background = 'url(/images/vehicles/common/' + thisBrand + '/' + thisBrandCode + '_finTool_slctd_header.gif) no-repeat';
		}
		else {
			theLinkObject.style.color = thisBrandColor;
			theObject.style.background = 'url(/images/vehicles/common/' + thisBrand + '/' + thisBrandCode + '_finTool_hvr_header.gif) no-repeat';
		}
}

function finToolHeaderOff(itemId,litemId){ 
        var theObject = getRef(itemId); 	
		var theLinkObject = getRef(litemId);
		var isOpen = getRef('finToolsList');
		
		if (isOpen.style.visibility == 'visible') {
			theLinkObject.style.color = thisBrandColor;
			theObject.style.background = 'url(/images/vehicles/common/' + thisBrand + '/' + thisBrandCode + '_finTool_slctd_header.gif) no-repeat';
		}
		else {
			theLinkObject.style.color = thisBrandDfltColor;
			theObject.style.background = 'url(/images/vehicles/common/' + thisBrand + '/' + thisBrandCode + '_finTool_header.gif) no-repeat';
		}			
}


// sets highlight states for menu LI 
function highLight(item,atag) {
	if (document.getElementById) {
		document.getElementById(item).style.backgroundColor = '#999';
		document.getElementById(item).style.cursor = 'hand';
		document.getElementById(atag).style.color = '#fff';
	}
}

function highLightOff(item,atag) {
	if (document.getElementById) {
		document.getElementById(item).style.backgroundColor = '#fff';
		document.getElementById(atag).style.color = '#000';
	}
}

// highlight arrows for shop menu
function highLightArrow(whichArrow) {
	if (document.getElementById) {
		document.getElementById(whichArrow).src = '/images/common/shop_menu_arrow_on.gif';
	}
}

function highLightArrowOff(whichArrow) {
	if (document.getElementById) {
		document.getElementById(whichArrow).src = '/images/common/shop_menu_arrow.gif';
	}
}

function dblHighLightArrow(whichArrow) {
	if (document.getElementById) {
		document.getElementById(whichArrow).src = '/images/vehicles/common/compareshop/' + thisBrand + '_shop_menu_arrow_on.gif';
	}
}

function dblHighLightArrowOff(whichArrow) {
	if (document.getElementById) {
		document.getElementById(whichArrow).src = '/images/vehicles/common/compareshop/' + thisBrand + '_shop_menu_arrow.gif';
	}
}