<!-- Hide the script from browsers which do not support it.

function IntsOnly(e, num)
{
// this function allows "num" to include interger number only
// usefull for edit text fields that required number only

	var key;
	var keychar;

	if (window.event)
		key = window.event.keyCode;
	else
	if (e)
		key = e.which;
	else
		return true;

	keychar = String.fromCharCode(key);

	// control keys
	if ((key==null) || (key==0) || (key==8) || 
		(key==9) || (key==13) || (key==27) )
		return true;

	// numbers
	else
	if ((("0123456789").indexOf(keychar) > -1))
		return true;
	else
		return false;
}

function SetCookie(name, value)
{
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;

	document.cookie = name + "=" + escape(value) +
						((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
						((path == null) ? "" : ("; path=" + path)) +
						((domain == null) ? "" : ("; domain=" + domain)) +
						((secure == true) ? "; secure" : "");
}

function GetCookie(name)
{
// Notice the use of unescape to decode special characters in the cookie value.

	var search = name + "=";
	if (document.cookie.length > 0)
	{ // if there are any cookies
		offset = document.cookie.indexOf(search);
		if (offset != -1)
		{ // if cookie exists
			offset += search.length;// set index of beginning of value
			end = document.cookie.indexOf(";", offset);// set index of end of cookie value
			if (end == -1)
				end = document.cookie.length
			return unescape(document.cookie.substring(offset, end));
		}
	}
}

function MakeTen(expr,decimal)
{
	var str="" + Math.round(eval(expr) * Math.pow(10,decimal))
	while (str.length <= decimal)
	{
	   str = "0" + str
	}
	var decpoint = str.length - decimal
	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
}

function buyItem(newItem, price1_11, price12_50, ratio12_50, price51_100, ratio51_100, newQuantity)
{
	var newPrice = 0.0;

	if (newQuantity < 12)
		newPrice = price1_11;
	else
	if (newQuantity < 51)
		//newPrice = MakeTen(price12_50 * ratio12_50, 2);
		newPrice = price12_50;
	else
		//newPrice = MakeTen(price51_100 * ratio51_100, 2);
		newPrice = price51_100;

	if (newQuantity <= 0)
	{
		alert('Sorry, but ZERO is not a valid quantity!');
	}
	else
	{
		var sPrevCartInfo = "";
		var sFormInfo = "";

		var sMyCookie = GetCookie("MyCart");

		if (sMyCookie != null)
		{
			if ( (sMyCookie.indexOf("{", 0) != -1) && (sMyCookie.indexOf("}", 0) != -1) )
				sFormInfo = sMyCookie.substring(sMyCookie.indexOf("{", 0), sMyCookie.indexOf("}", 0) + 1);

			if ( (sMyCookie.indexOf("[", 0) != -1) && (sMyCookie.indexOf("&", 0) != -1) )
				sPrevCartInfo = sMyCookie.substring(sMyCookie.indexOf("[", 0), sMyCookie.indexOf("&", 0));
		}

		var sNewCookie = "MyCart=" + sPrevCartInfo + "[" + newQuantity+"*"+newItem+"*"+newPrice+"]&" + sFormInfo;

		var expdate = new Date();
		//expdate.setTime (expdate.getTime() + (60*60*24*365*10));// expired in 10 years
		expdate.setTime (expdate.getTime() + (60*60*24*30));// expired in 30 days
		SetCookie(sNewCookie, 0, expdate);
	}
}

// End of hiding script from browsers which do not support it. -->
