<!--
// generic positive number decimal formatting function
function format (expr, decplaces) {
	// raise incoming value by power of 10 times the
	// number of decimal places; round to an integer; convert to string
	var str = "" + Math.round (eval(expr) * Math.pow(10,decplaces));
	// pad small value strings with zeros to the left of rounded number
	while (str.length <= decplaces) {
		str = "0" + str;
	}
	// establish location of decimal point
	var decpoint = str.length - decplaces;
	// assemble final result from: (a) the string up to the position of
	// the decimal point; (b) the decimal point; and (c) the balance
	// of the string. Return finished product.
	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
}

// turn incoming expression into a pound value
function dollarize (expr) {
	return format(expr,2);
}

//--------------------------------------------------------------------------------------------------------------------------------
//see what user has selected in options
function inspectBox(PC)
// PC = product number 1,2,3...99 
{
	//Calculate the base price + options of the product number "A" (ie withOUT monitor)
	//Get base price for product 1 option A is BasePrice1A
	var BasePriceA = eval("BasePrice" + PC + "A")
	var OptionsPrice = calcPrice(PC,"A")
	BasePriceA += OptionsPrice

	//Calculate the base price + options of the product number "B" (ie WITH monitor)
	var BasePriceB = eval("BasePrice" + PC + "B")			
	OptionsPrice = calcPrice(PC,"B")
	BasePriceB += OptionsPrice

	//Display the price to the user, in pounds and pence
	document.all.TOTALA.value="£" + format(BasePriceA/100,2);
	document.all.TOTALB.value="£" + format(BasePriceB/100,2);


	//now update the deposit required - whichever button is pressed use corresponding total and 25% percentage 
	//and also update the product item-name (as known by PAYPAL) to include whether monitor required
	if (document.all.PC[0].checked)
	{
		document.all.PAYPAL.amount.value= format(BasePriceA/400,2);
		document.all.PAYPAL.item_name.value = "Deposit for Starters Orders Personal Computer NO monitor"
	}else{
		document.all.PAYPAL.amount.value= format(BasePriceB/400,2);
		document.all.PAYPAL.item_name.value = "Deposit for Starters Orders Personal Computer WITH monitor"
	}
	
	//update the product id field (as known by PAYPAL) to contain all the options checked by the user
	if (globOptions == "") {
	document.all.PAYPAL.os1.value = "No options selected"
	}else{
	document.all.PAYPAL.os1.value = globOptions
	}
}

//------------------------------------------------------------------------------------------------------------------------------------
function doPageTitles(ProdNo)
{
	with (document.all)
	{
		pageSubTitle.innerText = eval("pageSubTitle" + ProdNo)
		prodTitle.innerHTML = eval("prodTitle" + ProdNo)
		prodSubTitle.innerHTML = eval("prodSubTitle" + ProdNo)
		getKeyFeatures(ProdNo)
		prodDesc.innerHTML = eval("prodDesc" + ProdNo)
		if (screen.width < 2000)
		{	prodPhoto.innerHTML = '<IMG src="' + eval("prodPhoto" + ProdNo +'Small') + '" border="0" alt="Product Photo">'}
		else{
		prodPhoto.innerHTML = '<IMG src="' + eval("prodPhoto" + ProdNo ) + '" border="0" alt="Product Photo">'}
		
		prodMonSize.innerHTML = "<font size=small>" + eval("MonSize" + ProdNo) + "</font>"
	}

}

function getKeyFeatures(PCno)
// format is <text description>~ToolTipName~<rest of anchored description>~[<remaining text>]
{
var KeyFeature='<ul style="padding-top: 1em" type="square">'

	for (var i=0; i < eval("prodFeatures" + PCno).length; i++)
	{
		thisprod=eval("prodFeatures" + PCno)[i]
		
		//Get first delimiter: tooltip name start
		var FirstT = thisprod.indexOf("~")
		
		//None found, so no tooltip - ignore
		if (FirstT == -1) {
			//if no tooltip then just add this into the list
			KeyFeature += "<li>" + thisprod + "</li>"
			continue}
		//alert("1st:" + FirstT)
		
		//Get second tilde: start of anchor
		var MidT = thisprod.indexOf("~", FirstT+1)
		if (MidT == -1) {
			//if no tooltip then just add this into the list
			KeyFeature += "<li>" + thisprod + "</li>"
			continue}
		//alert("2nd:" +MidT)
		
		//Get last tilde: anchor end
		var LastT = thisprod.lastIndexOf("~")
		if (LastT == MidT) {
			//if no tooltip then just add this into the list
			KeyFeature += "<li>" + thisprod + "</li>"
			continue}
		//alert("Final:" + LastT)
		
		//Extract Tooltip name
		var TTname = thisprod.slice(FirstT+1, MidT)
		//alert(TTname)
		
		//Build the final script
		KeyFeature += "<li>" //start of list item
		KeyFeature += thisprod.slice(0,FirstT) //first part of text
		KeyFeature += "<a href='javascript:void(0)' onMouseOver='ToolTip(\"" //start of anchor
		KeyFeature += TTname + "\")' onMouseOut='ToolTip(\"\")'>" //tooltip name and remaining anchor
		KeyFeature += thisprod.slice(MidT+1,LastT) + "</a>"//text to be clickable
		KeyFeature += thisprod.slice(LastT+1)+"</li>" //all remaining text
		//alert(KeyFeature)
	}
	KeyFeature += "</ul>"	
	document.all.prodFeatures.innerHTML = KeyFeature
}



//------------------------------------------------------------------------------------------------------------------------------------ 
function GetPageNo()
//establish which page we are displaying here from URL - default = page 1
//this corresponds directly with the product number 1,2,3...99
{
var PCno;
var thispage = location.href;
var PagePos = thispage.indexOf("Page",0);
if (PagePos == -1)
	{
	PCno=1;
	}
	else
	{PCno= thispage.slice(PagePos + 4);
	}
//alert("Generating values for page " +PCno)
return PCno;
}



//------------------------------------------------------------------------------------------------------------------------------
function ToolTip(Obj)
//Display tooltip on specific word(s) in Key Features list
{
	var myLeft = window.event.x + 20
	var myTop = window.event.y + document.body.scrollTop
	
	//If the name of an item was passed eg RAM
	if (Obj !="")
	{
		document.all.ToolTip.innerHTML = eval(Obj + "help")
		document.all.ToolTip.style.left = myLeft
		document.all.ToolTip.style.top = myTop
		document.all.ToolTip.style.visibility = "visible"
	}else
	{
	document.all.ToolTip.style.visibility = "hidden"
	}
}



//------------------------------------------------------------------------------------------------------------------------------
function buildProdMenus()
{
var smallMenu = ""
var bigMenu = ""
var hrefends = 0

	//build the full menu
	for (var i=0; i<prodMenu.length; i++)
	{
		//start the a link
		bigMenu += "<a class=menuItem href='" 
		
		//get the position of the * in the database description of this menu item
		hrefends = prodMenu[i].lastIndexOf('*')
		bigMenu += prodMenu[i].slice(0, hrefends)
		bigMenu += "' >" + prodMenu[i].slice(++hrefends) + "</a> <hr size=1>"
	}
	//bigMenu +="<a href='javascript:void(0)' Id=expand class=menuItem onClick=showMenu('S')>...Less</a>"
	document.all.MENU2.innerHTML = bigMenu

	//Retrieve the (autogenerated) height that accommodates the menu...
	var oDiv = document.getElementById('MENU2')
	
	//Store that menu Height in a global var
	menuMaxHeight = oDiv.clientHeight - 10
	
	//Now set the height explicitly so we can perform maths in the SlideMenu routine
	document.all.MENU2.style.height = menuMaxHeight 
	
	//Slide that menu!
	startMenu()
}	


function showMenu(size)
{			
		if (size == "B") {
				document.all.MENU.style.display="none"
				document.all.MENU2.style.display="block"
		}else{
				document.all.MENU2.style.display="none"
				document.all.MENU.style.display="block"
		}
}

// Product menu autoscrolling --------------------------------------------------------------------------------------------------

//Global variables to keep track of where we are
var MYID=""
var prodMenuFlag = 1 //set to true (ie expanded) so menu will shrink immediately upon rendering the page - cool effect

//timer for menu
function startMenu()
{
	prodMenuFlag = !prodMenuFlag
	if (prodMenuFlag)
	//open
	{MYID = setInterval("slideMenu(90,15,menuMaxHeight)",5)
	}else{
	//close
	MYID = setInterval("slideMenu(menuMaxHeight,-10,90)",3)
	}
}

//show menu routine
//uses MENU div (relative) and Trailer div block (absolute) immediately thereafter
function slideMenu(startH, incBy, stopVal)
{		if (incBy < 0) //Close
		{
			if (parseInt(document.all.MENU2.style.height) < stopVal)
			{ clearInterval(MYID) 
			document.all.Trailer.innerHTML = "<a class='menusublinks' href='javascript:void(0)'>More...</a>"			
			}
			else
			{
			document.all.Trailer.innerHTML = "<a  href='javascript:void(0)'>Closing...</a>"			
			document.all.MENU2.style.height = parseInt(document.all.MENU2.style.height) + incBy}
		}
		else //expand
		{
			if (parseInt(document.all.MENU2.style.height) > stopVal)
			{ clearInterval(MYID) 
			document.all.Trailer.innerHTML = "<a class='menusublinks' href='javascript:void(0)' color=yellow>Close...</a>"			
			}
			else
			{
						document.all.Trailer.innerHTML = "<a href='javascript:void(0)'>Expanding...</a>"			
			document.all.MENU2.style.height = parseInt(document.all.MENU2.style.height) + incBy}
		}
}
-->