// JavaScript Document

	// Function to find the browser and return the ID
	function fnFindBrowserID(theID)
	{
		if (document.layers)// for Mozila
		{
			theID = document.layers[theID];
		}
		else if (document.all)// IE
		{
			theID = document.all[theID];
		}
		else // Others
		{
			theID = document.getElementById(theID);
		}
		return theID;	
	}
	
	// This function swaps an image for another in a given id
	function fnSwapImage(theID, theImage)
	{
		// Function to change an image to another image.
		theID = fnFindBrowserID(theID);		
		theID.src=theImage;		
	}
	
	// Takes in an id and some text and changes the text in the id to the new text
	function fnChangeText(theID, theText)
	{
		theID = fnFindBrowserID(theID);
		theID.firstChild.nodeValue=theText;
	}

	// Takes a price and a postage price and sorts out the sub-total, VAT, postage and Total
	function fnPrices(price, theTax, theItemName, theItem)
	{
		theVAT = (Math.round(price*100)/100)*0.175;
		theVAT = Math.round(theVAT*100)/100;
		thePrice = Math.round(price*100)/100;
		//thePost = Math.round(post*100)/100;
		theTotal = thePrice+theVAT;
		
		//theShipping = fnFindBrowserID(theShipping);
		//theShipping.value = post;
		
		theItem = fnFindBrowserID(theItem);
		theItem.value = theItemName;
		
		theTax = fnFindBrowserID(theTax);
		theTax.value = theVAT;
		
		fnChangeText('idSub', thePrice);
		fnChangeText('idVAT', theVAT);
		//fnChangeText('idPost', thePost);
		fnChangeText('idTot', theTotal);
	}
	
