

/* -- Dropdown Nav Scripts -- */
// Copyright 2006-2007 javascript-array.com

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 


// Warning Div


	function getScrollPosition() {
		// return an array with the window scrolling offsets
		var xPos = 0;
		var yPos = 0;
		if (typeof( window.pageYOffset ) == 'number') {
			xPos = window.pageXOffset;
			yPos = window.pageYOffset;
		} else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
			xPos = document.body.scrollLeft;
			yPos = document.body.scrollTop;
		} else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
			xPos = document.documentElement.scrollLeft;
			yPos = document.documentElement.scrollTop;
		}
		return [xPos, yPos];

	}


	function clipLink(url) {
		var theRootTable = document.getElementById('rootTable');
		var theLightBox  = document.getElementById('lightbox');

		theRootTable.className = 'lightboxed';

		var linkOutContents = "<table class='linkOutDialog' cellspacing='0' cellpadding='0'>";
		linkOutContents    += "<tr><td colspan='2' style='height: 390px;'>&#160;</td></tr>";
		linkOutContents    += "<tr>";
		linkOutContents    += "<td class='linkOutLinkHolder'><a href='" + url + "' onclick='dismissLightbox();' target='_blank'>I AGREE<br>Take me there.</a></td>";
		linkOutContents    += "<td class='linkOutLinkHolder'><a href='#' onclick='dismissLightbox();'>I DISAGREE<br> Keep me here.</a></td>";
		linkOutContents    += "</tr>";
		linkOutContents    += "</table>";

		theLightBox.innerHTML = linkOutContents;

		var rtLeft   = theRootTable.offsetLeft;
		var rtWidth  = theRootTable.offsetWidth;
		var rtCenter = (rtLeft + Math.round(rtWidth/2));

		var lbLeft   = (rtCenter - Math.round(theLightBox.offsetWidth / 2));
		var lbTop    = getScrollPosition()[1] + 100;


		
		theLightBox.style.top = lbTop;
		theLightBox.style.left = lbLeft;
	}
	function dismissLightbox() {
		var theRootTable = document.getElementById('rootTable');
		var theLightBox  = document.getElementById('lightbox');

		theRootTable.className = 'root';
		theLightBox.innerHTML = '';
		theLightBox.style.top = -200;
	}





/* -- Quick Menu Nav Scripts (n is the groun number -- l is the link number)  -- */
function showGroup(n, l) {
	// Set the selected DIV group and content variable
	var theGroup = document.getElementById('g'+n);
	var theContents = theGroup.getElementsByTagName('span')[0];
	var theImagePath = theGroup.style.backgroundImage;
	var theImageName = theImagePath.substring(theImagePath.lastIndexOf('/') + 1,theImagePath.lastIndexOf('.'));


	// Check to see if the Link variable is set
	if (l) {
		var theLink = theGroup.getElementsByTagName('a')[l];
		if (n == 9 || n == 10){
			theLink.style.color = '000000';
		} else {
			theLink.style.color = 'ff0000';
		}
		theGroup.getElementsByTagName('a')[0].style.color = '#000000';
	}
	
	
	// Check to see if the selected group is closed
	if (theImageName == "quickMenuDark" || theImageName == "quickMenuRed" || theImageName == "quickMenuGrey") {
		// The group was closed
		//alert (theImageName);
		closeGroups();
				
		if (n == 9){
			theGroup.style.backgroundImage="url(/images/backgrounds/quickMenuRed2.jpg)";
		} else if (n == 10){
			theGroup.style.backgroundImage="url(/images/backgrounds/quickMenuGrey2.jpg)";
		} else {
			theGroup.style.backgroundImage="url(/images/backgrounds/quickMenuLight.jpg)";
		}
				
		theContents.style.display = 'block';
	} else {
		// The group was open
		closeGroups();
	}
}


function closeGroups() {
	
	for(i=1;i<9;i++)
		{
			if (document.getElementById('g'+i)) {
				document.getElementById('g'+i).style.backgroundImage = "url(/images/backgrounds/quickMenuDark.jpg)";
				document.getElementById('g'+i).getElementsByTagName('span')[0].style.display = 'none';
			}
		}
			
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function showNews(theURL) { //v2.0
  window.open('/news/'+theURL,'','scrollbars=yes,resizable=yes,width=1050,height=650');
}

function showPop(theURL) { //v2.0
  window.open(theURL,'','scrollbars=yes,resizable=yes,width=600,height=550');
}

function gotoStore(theURL) {
  window.open(theURL, '_blank');
}


function showModelImg(modelNum){
	document.getElementById('lgImage').src = 'images/'+ modelNum +'.jpg';
}




function showExtra(theDiv){
	//alert(theDiv);
	var divs = document.getElementsByTagName("div");
	for (var i=0; i<divs.length; i++)
	if (divs[i].id.indexOf("e_") == 0) divs[i].style.display = "none"; 
	
	document.getElementById('e_' + theDiv).style.display = "block";
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function swapImage(obj, img) {
	obj.src = img;
}

