// JavaScript Document

if( document.images )
{
	var home_btn = PreLoad( 'home' );
	var office_btn = PreLoad( 'office' );			//pre-loading all the images, so they don't have to load
	var kitchen_btn = PreLoad( 'kitchen' );			//when the user actually places the mouse over them,
	var car_btn = PreLoad( 'car' );			//by loading them into a var for each one
	var furniture_btn = PreLoad( 'furniture' );
	var electronics_btn = PreLoad( 'electronics' );
	var decorations_btn = PreLoad( 'decorations' );
	var garden_btn = PreLoad( 'garden' );
	var tools_btn = PreLoad( 'tools' );
	var plants_btn = PreLoad( 'plants' );
	var miscelectrical_btn = PreLoad( 'miscelectrical' );
	var misc_btn = PreLoad( 'misc' );
}

function PreLoad( btn )
{

	var img_path = "graphics/";			//file path to find button images
	var temp = new Array();
	
	temp[ 0 ] = new Image();				//don't know which image we're actually loading
	temp[ 1 ] = new Image();		
											//so format temp to hold an image, any image
											//then we can use .src to load each button img
	temp[ 0 ].src = img_path + btn + "_btn.gif";		//first version: no mouse over image
	temp[ 1 ].src = img_path + btn + "_btn_2.gif";		//second version: mouse over image

	return temp;
}

function Swap( img, mouse_on )				//reads img name from page and which version of the img 
{
	if( document.images )
	{	
		var img_name = ( img + "_btn" );		//(mouse_on) then inserts correct one	
		var temp = eval( img + "_btn" );
	
		document[ img_name ].src = temp[ mouse_on ].src;
	}
}