// Sams Liquid Waste Hire Javascript File

// SwitchImages
function SwitchImages(im1,im2,doc)
{
    // Set all Images to the mask
    MaskImages(doc);
   
   // Set the 2 Images to Clear
   var tmp1 = im1 + "_clear.jpg";
   var tmp2 = im2 + "_clear.jpg";
   
   doc.getElementById(im1).src = "Images/" + tmp1;
   doc.getElementById(im2).src = "Images/" + tmp2; 

}

// Load the Image
function loadImage(im)
{
	var i=new Image();
	i.src='Images/'+im;
	return i;
} 

function MaskImages(doc)
{
    doc.getElementById("Image1").src = "Images/Image1_mask.jpg";
    doc.getElementById("Image2").src = "Images/Image2_mask.jpg";
    doc.getElementById("Image3").src = "Images/Image3_mask.jpg";
    doc.getElementById("Image4").src = "Images/Image4_mask.jpg";
    doc.getElementById("Image5").src = "Images/Image5_mask.jpg";
    doc.getElementById("Image6").src = "Images/Image6_mask.jpg";
    doc.getElementById("Image7").src = "Images/Image7_mask.jpg";
    doc.getElementById("Image8").src = "Images/Image8_mask.jpg"; 
    
}

var currentlyPressedButton;
// Preset the Images
    homen = loadImage('Home.gif')
    homed = loadImage('HomeCLK.gif')
    homeo = loadImage('HomeRO.gif')
    toiln = loadImage('Toilets.gif')
    toild = loadImage('ToiletsCLK.gif')
    toilo = loadImage('ToiletsRO.gif')
    shown = loadImage('Showers.gif')
    showd = loadImage('ShowersCLK.gif')
    showo = loadImage('ShowersRO.gif')
    contn = loadImage('Contact.gif')
    contd = loadImage('ContactCLK.gif')
    conto = loadImage('ContactRO.gif')

// Toggle the images
function toggle(id,doc)
{ 
	x=id.substring(0,id.length-1); // get the name
	xe=id.substring(id.length-1,id.length); // get the end char 'o' or 'n' or 'd'

	if (currentlyPressedButton==x&&(xe=='n'||xe=='o'))   // if we're already pressed and a mouse out or mouse over then do nothing
		return;
	
	if (xe=='d') // if we are a mouse down
	{
		if(currentlyPressedButton != '-1')  // if currently pressed button is already pressed
		{
			doc.getElementById(currentlyPressedButton).src=eval(currentlyPressedButton+'n'+'.src'); // switch the currently pressed item to the normal gif
		}

		currentlyPressedButton=x; // assign the currently pressed item to the selected item
	} 

	doc.getElementById(x).src=eval(id+'.src'); // load the new image for the selected button

}

function setCurrent(im)
{
    currentlyPressedButton = im;
}

function preloadImages(doc)
{
    // set the image to
    if(currentlyPressedButton != '-1')
	    toggle(currentlyPressedButton+'d',doc);
}