function checkStock(num,inv,sku)
{		
	var formname = "skuform" + num;
	var qty = Number(document.forms[formname].elements["qty"].value);	
	inv = Number(inv);
		
	if (qty <= 0)
	{
		alert("Sorry the quantity of " + sku + " must be greater than 0.  Thanks");
	} 
	else if (qty > inv)
	{
		inv = roundOff(inv,2);
		alert("Sorry we only have " + inv + " units of " + sku + " available, PLEASE adjust the quantity to that number or less.  Thanks");
	} 
	else
	{
		document.forms[formname].submit();
	}
}

function addToWishList(sku)
{
	var url = "/wish_list.php?sku=" + sku;
	wishl = window.open(url,'wish_list','toolbar=0,menubar=0,resizable=1,dependent=0,status=0,width=640,height=250,left=25,top=25');
}

function enterKey()
{
    if (window.event)
    {
         //checks for the enter key
         if (window.event.keyCode == 13)
         {
		 	  alert("To add this item to the shopping cart you must click the \"Add to Basket\" button with your mouse.");
              return false;
         }
		 return true;
    }
	return true;
}

function roundOff(num, decimalplaces)
{
	var decimalfactor = Math.pow(10,decimalplaces);
	roundedValue = Math.round(num*decimalfactor)/decimalfactor;
	strVal = roundedValue.toString();

	if (strVal.indexOf(".") == -1) { roundedValue += ".00"; }	
	else if (strVal.substring(strVal.indexOf(".")+1,strVal.length).length < 2)
	{
		roundedValue += "0";
	}

	return roundedValue;
}