<!--
var winpop
function openscript(url, width, height) {
	if(winpop!=null && !winpop.closed){ 
	winpop.close() }
	winpop = window.open(url,"openscript",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=yes,menubar=no,status=no' );
	winpop.focus();
}

function OpenCart(url,width,height) {
	Win = window.open(url,"mybasket",'width=' + width + ',height=' + height + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no' );
	Win.focus();
}

function onError(error_message)
    {
	alert(error_message);
       	return false;	
    }
	
function CheckQuantity(object_value1, object_value2)
	{
	if ((object_value1 * 1.0) >= object_value2)
		{
		return true;
		}
	else {
		return false;
		}
	}
function CheckNumber(object_value)
    {
    //Returns true if value is a number or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is a number defined as
    //   having an optional leading + or -.
    //   having at most 1 decimal point.
    //   otherwise containing only the characters 0-9.
	var start_format = " .+-0123456789";
	var number_format = " .0123456789";
	var check_char;
	var decimal = false;
	var trailing_blank = false;
	var digits = false;

    //The first character can be + - .  blank or a digit.
	check_char = start_format.indexOf(object_value.charAt(0))
    //Was it a decimal?
	if (check_char == 1)
	    decimal = true;
	else if (check_char < 1)
		return false;
        
	//Remaining characters can be only . or a digit, but only one decimal.
	for (var i = 1; i < object_value.length; i++)
	{
		check_char = number_format.indexOf(object_value.charAt(i))
		if (check_char < 0)
			return false;
		else if (check_char == 1)
		{
			if (decimal)		// Second decimal.
				return false;
			else
				decimal = true;
		}
		else if (check_char == 0)
		{
			if (decimal || digits)	
				trailing_blank = true;
        // ignore leading blanks

		}
	        else if (trailing_blank)
			return false;
		else
			digits = true;
	}	
    //All tests passed, so...
    return true
    }
    
function  checkbasket(pid, qty) {
	//alert (document.getElementById(productid) & '/' & document.getElementById(Quantity));
	alert (pid);
	/*
	xform = document.main;
	catin = myorder.categoryID1.selectedIndex;
	catval = myform.categoryID1.options[catin].value;
     param1 = 'cat1='+catval;
     http( 'POST' , '/include/cfc/product.cfc?method=procat2' , get_cat2, param1 ); 
     */

}

function  basket_summary(obj) {
     document.getElementById('basket_item').innerHTML = obj.basket_item;
}
function  CheckForm(theForm) {

	if  (!CheckNumber(theForm.TempQty.value))
        {
        if  (!onError("You must enter numeric value"))
            {
            return false; 
            }
        }

	if (!CheckQuantity(theForm.TempQty.value, theForm.MinQuantity.value))
		{
		if (!onError("Minimum quantity to order is " + theForm.MinQuantity.value))
			{
			return false;
			}
		}
		
	theForm.Quantity.value = theForm.TempQty.value;
	theForm.TempQty.value = "";
	//checkbasket(theForm.productID.value, theForm.Quantity.value);
	
	param1 = 'productid='+theForm.productID.value+'&qty='+theForm.Quantity.value;
	http( 'POST' , '/include/cfc/basket.cfc?method=calculate' , basket_summary, param1 ); 
    	return OpenCart('/scripts/order/basket.cfm', '550', '300');
  }
//-->
