//
//-------------------------------------------------------------------
// Licensed Materials - Property of IBM
//
// WebSphere Commerce
//
// (c) Copyright IBM Corp. 2006
//
// US Government Users Restricted Rights - Use, duplication or
// disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
//-------------------------------------------------------------------
//

//
// ***
// * This javascript function is used by the 'Add to Shopcart' button.  Since the HTML form is shared by both 'Add to Shopcart' and 'Add to Wish List' button,
// * appropriate values are set using this javascript before the form is submitted.
// * The variable 'busy' is used to avoid submitting the same forms multiple times when users click the button more than once.
// ***
//
var busy = false;
function Add2ShopCart(form)

{      //alert("catentryId="+form.catEntryId.value);
	   
       if (!busy) {
              busy = true;
              form.action="OrderItemAdd";
              //form.catEntryId.value = catEntryId;
              //form.quantity.value = catEntryQuantity;
              form.URL.value='OrderCalculate?dummaryparam=1&URL=OrderItemDisplay';
              form.submit();
       }
}
// This javascript function is used by the 'Add to Wish List' button to set appropriate values before the form is submitted
function Add2WishList(form)
{
       if (!busy) {
              busy = true;
              form.action="InterestItemAdd";
             // form.catEntryId.value = catEntryId;
              form.URL.value='InterestItemDisplay';
              form.submit();
       }
}

 
// getURLParam() assumes URL parameters are name-value-pairs
// A valid URL would be http://domain/page?name1=value1&name2=value2
// Any similar, more (or less) robust function can be substituted here
function getURLParam(name) {
	var pairs = window.location.search.substr(1).split("&");
	for(var i = 0; i < pairs.length; i++) {
		var nvp = pairs[i].split("=");
		if((nvp.length == 2) && (nvp[0] == name)) {
			return nvp[1];
		}
	}
	return "";
}
	var cmCatID = getURLParam("cmCategory");
 


