function b(c)
{
	makeActive(c);
}

function tabOver(item)
{
	if( item.className == "tabActive" )
		item.className = "tabActiveOver";
	else
		item.className = "tabOver";

	return true;
}

function tabOut(item)
{
	if( ( item.className == "tabActiveOver" || item.className == "tabActive" ) )
		item.className = "tabActive";
	else
		item.className= "tab";

	return true;
}

function tabClick(item)
{
	makeActive(item);

	var max = 0;

	if( item.innerHTML.indexOf(" ") > 0 )
		max = item.innerHTML.indexOf(" ");
	else
		max = item.innerHTML.length;

	var itemReference = item.innerHTML.substring( 0, max )

	show(itemReference);

	return true;
}

function getMakeFolder()
{
	if( location.href.indexOf("dodge/") > -1 ) return "dodge/";
	if( location.href.indexOf("ford/") > -1 ) return "ford/";
	if( location.href.indexOf("gm/") > -1 ) return "gm/";
	if( location.href.indexOf("international/") > -1 ) return "international/";
	if( location.href.indexOf("jeep/") > -1 ) return "jeep/";
	if( location.href.indexOf("mazda/") > -1 ) return "mazda/";
	if( location.href.indexOf("nissan/") > -1 ) return "nissan/";
	if( location.href.indexOf("toyota/") > -1 ) return "toyota/";
	return "";
}

function moreInfo( u, w, h ) { openWindow( ROOT_PATH + "library/" + getMakeFolder() + u, w, h ); }

function openWindow( u, w, h )
{
	var newWindow = window.open( u, "requestedPopup", "width="+w+", height="+h+", resizable=yes, scrollbars=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, copyhistory=no" );
	centerWindow( newWindow, w, h ); 
}

function openWindowWithContent( w, h, t, c )
{
	var newWindow = window.open( "", "requestedPopup", "width="+w+", height="+h+", resizable=yes, scrollbars=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, copyhistory=no" );
	centerWindow( newWindow, w, h );
	newWindow.document.body.innerHTML = "";
	newWindow.document.write("<html><body style=\"background-color:#FFFFFF;color:#000000;padding:5px;font:8pt Arial, Helvetica, sans-serif;\">\n\n<div style=\"font-size:12pt;font-weight:bold;padding-bottom:5px;margin-bottom:5px;border-bottom:solid 1px #CCCCCC;\">" + t + "</div>\n\n" + c + "\n\n<hr /><center><a href=\"javascript:window.close();\">Close Window</a></center></body></html>");
}

function centerWindow( win, w, h )
{
	var x = 1024;
	var y = 768;

	if( window.screen )
	{
		x = (window.screen.width / 2) - (w / 2);
		y = (window.screen.height / 2) - (h / 2);
	}

	win.moveTo( x, y );
}

function resizeCenterAndGo( u, w, h )
{
	window.resizeTo(w,h);
	centerWindow(window,w,h);
	location.href = u;
}


var IE = document.all ? true : false;
if ( !IE ) document.captureEvents(Event.MOUSEMOVE);

var cursorX = 0;
var cursorY = 0;

function getMouseXY(e)
{

	if( IE )
	{
		cursorX = event.clientX + document.body.scrollLeft;
		cursorY = event.clientY + document.body.scrollTop;
	} else {
		if( e.pageX != null && e.pageY != null )
		{
			cursorX = e.pageX;
			cursorY = e.pageY;
		}
	}

	if( cursorX < 0 ) cursorX = 0;
	if( cursorY < 0 ) cursorY = 0;

	if( document.getElementById("tireNote") != null )
	{
		if( document.getElementById("tireNote").style.display != "none" )
		{
			document.getElementById("tireNote").style.top = ( cursorY + 10 ) + "px";
			document.getElementById("tireNote").style.left = ( cursorX + 10 ) + "px";
		}
	}

	return true;

}

function hideTireNote(e)
{
	if( document.getElementById("tireNote") != null )
	{
		if( document.getElementById("tireNote").style.display != "none" ) document.getElementById("tireNote").style.display = "none";
	}

	return true;	
}

var elemOpacity = 0;
var fadeElem = null;

function beginFade(elem)
{
	if( IE && elem.style.display != "block" )
	{
		prevElemOpacity = 100;
		currElemOpacity = 0;
		fadeElem = elem;
		fadeElem.style.filter = "Alpha(Style=0,Opacity=0);";
		fadeElem.style.display = "block";
		fadeIn();
	}
}

function fadeIn()
{
	if( elemOpacity < 100 )
	{
		fadeElem.style.filter = "Alpha(Style=0,Opacity=" + elemOpacity + ");";
		elemOpacity++;
		faderTimeout = setTimeout( "fadeIn()", 1 );
	} else {
		faderTimeout = null;
		faderTimeout = setTimeout( "fadeOut()", 15000 );
	}
}

function fadeOut(elem)
{
	if( elemOpacity > 0 )
	{
		fadeElem.style.filter = "Alpha(Style=0,Opacity=" + elemOpacity + ");";
		elemOpacity--;
		faderTimeout = setTimeout( "fadeOut()", 1 );
	} else {
		fadeElem.style.display = "none";
	}
}

function initializeMouseEvents()
{
	document.onmousemove = getMouseXY;
	document.onmouseclick = hideTireNote;
}
