	var busy = false;
	
	/*
	 ***
	 * 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.
	 ***
	 */
	function Add2ShopCart(form)
	{
		if (!busy ) {
			busy = true;
			form.action="SBDOrderItemAdd";
			form.errorViewName.value="ProductView";
			form.URL.value='ShoppingBasketView?orderId=.';
			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, usertype)
	{
		if (!busy) {
			busy = true;
			form.action="WishListAddItemToListView";
			if( usertype == 'G' ) {
				form.errorViewName.value="LoginView";
			} else {
				form.errorViewName.value="WishListView";
			}
			form.URL.value='MyAccountView';
			form.submit();
		}
	}

	function changeStillNeeds(quantity, stillneeds)
	{
		stillneeds.value = quantity.value ;
	}	
	
	function Add2GiftRegistry(form)
	{
		if (!busy) {
			busy = true;
			//form.action="InterestItemAdd";
			form.action="SBDInterestItemAdd";
			form.errorViewName.value="LoginView";
			form.URL.value="InterestItemDisplay";
			form.submit();
		}
	}


	// declare global variable name
	var histInsp = null
	function histInspWin(theURL,winName,features) {
		// check if window already exists
		if (!histInsp || histInsp.closed) {
			// store new window object in global variable
			histInsp = window.open(theURL,winName,features)
			histInsp.document.close()
		} else {
			// window already exists, so bring it forward
			histInsp.focus()
		}
	}
	// declare global variable name
	var viewDetails = null
	function viewDetailsWin(theURL,winName,features) {
		// check if window already exists
		if (!viewDetails || viewDetails.closed) {
			// store new window object in global variable
			viewDetails = window.open(theURL,winName,features)
			viewDetails.document.close()
		} else {
			// window already exists, so bring it forward
			viewDetails.focus()
		}
	}	

	function MM_openBrWindow(theURL,winName,features) { //v2.0
		window.open(theURL,winName,features);

		var newWindow = null
		function makeNewWindow(theURL,winName,features) {
			// check if window already exists
			if (!newWindow || newWindow.closed) {
				// store new window object in global variable
				newWindow = window.open(theURL,winName,features)
				newWindow.document.close()
			} else {
				// window already exists, so bring it forward
				newWindow.focus()
			}
		}
	}
	
    function changeSort(viewCommand, sortBy, allNumber) {
        if (sortBy != "") {
       		var allNumberParams = '';
			if (allNumber > 0) {
				allNumberParams = '&start=1&end=' + allNumber + '&all=true';
			}
			//alert('A=' + allNumberParams);
			self.location =  viewCommand + '&sortBy=' + sortBy + allNumberParams;
        }
    }
	
    function filterByPrice(viewCommand, priceRange, allNumber) {
 	    var allNumberParams = '';
 	    if (allNumber > 0) {
			allNumberParams = '&start=1&end=' + allNumber + '&all=true';
		}
 	    
        if (priceRange != "") {			
			//alert('A=' + allNumberParams);
			self.location =  viewCommand + '&priceRange=' + priceRange + allNumberParams;
        } else {
        	self.location =  viewCommand + allNumberParams;
        }
        
    }
       
    function narrow(viewCommand, narrowById) {
        if ( narrowById != "" && viewCommand != "" ) {
                self.location =  viewCommand + narrowById;
        }
    }
    
    function displaySingletonProductAlert() {
    	alert('Please indicate the Quantity for the product that you wish to add to the cart, wish list, or gift registry.');
    }

    function displayMultiItemProductAlert() {
    	alert('Please select the Product and Quantity that you wish to add to the cart, wish list, or gift registry.');
    }
    