//the better price formating
function just(here)
{
string = "" + here;
number = string.length - string.indexOf('.');
if (string.indexOf('.') == -1)
	return string + '.00';
if (number == 1)
	return string + '.00';
if (number == 2)
	return string + '0';
if (number > 3)
	return string.substring(0,string.length-number+3); return string;
}



//builds the pricing for __incMain.asp
function getPrice(index, obj) {
	var objArray;
	var sel;
	var str;
	var indicator;
	
	//obj should be something like ('12.99, 13.99, 14.99')
	//we'll split this on the comma
	objArray = obj.split(", ");

	//indicator cannot be 0
	indicator = parseFloat(index-1);
	
	//closes setPrice which display the from price
	sel = document.getElementById("setPrice3");
	sel.style.display = 'none';
	
	//opens setPrice4 which shows the price they have selected based on their size selection
	sel = document.getElementById("setPrice4");
	sel.style.display = 'block';
	
	//fills the element with content
	str = ""
	str = str + "<span style=\"height:30px; font-size:16px; color:#FF0000; margin-left:70px; margin-top:5px; font-weight:bold;\">"
	str = str + "<strong>&pound;" + just(objArray[indicator]) + "</strong>"
	str = str + "</span>"
	if (objArray[indicator] == undefined) {
	str = ""
	str = str + "<span style=\"height:30px; font-size:16px; color:#FF0000; margin-left:70px; margin-top:5px; font-weight:bold;\">"
	str = str + "Please select a size";
	str = str + "</span>"
	}
	document.getElementById("setPrice4").innerHTML = str;

	//drop this into the hidden value field
	sel = document.getElementById("price");
	sel.value = just(objArray[indicator]);
	if (objArray[indicator] == undefined) {
	sel.value = "";
	}
}




// FOR UD__Cart.asp increments the order quantity and submits the 
// form to update itself, needs UD__cartUpdate.asp
// thisAction == down || up
// oQTY the quanity field it needs to talk to
function doQuantity(thisAction, oQTY ) {
		var myqty = document.getElementById(oQTY);
		val = myqty.value
		if(thisAction=="down") {
		myqty.value = (parseFloat(val) - 1)
			}
		if(thisAction=="up") {
		myqty.value = (parseFloat(val) + 1)
			}
		document.updateAHScart.submit()
	}



//Resize the thumbnail images as they load
//checks to see if the height is greater 
//than the width
//and resizes accordingly

function resizeFunc(width, height, img){
		document.getElementById(img).width = 100;
}



//Swaps the images on __incMain.asp
function swapMainImage(imageID) {
	var sel = document.getElementById("mainImage");
	sel.src = "/images/" + imageID;
	}

