//
//-------------------------------------------------------------------
// 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.
//------------------------------------------------------------------- 
//

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) {  

	//*******************************************************
	// Check submit button has been activated
	if ( $("#addToBasket").hasClass("activeButton") ) {
		// go ahead and submit form
		if (!busy && validateSelectedOptions(form, false)) {
		  busy = true;
		  form.action="OrderItemAdd";
		  form.URL.value='OrderCalculate?URL=/webapp/wcs/stores/servlet/ProductDisplay';
		  form.submit();
		}
	} else if( $("#addToBasket").hasClass("inactiveButton") ) {
	}
	else {
		alert("Please select a size");
	}

}

// 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) {
       	if (validateSelectedOptions(form, false)) {
              busy = true;
              form.action="InterestItemAdd"
              //form.URL.value='InterestItemDisplay'
              form.submit()
       	}
       }
}


// Click and collect feature
function ReserveItem(form) {  
	//*******************************************************
	// Check submit button has been activated
	if ( $("#reserveForCollection").hasClass("activeButton") ) {
		// go ahead and submit form
		if (!busy && validateSelectedOptions(form, false)) {
		  busy = true;
		  form.action="ReserveItemAvailability";
		  //form.URL.value='OrderCalculate?URL=/webapp/wcs/stores/servlet/ProductDisplay';
		  form.submit();
		}
	} else 
	
	if ( $("#reserveForCollection").hasClass("inactiveButton") ) {
		//alert("This item cannot be reserved");
	
	} else {
		alert("Please select a size");
	}

}
