/****** User may alter these to change the fade effect ********/
var FadeInStep 	= 20;
var FadeOutStep 	= 20;
/****** Don't alter anything else **************/
document.write('<STYLE TYPE="text/css">.imgFader{ position:relative; filter:alpha(opacity=0); -moz-opacity:0.0 }</STYLE>');

if(!window.FADE)
	FADE=new Object();

FADE.RolloverObjects=new Array();

FADE.Rollover = function(name, img)
{
	FADE.RolloverObjects[name]=new Image();
	FADE.RolloverObjects[name].img_src = img;	
	if(!FADE.Rollover.postLoad)
		FADE.RolloverObjects[name].src = img;
}
FADE.Rollover.postLoad = false;
FADE.Rollover.loadImages = function()
{
	var i;
	for(i in FADE.RolloverObjects)
	{
		r=FADE.RolloverObjects[i];
		r.src=r.img_src;
	}
}
FADE.Rollover.error = function(n)
{
		alert("FADE.Rollover - An Error has been detected\n"
			+ "----------------------------------\n"
			+ "You must define a FADE.Rollover in your document\n"
			+ "FADE.Rollover(\""+n+"\",\"your_on_img.gif\")\n"
			+ "(check the spelling of your FADE.Rollovers)");
}
/*******************************************************************
*
* Function    : getImg
*
* Description : In Netscape 4 images could be in layers so we might
*		    have to recurse the layers to find the image
*
*****************************************************************/
FADE.getImg = function(n, d) 
{
	var img = d.images[n];
	if(!img && d.layers)  
		for(var i=0 ; !img && i<d.layers.length ; i++)
			img=FADE.getImg(n,d.layers[i].document);
	return img;
}
/*******************************************************************
*
* Function    : findImg
*
* Description : gets the image from the document and reports an
*		    error if it cannot find it.
*
*****************************************************************/
FADE.findImg = function(n, d) 
{
	var img = FADE.getImg(n, d);

	/*** Stop emails because the image was named incorrectly ***/
	if(!img)
	{
		alert("FADE.findImg - An Error has been detected\n"
			+ "----------------------------------\n"
			+ "You must define an image in your document\n"
			+ "<IMG SRC=\"your_image.ext\" NAME=\""+n+"\">\n"
			+ "(check the NAME= attribute of your images)");

		return(new Image());
	}
	return img;
}

FADE.ImageFadeRunning=false;
FADE.ImageFadeInterval=30;

/*******************************************************************
*
* Function    : imgFadeIn
*
* Description : This function is based on the turn_on() function
*		      of animate2.js (animated rollovers from www.roy.whittle.com).
*		      Each image object is given a state. 
*			OnMouseOver the state is switched depending on the current state.
*			Current state -> Switch to
*			===========================
*			null		->	OFF.
*			OFF		->	FADE_IN
*			FADE_OUT	->	FADE_IN
*			FADE_OUT	->	FADE_OUT_IN (if the new image is different)
*			FADE_IN_OUT->	FADE_IN (if the image is the same)
*****************************************************************/
FADE.imgFadeIn = function(img, imgSrc)
{
	if(img) 
	{
		if(img.state == null) 
		{
			img.state = "OFF";
			img.index = 0;
			img.next_on    = null;
		}

		if(img.state == "OFF")
		{
			/*** Vers 1.7 only load the ON image once ever ***/
			if(img.src.indexOf(imgSrc) == -1)
				img.src=imgSrc;

			img.currSrc = imgSrc;
			img.state = "FADE_IN";
			FADE.startFading();
		}
		else if( img.state == "FADE_IN_OUT"
			|| img.state == "FADE_OUT_IN"
			|| img.state == "FADE_OUT")
		{
			if(img.currSrc == imgSrc)
				img.state = "FADE_IN";
			else
			{

				img.next_on = imgSrc;
				img.state="FADE_OUT_IN";
			}
		}
	}
}
/*******************************************************************
*
* Function    : imgFadeOut
*
* Description : This function is based on the turn_off function
*		      of animate2.js (animated rollovers from www.roy.whittle.com).
*		      Each image object is given a state. 
*			OnMouseOut the state is switched depending on the current state.
*			Current state -> Switch to
*			===========================
*			ON		->	FADE_OUT.
*			FADE_IN	->	FADE_IN_OUT.
*			FADE_OUT_IN	->	FADE_IN. (after swapping to the next image)
*****************************************************************/
FADE.imgFadeOut = function(img)
{
	if(img)
	{
		if(img.state=="ON")
		{
			img.state="FADE_OUT";
			FADE.startFading();
		}
		else if(img.state == "FADE_IN")
		{
			img.state="FADE_IN_OUT";
		}
		else if(img.state=="FADE_OUT_IN")
		{
			img.next_on == null;
			img.state = "FADE_OUT";
		}
	}
}
/*******************************************************************
*
* Function    : startFading
*
* Description : This function is based on the start_animating() function
*	        	of animate2.js (animated rollovers from www.roy.whittle.com).
*			If the timer is not currently running, it is started.
*			Only 1 timer is used for all objects
*****************************************************************/
FADE.startFading = function()
{
	if(!FADE.ImageFadeRunning)
		FADE.ImageFadeAnimation();
}

/*******************************************************************
*
* Function    : ImageFadeAnimation
*
* Description : This function is based on the Animate function
*		    of animate2.js (animated rollovers from www.roy.whittle.com).
*		    Each image object has a state. This function
*		    modifies each object and (possibly) changes its state.
*****************************************************************/
FADE.ImageFadeAnimation = function()
{
	FADE.ImageFadeRunning = false;
	for(i=0 ; i<document.images.length ; i++)
	{
		var img = document.images[i];
		if(img.state)
		{
			if(img.state == "FADE_IN")
			{
				img.index+=FadeInStep;

				if(img.index > 100)
					img.index = 100;

				if(img.filters)
					img.filters.alpha.opacity = img.index;
				else
					img.style.MozOpacity = img.index/101;

				if(img.index == 100)
					img.state="ON";
				else
					FADE.ImageFadeRunning = true;
			}
			else if(img.state == "FADE_IN_OUT")
			{
				img.index+=FadeInStep;
				if(img.index > 100)
					img.index = 100;

				if(img.filters)
					img.filters.alpha.opacity = img.index;
				else 
					img.style.MozOpacity = img.index/101;

	
				if(img.index == 100)
					img.state="FADE_OUT";

				FADE.ImageFadeRunning = true;
			}
			else if(img.state == "FADE_OUT")
			{
				img.index-=FadeOutStep;
				if(img.index < 0)
					img.index = 0;

				if(img.filters)
					img.filters.alpha.opacity = img.index;
				else
					img.style.MozOpacity = img.index/101;


				if(img.index == 0)
					img.state="OFF";
				else
					FADE.ImageFadeRunning = true;
			}
			else if(img.state == "FADE_OUT_IN")
			{
				img.index-=FadeOutStep;
				if(img.index < 0)
					img.index = 0;

				if(img.filters)
					img.filters.alpha.opacity = img.index;
				else
					img.style.MozOpacity = img.index/101;

				if(img.index == 0)
				{
					img.src = img.next_on;
					img.currSrc = img.next_on;
					img.state="FADE_IN";
				}
				FADE.ImageFadeRunning = true;
			}
		}
	}
	/*** Check to see if we need to animate any more frames. ***/
	if(FADE.ImageFadeRunning)
		setTimeout("FADE.ImageFadeAnimation()", FADE.ImageFadeInterval);
}
/*******************************************************************
*
* Function    : hasOpacity
*
* Description : Tests if the browser allows Opacity
*
*****************************************************************/
FADE.hasOpacity = function(obj)
{
	if(document.layers)
		return false;

	if(window.opera)
		return false;

	if(navigator.userAgent.toLowerCase().indexOf("mac") != -1)
		return false;

	return true;
}
/*******************************************************************
*
* Function    : fadeIn /fadeOut
*
* Description : Detects browser that can do opacity and fades the images
*		    For browsers that do not support opacity it just does an image swap.
*		    (I only know about NS4 but maybe IE on a Mac also ?)
*		    For these functions to work you need to name the image
*			e.g. for an image named "home" you need
*			<IMG .... NAME="home">
*		    and you need 2 images, the on and the off image
*****************************************************************/
FADE.fadeIn = function(imgName, rollName)
{
	if(rollName == null)
		rollName=imgName;

	/*** Stop emails because the rollover was named incorrectly ***/
	if(!FADE.RolloverObjects[rollName])
	{
		FADE.Rollover.error(rollName);
		return;
	}

	var img = FADE.findImg(imgName, document);
	if(FADE.hasOpacity(img))
		FADE.imgFadeIn(img, FADE.RolloverObjects[rollName].img_src);
	else
	{
		if(img.offSrc==null)
			img.offSrc=img.src;
		img.src=FADE.RolloverObjects[rollName].img_src;
	}
}
FADE.fadeOut = function(imgName)
{
	var img = FADE.findImg(imgName, document);
	if(FADE.hasOpacity(img))
		FADE.imgFadeOut(img);
	else
		img.src=img.offSrc;
}
/*******************************************************************
*
* Function    : imgOn /imgOff
*
* Description : Included these functions so you can mix simple and
*		    fading rollovers without having to include 2 ".js" files
*
*****************************************************************/
FADE.imgOn = function(imgName, rollName)
{
	if(rollName == null)
		rollName=imgName;

	/*** Stop emails because the rollover was named incorrectly ***/
	if(!FADE.RolloverObjects[rollName])
	{
		FADE.Rollover.error(rollName);
		return;
	}
	var img = FADE.findImg(imgName,document);
	if(img.offSrc==null)
		img.offSrc=img.src;
	img.src=FADE.RolloverObjects[rollName].img_src;
}
FADE.imgOff = function(imgName)
{
	var img = FADE.findImg(imgName,document);
	img.src=img.offSrc;
}


	/*** MouseOver / Show Hide Layer Code ***/

function reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

	/*** List of the thumbnails on the Gallery Page ***/
	FADE.Rollover("buttonBalcony", "images/btnBalcony_on.gif");
	FADE.Rollover("buttonJazz", "images/btnJazz_on.gif");
	FADE.Rollover("buttonSavanda", "images/btnSavanda_on.gif");
	FADE.Rollover("buttonBcc", "images/btnBcc_on.gif");
	FADE.Rollover("buttonBcb", "images/btnBcb_on.gif");
	FADE.Rollover("buttonHand", "images/btnHand_on.gif");
	FADE.Rollover("buttonStop", "images/btnStop_on.gif");
	FADE.Rollover("buttonLadyStanding", "images/btnLadyStanding_on.gif");
	FADE.Rollover("buttonLadyCar", "images/btnLadyCar_on.gif");
	FADE.Rollover("buttonSlider", "images/btnSlider_on.gif");
	FADE.Rollover("buttonDaspo", "images/btnDaspo_on.gif");
	FADE.Rollover("buttonFlagstar", "images/btnFlagstar_on.gif");
	FADE.Rollover("buttonHighMileage", "images/btnHighMileage_on.gif");
	FADE.Rollover("buttonSenior", "images/btnSenior_on.gif");
	FADE.Rollover("buttonFcs", "images/btnFcs_on.gif");
	FADE.Rollover("buttonOhsim", "images/btnOhsim_on.gif");
	FADE.Rollover("buttonOutfitters", "images/btnOutfitters_on.gif");
	FADE.Rollover("buttonPowertrain", "images/btnPowertrain_on.gif");
	FADE.Rollover("buttonTyc", "images/btnTyc_on.gif");
	FADE.Rollover("buttonMerc", "images/btnMerc_on.gif");
	FADE.Rollover("buttonMj", "images/btnMj_on.gif");
	FADE.Rollover("buttonDds", "images/btnDds_on.gif");
	FADE.Rollover("buttonRt", "images/btnRt_on.gif");
	FADE.Rollover("buttonPd", "images/btnPd_on.gif");
	FADE.Rollover("buttonVls", "images/btnVls_on.gif");
	FADE.Rollover("buttonWcs", "images/btnWcs_on.gif");
	FADE.Rollover("btnOne", "images/btnOne_on.gif");
	FADE.Rollover("btnTwo", "images/btnTwo_on.gif");
	FADE.Rollover("btnThree", "images/btnThree_on.gif");
	FADE.Rollover("btnFour", "images/btnFour_on.gif");