<!-- Begin

var USER_ID="3255187";                     // Mal's e-commerce User ID
var EC_URL="http://www.aitsafe.com//cf/";   // Mal's e-commerce Shopping Basket URL
var ADD_BASKET=EC_URL + "add.cfm?userid="; // Mal's e-commerce Add Basket URL
var RETURN_DNS="www.jansgifts.co.uk";      // Return URL Address
      // Return URL Address for test
var gsFILENAME=window.location.pathname;   // Get Current file Path

//--------
function article_type(type_id){
         document.menu_form.type_id.value = type_id;
         document.menu_form.target="_blank";
         if (type_id == 102) document.menu_form.action = "links.php";
         else  document.menu_form.action = "list.php";
         document.menu_form.submit();
}
//        ViewCurrentOrder: View Current Order in a shopping basket
//--------
function ViewCurrentOrder(){

        var sView_basket=EC_URL + "review.cfm?userid="; // Mal's e-commerce View Basket URL

        // View Current Order //
        sUrlPath = sView_basket + USER_ID;
        location.href = sUrlPath;
        return(0);
}

//--------
//          AddToOrder: Add a products in a shopping basket
//--------
// function BuyNow(pProductName, pSize, pColor, pColor2, pPrice, pQty, pUnits, pHash){
//function BuyNow(pThisForm){
function BuyNow(sThisForm){
        var sName="";
        var sVersion="";
        var iQuantity=1;
        var iUnits=1;
        var sPrice="";
        var sHash="";
        var pThisForm = document.forms[sThisForm];
        /**** Parameter Check ****/
        // Check Quantity - the Quantity must set more than 1
        iQuantity=parseInt(pThisForm.qty.value);
        if (isNaN(iQuantity)==true){
            alert('Error! Invalid Quantity Setting!');
                return(1);
        }
        if (iQuantity <= 0 ){
            alert('Please set the quantity at least one');
                return(1);
        }
        // Set Product Name
        sName=pThisForm.product.value;

        // Check Color - the size must be selected
        if (pThisForm.color.type=="hidden"){
                if(pThisForm.color.value!=""){
                        sName += "+-+" + pThisForm.color.value;
                }
        }else if (pThisForm.color.type=="select-one"){
                var iSelIndex=pThisForm.color.selectedIndex;
                   if (iSelIndex==0){
                    alert('Please select a Colour for the product you would like to order!');
                        return(1);
                }
                if(pThisForm.color.options[iSelIndex].value!=""){
                        sName += "+-+" + pThisForm.color.options[iSelIndex].value;
                }
        }else{
            alert("Error! No color setting!");
                return(1);
        }
		
		
		 // Check Color2 - the size must be selected
        if (pThisForm.color2.type=="hidden"){
                if(pThisForm.color2.value!=""){
                        sName += "+-+" + pThisForm.color2.value;
                }
        }else if (pThisForm.color2.type=="select-one"){
                var iSelIndex=pThisForm.color.selectedIndex;
                   if (iSelIndex==0){
                    alert('Please select an Alternative Color in case we are out of stock of your first choice!');
                        return(1);
                }
                if(pThisForm.color2.options[iSelIndex].value!=""){
                        sName += "+-+" + pThisForm.color2.options[iSelIndex].value;
                }
        }else{
            alert("Error! No alternative colour selected!");
                return(1);
        }

        // Check Size - the size must be selected
        if (pThisForm.size.type=="hidden"){
                if(pThisForm.size.value!=""){
                        sName += "+-+" + pThisForm.size.value;
                }
        }else if (pThisForm.size.type=="select-one"){
                var iSelIndex=pThisForm.size.selectedIndex;
                   if (iSelIndex==0){
                    alert('Please select a size of product you would like to order!');
                        return(1);
                }
                   if (isNaN(pThisForm.size.options[iSelIndex].value)){
                        // When the size value is not number
                           sName += "+-+" + pThisForm.size.options[iSelIndex].value;
                   }else{
                        // When the size value is number
                           sName += "+-+" + pThisForm.size.options[iSelIndex].value + "+" + "inches";
                   }
        }else{
            alert("Error! No size setting!");
                return(1);
        }

        // Check Price
        /*if (pThisForm.price.value==""){
            alert('Error! Invalid Price Setting!');
                return(1);
        }  */
        // Check Weight
        iUnits=parseInt(pThisForm.units.value);
        if (isNaN(iUnits)==true){
            alert('Error! Invalid Weight Setting!');
                return(1);
        }
        if (iUnits < 0 ){
            alert('Error! Please set the weight more than 0');
                return(1);
        }

        //*** Set Shopping Basket URL ***//
        sUrlPath = ADD_BASKET + USER_ID + "&" +
                   "product=" + sName + "&" +
                           "qty=" + pThisForm.qty.value + "&" +
                           "units=" + pThisForm.units.value + "&" +
                           "return=" + RETURN_DNS + gsFILENAME + "?type_id=" + pThisForm.type_id.value;
        if (pThisForm.price.value != "") sUrlPath = sUrlPath +  "&" + "price=" + pThisForm.price.value
        // Add Hash
        if (pThisForm.hash.value != ""){
            sUrlPath = sUrlPath + "&" + "hash=" + pThisForm.hash.value;
        }

        //*** Go to the Location ***//
        if (sUrlPath != ""){
            // alert(sUrlPath); // For testing the URL
               if (pThisForm.price.value != "")  window.location.href = sUrlPath;
               else{ pThisForm.submitURL.value = sUrlPath;
                     pThisForm.haction.value = "SUBMIT";
                     pThisForm.submit();
               }
        }else{
            alert('AddToOrder: Error! No Location!');
                return(1);
        }
}

// Changing the color of button (IE only) //
function change(color){
        var el=event.srcElement
        if (el.tagName=="INPUT"&&el.type=="button")
        event.srcElement.style.backgroundColor=color
}

// End -->

