';
var bCookieFavListQty = false;
var sNoWarehouseFound = 'Call for Inventory';
var bRequireWarehouse = false;
var bListViewATCPerLine = false;
var bInStockShowEmptyWarehouses = false;
var bInvalidQtyMsgShowing = false;
var bUseIDP = true;
/*
* Get the values of orderfronturl and buildsessionpassthrough
* to maintain sessions and cookies for SSL domain
* @auther lroselli
* @since 4/10/2013
*/
var sOrderFrontUrl = 'https://winning-moves.com';
var sBuildSessionPassThrough = 'sc_id=FB12BAC68CC94E0A8AB660CC36EC9C62&a_name=&c_Lastname=&c_firstName=&c_userName=&c_id=&a_id=&s_key=65F0385A96A1466E85D544315419817F&s_url=http%3A%2F%2Fwinning%2Dmoves%2Ecom&o_url=https%3A%2F%2Fwinning%2Dmoves%2Ecom&createsessioncookie=1&noredirect=1&l_ws_key=&c_type=&SessionPriceGroup=&SessionWarehouse=&SessionCurrency=&SessionPriceSheetField=&user_setting_key=&us_key=&mobile=no';
var bShowSalesUOM = false;
var bShowNativeUOMinCart = false;
var bDisableATCZeroQtyWarehouse = false;
/*================================
* Init Code & Event Registration
*================================*/
jQuery(function(){
/* inline search */
if ( bShowTableFilter ) {
/* inline search: store searchable text */
$('#clear_filter').click(function(){
$('#prod_table_search').val('').blur();
$('.product_wrap_table .indexColumn').parent().show().end().hide();
window.location.hash = '';
$(this).hide();
});
$('.product_wrap_table tr:has(td)')
.each(function(){
var t = $(this).text().toLowerCase();
$('
').hide().text(t).appendTo(this);
});
/* inline search: function */
$('#prod_table_search')
.keyup(function(e){
if (e.keyCode == 27) {
/* clear search on ESC keypress when search is focused */
$('#clear_filter').click();
} else {
/* perform search */
var s = $(this).val().toLowerCase().split(' ');
window.location.hash = $(this).val();
$('.product_wrap_table tbody tr:hidden').show();
$.each(s, function(){
$('.product_wrap_table tbody tr:visible .indexColumn:not(:contains("' + this + '"))').parent().hide();
});
} //-if (e.keyCode == 27)
if($(this).val()=='')
$('#clear_filter').hide();
else
$('#clear_filter').show();
});
(function($){
var hash = window.location.hash;
if(hash)
$('#prod_table_search').val(hash.replace('#','')).keyup();
})(jQuery);
} //- if ( bShowTableFilter )
// check for layout cookie - create if necessary
c_start = document.cookie.indexOf('productLayout=');
if (c_start = -1) {
wsp_setCookie('productLayout', 'gallery', 365);
};
jQuery('a#gallery_layout').addClass('active');
// set layout mode when ui buttons are clicked
jQuery('a#gallery_layout').click(function(event){
event.preventDefault();
wsp_setCookie('productLayout', 'gallery', 365);
window.location.reload();
});
jQuery('a#list_layout').click(function(event){
event.preventDefault();
wsp_setCookie('productLayout', 'list', 365);
window.location.reload();
});
/*
* Added HTML Element "Table" before class "#list_layout",
* just to instruct the jQuery to refer the Table with the
* Class "list_layout".
*
* @author MandarK
* @since 02/23/2011
*/
jQuery('Table#list_layout').delegate("select.uom", "change", function(){
sPKey = jQuery(this).closest('tr').attr("id");
Uom.getPrice(sPKey);
});
/*
* Added HTML Element "Table" before class "#gallery_layout", just to instruct the jQuery to refer
* the Table with the Class "gallery_layout". Now additionally took the "Prod Id" Value from the
* closest TD and replacing the text "prod_item_" value with ""
*
* @author MandarK
* @since 02/23/2011
*/
jQuery('Table#gallery_layout').delegate("select.uom", "change", function(){
sPKey = (jQuery(this).closest('td').attr("id")).replace("prod_item_","");
Uom.getPrice(sPKey);
});
jQuery('#atc_msg_close_win').click(function(event){
event.preventDefault();
closeCartLightbox();
});
jQuery('.order_btn').click(function(){
postToCart('', $(this).data('pkey'));
});
/*
* Qty Available Immediate Function
*@author pijushb
*@since 9/14/2011
*/
if (bShowBackOrderMessage) {
(function($){
// //Show Check Stock Button.
// keys = document.getElementsByName('keys');
// for (var k=0; k < keys.length; k++){
// $("#review_button_"+keys[k].value).show();
// }
// Refactored above code to use jQuery
// jonr - 8-12-2013
jQuery('input[name="keys"]')
.each(function(){
$("#review_button_"+jQuery(this).val()).show();
});
//Register review button listener
$('.review_button').click(function(event){
sPKey = $(this).attr('rel');
bBackOrder = fncCheckBackorder(sPKey,'checkstock');
$("#review_message_" + sPKey).show();
});
})(jQuery);
} //-if (bShowBackOrderMessage)
/*
* This was added for the list view for results
* returning no items that are in stock.
*
* @author: johns
* @since 6/25/2012
*/
if ( jQuery('input[name="keys"]').length <= 0 ) {
jQuery('.btn_addtocart').hide();
}
if ( bRequireWarehouse && bListViewATCPerLine) {
jQuery('.btn_addtocart').attr('disabled', true);
jQuery('[id*="get_wh_btn_"]').click( function() {
pkey = $(this).attr('id').substring($(this).attr('id').length - 32);
jQuery('#' + pkey + ' td.product_quantity form button[type="submit"]').removeAttr('disabled');
});
}
if ( bCookieFavListQty ) {
fncLoadFavListQtyFromCookie();
jQuery('#list_prods input.qtyinput').bind('change keyup', function(){
fncCookieForm();
});
}
});
function fncCookieForm() {
var sCookie = '[';
//build the cookie with an array of objects containing the p_key and qty
jQuery('#list_prods input[class="qtyinput"][type="number"][value!=""]').each(function(){
var sPKey = jQuery(this).attr('id').substr(4, jQuery(this).attr('id').length);
var sQty = jQuery('#qty_' + sPKey).val();
if ( sCookie != '[' ) {
sCookie += ','
}
sCookie += '{key: \'' + sPKey + '\', qty: ' + sQty + '}';
});
sCookie += ']';
var sExpDate = new Date();
sExpDate.setDate(sExpDate.getDate() + 1); //keep for 1 day
document.cookie = sFl_Key + '=' + sCookie + '; expires=' + sExpDate.toUTCString();
}
function fncLoadFavListQtyFromCookie() {
try {
prepop = eval(getCookie(sFl_Key).replace(/\"/g,''));
if ( typeof prepop == 'undefined' ) {
prepop = [];
}
} catch (ignore) {
prepop = []
}
if ( prepop.length > 0 ) {
$.each(prepop, function(index, prod) {
jQuery('#qty_' + prod.key).val(prod.qty)
});
}
}
function getCookie(c_name) {
var c_value = document.cookie;
var c_start = c_value.indexOf(" " + c_name + "=");
if ( c_start == -1 ) {
c_start = c_value.indexOf(c_name + "=");
}
if (c_start == -1) {
c_value = null;
} else {
c_start = c_value.indexOf("=", c_start) + 1;
var c_end = c_value.indexOf(";", c_start);
if ( c_end == -1 ) {
c_end = c_value.length;
}
c_value = unescape(c_value.substring(c_start,c_end));
}
return c_value;
}
function fncShowChildProducts ( vPKey ) {
var aRows = document.getElementsByName(vPKey + '_keys');
for ( var iRow = 0, iGoTo = aRows.length; iRow < iGoTo; iRow++ ) {
try {
jQuery('#' + vPKey + '_' + aRows[iRow].value).show();
} catch ( oError ) {
alert('Error: ' + oError.message);
}
}
jQuery('#' + vPKey + '_disp_children_link').hide();
} //- function fncShowChildProducts ( vPKey )
/*================================
* Standard Functions
*================================*/
function wsp_setCookie(nm,val,days) {
var expdate = new Date();
expdate.setDate(expdate.getDate()+days);
document.cookie = nm + '=' + val + ';expires=' + expdate.toGMTString() + ';path=/;';
}
function fncMinMaxQtyCheck ( sKey ) {
var iQty = parseInt(jQuery('#qty_' + sKey).val());
var iMinQty = parseInt(jQuery('#min_order_qty_' + sKey).val());
var iMaxQty = parseInt(jQuery('#max_order_qty_' + sKey).val());
var iCaseQty = parseInt(jQuery('#case_qty_' + sKey).val());
var sErrorMsg = 'One or more of the quantities you entered did not match the minimum or maximum quantity allowed and have been adjusted accordingly.';
var bIsError = false;
var bUseMinQtyCheck = false;
//Checks for negative numbers and non numeric characters
//Sets Min & Case QTY to 1 if null or zero
//lroselli 3/5/2013
if ( iMinQty <= 0 || isNaN(iMinQty) ) {
iMinQty = 1;
}
if ( iCaseQty <= 0 || isNaN(iCaseQty) ) {
iCaseQty = 1;
}
//This actually does the check and adjusts end result QTY -lroselli 3/5/2013
if ( iQty < iMinQty && iQty != 0 && bUseMinQtyCheck ) {
if ( iMinQty > iMaxQty && iMaxQty != 0 ) {
jQuery('#qty_' + sKey).val('');
} else if ( iMinQty <= iCaseQty ) {
iQty = iCaseQty;
jQuery('#qty_' + sKey).val(iQty);
bIsError = true;
} else {
iQty = Math.round(iMinQty / iCaseQty) * iCaseQty;
jQuery('#qty_' + sKey).val(iQty);
bIsError = true;
}
} else if ( iQty > iMaxQty && iQty != 0 ) {
if ( iMinQty > iMaxQty && iMaxQty != 0 ) {
jQuery('#qty_' + sKey).val('');
} else if ( iMaxQty > iCaseQty ) {
iQty = Math.floor(iMaxQty / iCaseQty) * iCaseQty;
jQuery('#qty_' + sKey).val(iQty);
bIsError = true;
} else if ( iMaxQty == 0 ) {
if ( iQty % iCaseQty != 0 ) {
iQty = Math.round(iQty / iCaseQty) * iCaseQty;
if ( iQty == 0 ) {
iQty = iCaseQty;
}
jQuery('#qty_' + sKey).val(iQty);
bIsError = true;
} else {
jQuery('#qty_' + sKey).val(iQty);
}
} else {
iQty = iCaseQty;
jQuery('#qty_' + sKey).val(iQty);
bIsError = true;
}
} else {
if ( ! isNaN(iQty) && iQty != 0 ) {
if ( iQty % iCaseQty != 0 ) {
iQty = Math.round(iQty / iCaseQty) * iCaseQty;
jQuery('#qty_' + sKey).val(iQty);
bIsError = true;
} else {
jQuery('#qty_' + sKey).val(iQty);
}
} else {
//do not alert or break
jQuery('#qty_' + sKey).val('');
}
}
if ( bAddToCartAfterQtyAdjust && bAddToCartAfterQtyAdjustErrored ) {
jQuery('#atc_msg_adj_text').show();
} else {
jQuery('#atc_msg_adj_text').hide();
}
if ( bIsError && ! bAddToCartAfterQtyAdjust ) {
styled_modal_alert(sErrorMsg);
return false;
} else if ( bIsError && bAddToCartAfterQtyAdjust ) {
bAddToCartAfterQtyAdjustErrored = true;
return true;
} else {
return true;
}
} //- function fncMinMaxQtyCheck ( sKey )
/**
* This function determines how the products should be posted (form or ajax).
*
* @author ??
* @since ??
*
* @modified johns - 3/19/2013: added param "sKeyDataName" and the code w/ it
*
* @param sKeyDataName (string): id of the html element that hold the
* keys of the products to be added to the cart (this is
* specifically used for the add-on products)
*
* @return bool - for ajax ATC, return false to draw the modal popup window
* else return true to redirect to the add to cart page
*/
function postToCart ( sKeyDataName, sKey ) {
var bIsAccessory = false;
var addToCartButtons = '.prod_item .actions .btn.btn-small, .detail_atc_standalone .btn-primary';
try {
bPassMinMaxQtyCheck = fncMinMaxQtyCheck ( sKey );
if ( ! bPassMinMaxQtyCheck ) {
// removed spinner Icon from add to cart button
$(addToCartButtons).children('i.icon-spinner').remove();
return false;
}
/*
'Check of backorder qyantity so that it show proper message and enable review and checkout button.
'@author pijushb
'@since 9/14/2011
*/
if ( bShowBackOrderMessage ) {
/*
* Call function to check for backorder qyantity
* parm: product key
* return: boolean
*/
bBackOrder = ! fncCheckBackorder ( sKey, 'atcbutton' );
if ( bBackOrder ) {
//Hold the process..
return false;
} else {
//Proceed to add product to Cart..
return true;
} //- if ( ! bBackOrder )
} else {
return true;
} //- if ( bShowBackOrderMessage )
} catch ( oError ) {
alert(oError.mesage);
return false
}
} //- function postToCart ( sKey )
/**
* Check the product's inventory to show a backorder message
*
* @author pijushb
* @since 9/14/2011
*/
function fncCheckBackorder ( sKey, sButtonType ) {
var sGlobalBackOrderMessage = ''
, sBackOrderMessage = ''
, sQtyRequested = 1
, iQtyAvaliable = 1
, bReturn = true
, sReviewComplete = jQuery('#review_complete_' + sKey).val()
, sCheckoutButton = jQuery('#checkout_complete_' + sKey).val();
if ( sReviewComplete === '0' ) {
sQtyRequested = jQuery('#qty_' + sKey).val();
iQtyAvaliable = jQuery('#inventory_qty_' + sKey).val();
if ( iQtyAvaliable === '' ) iQtyAvaliable = 0;
if ( parseInt(sQtyRequested) > parseInt(iQtyAvaliable) ) {
//Popup to show backorder message..
sBackOrderMessage = sBackorderPlacedMessage;
if ( sButtonType === 'atcbutton' && sCheckoutButton === '0' ) {
showOkCheckoutMessage ( sBackOrderMessage, sKey );
} //- if ( sButtonType === 'atcbutton' && sCheckoutButton === '0' )
jQuery('#review_message_' + sKey).html(sStockExceedMessage);
bReturn = false
} else {
//Popup to show available message..
sBackOrderMessage = sBackorderAvailableMessage;
if ( sButtonType === 'atcbutton' && sCheckoutButton === '0' ) {
showOkCheckoutMessage ( sBackOrderMessage, sKey );
} //- if ( sButtonType === 'atcbutton' && sCheckoutButton === '0' )
jQuery('#review_message_' + sKey).html(sStockAvailableMessage);
bReturn = false
} //- if ( parseInt(sQtyRequested) > parseInt(iQtyAvaliable) )
} else {
bReturn = false;
} // if ( sReviewComplete === '0' )
if (sCheckoutButton === '1') bReturn = true;
return bReturn;
} //- function fncCheckBackorder ( sKey, sButtonType )
/**
* Function to popup dialog box with proper message
* @author pijushb
* @since 1/25/2012
*/
function showOkCheckoutMessage (sBackOrderMessage, sKey ) {
bSucessAdd = ajaxAddKeys(sKey);
if ( bSucessAdd ) {
jQuery('#dialog-box').html(sBackOrderMessage)
jQuery('#dialog-box').dialog();
//getter
var buttons = $('#dialog-box').dialog( 'option', 'buttons' );
//setter
jQuery('#dialog-box').dialog( 'option', 'buttons', [
{
text: 'Ok',
click: function() {
closeCartLightbox();
funcShowHideButtons(sKey); jQuery(this).dialog('close');
}
},
{
text: 'Checkout',
click: function() { gotoCart(sKey); jQuery(this).dialog('close'); }
}
] );
} //- if ( bSucessAdd )
} //- function showOkCheckoutMessage (sBackOrderMessage, sKey )
/*
* Function to show/hide buttons and message.
* @author pijushb
* @since 1/25/2012
**/
function funcShowHideButtons ( sKey ) {
//Show review button and checkout button and set review message with backorder message..
jQuery('#checkout_button_' + sKey).show();
jQuery('td#prod_item_' + sKey + ' div.actions input.btn_addtocart').hide();
jQuery('#review_message_' + sKey).hide();
//Set the value to 1. so that when click on checkout button it should not check backorder again.
jQuery('#checkout_complete_'+ sKey).val('1');
} //- function funcShowHideButtons ( sKey )
/*
* Function to redirect the page to showcart page.
* @author pijushb
* @since 1/25/2012
**/
function gotoCart() {
window.location = "https://winning-moves.com/showcart.asp";
} //- function gotoCart()
/**
* Show a modal message
* @author pijushb
* @since 9/14/2011
*/
function showModalMessage(sMessage){
ResizeLoadingBG();
sOrigText = $('#detailloadingpic').html();
$('#detailloadingpic').html(sMessage);
setTimeout( 'HideLoading()', 3000 );
}
function HideLoading(){
jQuery('#detailloadingbg').hide();
jQuery('#detailloadingpic').hide();
}
function ResizeLoadingBG(){
var oLBG = jQuery('#detailloadingbg')[0];
var oLPic = jQuery('#detailloadingpic')[0];
var popwidth = 200;
if (window.innerHeight && window.scrollMaxY) {
oLBG.style.width = document.body.scrollWidth;
oLBG.style.height = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
oLBG.style.width = document.body.scrollWidth;
oLBG.style.height = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
oLBG.style.width = document.body.offsetWidth;
oLBG.style.height = document.body.offsetHeight;
}
if (self.innerHeight) { // all except Explorer
oLPic.style.left = (self.innerWidth / 2) - (popwidth / 2);
oLPic.style.top = self.pageYOffset + (self.innerHeight / 4);
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
oLPic.style.left = (document.documentElement.clientWidth / 2) - (popwidth / 2);
oLPic.style.top = document.documentElement.scrollTop + (document.documentElement.clientHeight / 4);
} else if (document.body) { // other Explorers
oLPic.style.left = (document.body.clientWidth / 2) - (popwidth / 2);
oLPic.style.top = document.body.scrollTop + (document.body.clientHeight / 4);
}
oLBG.style.display = 'block';
oLPic.style.display = 'block';
}
function validQtys(form) {
var bReturn = false;
$(form).find('input[name*="qty_"]').each(function(){
if($(this).val()!='' && parseInt($(this).val())>0) {
bReturn = true;
return;
}
});
if(!bReturn && !bInvalidQtyMsgShowing) {
bInvalidQtyMsgShowing = true;
$(form).find('button[type="submit"]').after(sInvalidQtyHtml);
}
return bReturn;
}
/**
* This function handles the case qty validation of the add to cart form post.
* @author ??
* @since ??
* @modified johns - 3/19/2013: added param "sKeyDataName" and the code w/ it
*
* @param bUseAjaxATC (bool): use ajax form post
* @param sKeyDataName (string): id of the html element that hold the
* keys of the products to be added to the cart (this is
* specifically used for the add-on products)
* @param sKey (string): single product key (gallery view and atc per line
* in list view)
*
* @return bool - for ajax ATC, return false to draw the modal popup window
* else return true to redirect to the add to cart page
*/
function checkCaseQtys ( bUseAjaxATC, sKeyDataName, sKey ) {
var bValidCaseQty = false;
var aKeys;
var bFailedCheck = true;
bAddToCartAfterQtyAdjustErrored = false;
if ( typeof sKeyDataName === 'undefined' && typeof sKey === 'undefined' || sKey === '') sKeyDataName = 'keys';
try {
if ( typeof sKey === 'undefined' || sKey === '' || ( typeof sKeyDataName !== 'undefined' && sKeyDataName !== '' ) ) {
if ( jQuery('input[name="' + sKeyDataName + '"]').length > 0 ) {
aKeys = jQuery('input[name="' + sKeyDataName + '"]');
for ( var iKeyCounter = 0, iKeyGoTo = aKeys.length; iKeyCounter < iKeyGoTo; iKeyCounter++ ) {
//bValidCaseQty = fncValidateCaseQty ( jQuery(aKeys[iKeyCounter]).val() );
bValidCaseQty = fncMinMaxQtyCheck ( jQuery(aKeys[iKeyCounter]).val() );
if ( ! bValidCaseQty ) bFailedCheck = false;
}//- for ( iKeyCounter = 0, iKeyGoTo = sKeys.length; iKeyCounter < iKeyGoTo; iKeyCounter++ )
if ( ! bFailedCheck ) {
//styled_modal_alert('You must order the package quantity for this item. Please adjust the quantity to proceed.');
return false;
} else {
if ( bUseAjaxATC ) {
bPass = postToCart ( sKeyDataName, jQuery(aKeys[iKeyCounter]).val() );
} else {
bPass = fncMinMaxQtyCheck ( jQuery(aKeys[iKeyCounter]).val() );
} //- if ( bUseAjaxATC )
} //- if ( bHitOne )
} //- if ( jQuery('input[name="keys"]').length > 0 )
} else {
bValidCaseQty = fncMinMaxQtyCheck ( sKey );
//bValidCaseQty = fncValidateCaseQty ( sKey );
if ( ! bValidCaseQty ) {
//styled_modal_alert('You must order the package quantity for this item. Please adjust the quantity to proceed.');
return false;
} else {
if ( bUseAjaxATC ) {
bPass = postToCart ( sKeyDataName, sKey );
} else {
bPass = fncMinMaxQtyCheck ( sKey );
} //- if ( bUseAjaxATC )
} //- if ( bValidCaseQty )
} //- if ( typeof sKey == 'undefined' )
return bPass;
} catch ( oError ) {
alert('Case Quantity Validation: ' + oError.mesage);
return false;
}
} //- function checkCaseQtys ( sKey )
function fncValidateCaseQty ( sKey ) {
var bPass = true;
var iCaseQty, iRemainder = 0;
iCaseQty = jQuery('#case_qty_' + sKey).val();
if ( parseInt(iCaseQty) > 1 ) {
iQty = jQuery('#qty_' + sKey).val();
if ( iQty != '' ) {
//make sure the qty is a multiple
iRemainder = parseInt(iQty) % parseInt(iCaseQty);
if ( iRemainder != 0 ) {
bPass = false;
} //- if ( iRemainder = 0 )
} //- if ( iQty.value != '' )
} //- if ( parseInt(iCaseQty) > 1 )
return bPass
} //- function fncValidateCaseQty ( sKey )
/*================================
* AJAX Functions
*================================*/
/**
* Logic to Update Pricing for UOM
*
* @author dand
* @since 4/22/2010
*/
var UomJQ = jQuery;
var Uom = {fn: function(){}};
var sLoadingMessage = '';
var sPriceText = 'Price:';
(function(jQuery){
/**
* getPrice
*/
Uom.getPrice = function(sPKey){
var oUomAjax = new ajax_builder();
this.sPKey = sPKey;
this.toggleQty();
oUomAjax.Reset();
oUomAjax.SetVar("pageaction", "uom_price");
oUomAjax.SetVar("uom_type", jQuery('#uom_type_' + sPKey).val());
oUomAjax.SetVar("p_id", sPKey);
oUomAjax.RequestFile = "ChildrensGames.asp"; //i_i_
oUomAjax.Method = "GET";
oUomAjax.ResponseType = "text";
oUomAjax.onLoading = function() { Uom.loading() };
oUomAjax.onCompletion = function(){ Uom.drawPrice(oUomAjax.Response) };
oUomAjax.onError = this.error;
oUomAjax.RunAJAX();
};//-Uom.getPrice
/**
* drawPrice
*/
Uom.drawPrice = function ( sResponse ) {
jQuery('#' + Uom.sPKey + ' td.product_price').html(sResponse);
/*
* Add this line to replace the price value on select of UOM
* when the view is Gallary view
*
* @author MardarK
* @since 02/23/2011
*/
jQuery('td#prod_item_' + Uom.sPKey + ' div.item_pricing').html('
' + sPriceText + ' ' + sResponse + '
');
jQuery('td#prod_item_' + this.sPKey + ' div.actions input.btn_addtocart').removeAttr('disabled');
//HideLoading();
}; //- Uom.drawPrice
Uom.loading = function () {
jQuery('td#prod_item_' + this.sPKey + ' div.actions input.btn_addtocart').attr('disabled','disabled');
jQuery('td#prod_item_' + this.sPKey + ' div.item_pricing').html(sLoadingMessage);
}; //- Uom.loading
/**
* toggleQty
*/
Uom.toggleQty = function () {
if(jQuery('#uom_type_' + this.sPKey).val() == 'sales'){
jQuery('#qty_' + this.sPKey).attr("name", 'sales_qty_' + this.sPKey);
} else {
jQuery('#qty_' + this.sPKey).attr("name", 'qty_' + this.sPKey);
}//-if(jQuery('#uom_type_' + vPKey).val() == 'sales')
}; //- Uom.toggleDisplay
/**
* error
*/
Uom.error = function () {
alert('There was an error retrieving the information for the product you selected.');
}; //- Uom.error
})(UomJQ);
/**
* AJAX Call to remove item from favorites list.
*
* @author johns
* @since 10/15/2009
*/
function fncRemoveItem ( sProdKey ) {
jQuery.ajax({
url: sPageName,
data: 'pageaction=removefavitems&p_key=' + sProdKey + '&fl_key=' + sFl_Key + '&r_id=' + new Date().getTime(),
type: 'GET',
async: false,
dataType: 'text',
success: function () { fncRemoveItemCompleted ( sProdKey ); }
});
} //- function fncRemoveItem ( sProdKey )
//- EVENT FUNCTIONS ==================================================
function fncRemoveItemCompleted( p_key ) {
var $oContainer = jQuery('td#prod_item_' + p_key);
var $oContainer2 = jQuery('tr#' + p_key);
if ($oContainer.length > 0){
// $oContainer.hide();
$oContainer.remove();
}else{
// $oContainer2.hide();
$oContainer2.remove();
}
} //- function fncRemoveItemCompleted( p_key )
//================================================================
function closeCartLightbox() {
if (jQuery('#cart_window')){
//cart_window
oAjax.Reset();
oAjax.RequestFile = 'i_i_shopping_cart_window.asp'
oAjax.Method = 'GET';
oAjax.onCompletion = function(){
//jQuery.scrollTo(0, 500, {
// easing: 'swing',
// onAfter: function(){
jQuery('#cart_window').replaceWith(oAjax.Response);
jQuery("#atc_msg_buttons").show();
// }
// });
tb_init('#cartwin_shipping a.thickbox');
};
oAjax.ResponseType = 'text'; //- The format of returned data. xml, text, json.
oAjax.RunAJAX();
}
jQuery('#atc_msg')
.fadeOut('fast', function(){
jQuery('#atc_msg_container').hide();
jQuery('#atc_msg_product, #atc_msg_notice').html('');
});
}
/**
* This will perform an ajax get request on the ORDERFRONTURL's
* showcart.asp page to create a cookie of the SSL domain to
* maintain session information such as the shopping cart.
*
* @author lroselli
* @since 04/10/2013
*/
function fncBuildSSLCookie() {
jQuery.ajax({
url: sOrderFrontUrl + '/i_i_showcart.asp?' + sBuildSessionPassThrough
, type: "GET"
, async: false
, crossDomain: true
, xhrFields: {
withCredentials: true
}
, error: function() {
//ignore
}
});
} //- fncBuildSSLCookie
/**
* This function handles calling the add to cart page via ajax for
* a single product key.
*
* @author johns
* @since 03/19/2013
*
* @modified johns - 3/19/2013: added param "bIsAccessory" and the code w/ it
*
* @param p_key (string): key of the product to be added to
* cart
* @param bIsAccessory (bool): is the call coming from product addon window
*
* @return void
*/
function ajaxAddKeys ( p_key, bIsAccessory ) {
var sStockStatus = '';
var iCaseQty = 1;
var sAtcType = 'GET';
var sAtcSfx = '';
if ( typeof bIsAccessory === 'undefined' ) bIsAccessory = false;
var sUomData = '';
var sUomType = '';
var sUom = '';
var sUomStd = '';
var iUomSalesConv = 0;
try {
$qtybox = jQuery('#qty_' + p_key);
if($qtybox.length === 0){
$qtybox = jQuery("#atc_form_" + p_key + " .qtyinput");
}
// get min and max qty if it is populated
iMinQty = jQuery('#min_order_qty_' + p_key).val();
iMaxQty = jQuery('#max_order_qty_' + p_key).val();
if ( bShowSalesUOM ) {
sUomType = jQuery('#uom_type_' + p_key).val();
sUom = jQuery('#uom_' + sUomType + '_' + p_key).val();
sUomStd = jQuery('#uom_std_' + p_key).val();
iUomSalesConv = jQuery('#uom_conv_' + p_key).val();
sUomData += '&uom=' + sUom + '&uomconv=' + iUomSalesConv + '&uomtype=' + sUomType;
if ( bShowNativeUOMinCart ) {
sUomData += '&stduom=' + sUomStd;
}
}
$qty = $qtybox.val();
// product html for gallery view
if ( jQuery('#prod_item_' + p_key).length > 0 ) {
$container = jQuery('#prod_item_' + p_key).children('.prod_item_pad');
$prodnm = $container.children('.nm').html();
$stockstatus = jQuery('#in_stock_' + p_key).val();
if ( $stockstatus !== undefined && $stockstatus !== '' ) sStockStatus = '&in_stock_' + p_key + '=' + $stockstatus;
$prodimg = '' + $container.children('.thumb').html() + '';
if ( $container.children('.thumb').html() === null || typeof $container.children('.thumb').html() == 'undefined' ) $prodimg = '';
$product = $prodimg + '' + $prodnm + ' (' + $qty + ')';
// product html for list view
} else {
$oContainer = jQuery('#' + p_key);
iQty = $qtybox.val();
sProdName = $oContainer.children('td.product_desc').children('p').html();
sProdImage = $oContainer.children('td.product_thumb').html();
if ( sProdImage === null || typeof sProdImage == 'undefined') sProdImage = '';
$product = sProdImage + '' + sProdName + ' (' + iQty + ')';
} //- if ( jQuery('#prod_item_' + p_key).length > 0 )
var sPWID = '&pw_id=' + (jQuery('#pw_id_' + p_key).val() || '');
if ( $qty !== '' && typeof $qty !== 'undefined' && $qty > 0 ) {
// calls i_i_showcart.asp to build session passthrough
fncBuildSSLCookie();
if ( bUsingOrderDetailTableForCarts ) {
$('#atc_msg').on('hidden', function () {
closeCartLightbox();
});
jQuery.ajax({
url: 'i_i_add_to_cart.asp?ajax=listview&action=postlogic'
, data: 'type=ajaxadd&key=' + p_key + '&qty'+sAtcSfx+'=' + $qty + '&minqty=' + iMinQty + '&maxqty=' + iMaxQty + sStockStatus + sUomData + '&r_id=' + new Date().getTime()
, cache: false
, async: false
, type: sAtcType
, dataType: "json"
, complete: function(jsonOrder) {
handleAjaxATCSuccess ( bIsAccessory, p_key, $product, jsonOrder );
}
, error: function(XMLHttpRequest, textStatus, errorThrown){
alert('Error: ' + errorThrown);
}
});
} else {
// Updated to post form as is using AJAX instead of custom AJAX ATC logic
$form = jQuery("#atc_form_" + p_key);
if($form.length > 0){
// post form using exisitng form data + action
// [dcohen @ 2015-02-23]
jQuery.ajax({
url: $form.attr('action').replace("https://", "//") + "&requestType=ajaxcall",
type: "POST",
data: $form.serialize(),
cache: false,
async: false,
dataType: 'text',
success: function(oData){
handleAjaxATCSuccess ( bIsAccessory, p_key, $product, oData );
},
error: function ( jqXHR, textStatus, errorThrown ) {
alert('Error: ' + errorThrown);
}
});
} else {
// form not found: use legacy ATC AJAX call (should never get here)
jQuery.ajax({
url: 'i_i_add_to_cart.asp?ajax=listview',
data: 'type=ajaxadd&key=' + p_key + '&qty'+sAtcSfx+'=' + $qty + '&minqty=' + iMinQty + sPWID + '&maxqty=' + iMaxQty + sStockStatus + sUomData + '&r_id=' + new Date().getTime(),
type: sAtcType,
async: false,
dataType: 'text',
error: function ( jqXHR, textStatus, errorThrown ) {
alert('Error: ' + errorThrown);
},
success: function ( oData ) {
handleAjaxATCSuccess ( bIsAccessory, p_key, $product, oData );
}
});
}
} //- if ( bUsingOrderDetailTableForCarts )
if ( jQuery('#case_qty_' + p_key).val() !== '' && ! isNaN(jQuery('#case_qty_' + p_key).val()) && bUseCaseQty ) iCaseQty = jQuery('#case_qty_' + p_key).val();
//if ( ! bIsAccessory ) $qtybox.val(iCaseQty);
// override the qty with the min qty if it is populated
//if ( jQuery('#min_order_qty_' + p_key).length > 0 ) $qtybox.val(iMinQty);
return true;
} else {
return false;
}
} catch ( oError ) {
//alert('Failed to add selection to cart. ' + oError.mesage);
jQuery('.atc_msg').hide()
return false;
}
} //- function ajaxAddKeys
/**
* This function the success of the ajax ATC call.
*
* @author johns
* @since 03/19/2013
*
* @param sP_Key (string): key of the product detail page loaded
* @param $oProd (jQuery object): contains the html of the product info
* to be loaded in the modal popup window
* @param bIsAccessory (bool): is the call coming from product addon window
*
* @return void
*/
function handleAjaxATCSuccess ( bIsAccessory, sP_Key, $oProd, jsonOrder ) {
/*
* Kbrown 6.19.2014 - #49277
* Added Code to display a back order message when
* the page is using IDP.
*/
if (bUseIDP && bShowBackOrderMessage) {
var iQty = jQuery('#qty_' + sP_Key).val();
var iQtyAvaliable = jQuery('#inventory_qty_' + sP_Key).val() || 0;
var sInventoryStatus = jQuery('#inventory_status_' + sP_Key).val();
if (sInventoryStatus == "Out" || iQty > iQtyAvaliable){
jQuery('#atc_msg_backorder_text').html('
' + sBackorderPlacedMessage +'
');
}
else {
jQuery('#atc_msg_backorder_text').html('');
}
}
/*
* added js var to perform based on whether or not the item just added was an addon product
* johns - 02/20/2013
*/
if ( bShowRecommendedItems && bIsAccessory ) {
jQuery('#atc_msg_product').html('');
jQuery('#qty_' + sP_Key).val('');
jQuery('#atc_msg').css('height', '400px');
} else if ( bShowRecommendedItems && ! bIsAccessory ) {
jQuery('#atc_msg_product').html($oProd);
jQuery.get('i_i_pc_add_ons.asp?searchstring=searchexact~p_id~' + sP_Key + '&modal=1&display=' + sRecommendedItemsView)
.done(function ( sData ) {
jQuery('#atc_msg_addon_container').html(sData);
if ( jQuery('#ors_eof_result').val().toLowerCase() !== 'false' ) {
jQuery('#atc_msg').removeClass('with-recommended');
jQuery('.viewport').css('height', '0');
jQuery('#atc_msg').show();
jQuery('#atc_msg_container').show();
} else {
jQuery('#atc_msg').show();
jQuery('#atc_msg_container').show();
} //- if ( jQuery('#ors_result').val().toLowerCase() !== 'false'
});
jQuery('body').addClass('modal-open');
try {
if(typeof jsonOrder == 'undefined') {
fncCartRefresh();
} else {
fncCartRefresh(jsonOrder[1].item_count, jsonOrder[1].o_total);
}
} catch(err) {
// Silently fail because this is only relevant
// with newer versions of cart preview
}
/*
* normal ajax atc window
* johns - 02/20/2013
*/
} else {
jQuery('#atc_msg_product').html($oProd);
jQuery('#atc_msg_buttons').show();
try {
if(typeof jsonOrder == 'undefined') {
fncCartRefresh();
} else {
fncCartRefresh(jsonOrder[1].item_count, jsonOrder[1].o_total);
}
} catch(err) {
// Silently fail because this is only relevant
// with newer versions of cart preview
}
} //- if ( bShowRecommendedItems && bIsAccessory )
var bShowAtcMsgAddons = false;
if ( ! bShowAtcMsgAddons ) {
jQuery('#atc_msg').show();
jQuery('#atc_msg_container').show();
} //- if ( ! bShowAtcMsgAddons )
} //- function fncHandleAjaxATCSuccess ()
if (bDisableATCZeroQtyWarehouse) {
jQuery('td').delegate('[id^=pw_id_]', 'change', function(event) {
if (jQuery(event.target).children(':selected').text().indexOf("(Qty: 0)") > -1 || jQuery(event.target).children(':selected').text() == "[Select One]") {
sKey = jQuery(event.target).attr("id").replace('pw_id_', '')
jQuery('#' + sKey + ' .btn_addtocart').attr('disabled', 'disabled')
} else {
sKey = jQuery(event.target).attr("id").replace('pw_id_', '')
jQuery('#' + sKey + ' .btn_addtocart').removeAttr('disabled')
}
});
}
jQuery('[id*="get_wh_btn_"]').click(function(){
var sPKey = '';
sKey = $(this).attr("ID");
sPKey = sKey.replace('get_wh_btn_','');
fncGetNewProductWarehouse(sPKey);
});
function fncGetNewProductWarehouse(sPKey) {
try{
jQuery.ajax({
url: sPageName
, data: ({ pageaction : 'getproductwarehouse'
,ajax : genID()
,key : sPKey
,getall : bInStockShowEmptyWarehouses
})
, cache: false
, dataType: "text"
, async: false
, success: function(data){
sDefaultWH = jQuery('#pw_id_' + sPKey).val();
fncDrawNewProductWarehouse(data,sPKey);
if (sDefaultWH.Len == 32) {
jQuery('#pw_id_' + sPKey).val(sDefaultWH);
} else {
jQuery("#pw_id_" + sPKey + " option").not(':contains("Qty: 0")').filter(':first').attr('selected',true);
}
}
});
} catch (err){
//alert(err.message);
}
}
function fncDrawNewProductWarehouse(data,sPKey) {
var aWareHouses, aSubWareHouses;
var sDisplay;
var bSelected = false;
if (data!='') {
$('#wh_td_' + sPKey).html('');
aWareHouses = data.split('|');
for (var i =0; i < aWareHouses.length; i++ ){
aSubWareHouses = aWareHouses[i].split('~');
sDisplay = aSubWareHouses[0];
sPwKey = aSubWareHouses[1];
var newOption = new Option(sDisplay, sPwKey);
$(newOption).html(sDisplay);
$('#pw_id_'+sPKey).append(newOption);
}
} else {
$('#wh_td_' + sPKey).html(sNoWarehouseFound);
}
}
/*
* Register Product warehouse selection
* vinayakj - 6/29/2012
*/
jQuery('[name*="pw_id_"]').click(function(){
var sPKey = '';
sKey = $(this).attr("ID");
sPKey = sKey.replace('pw_id_','');
if (jQuery('#pw_id_click_'+sPKey).val()!='1') {
fncGetProductWarehouse(sPKey);
}
});
/*
* Get Product warehouse
* author - vinayakj
* since - 6/29/2012
*/
function fncGetProductWarehouse(sPKey) {
try{
jQuery.ajax({
url: sPageName
, data: ({ pageaction : 'getproductwarehouse'
,ajax : genID()
,key : sPKey
})
, cache: false
, dataType: "text"
, async: false
, success: function(data){
fncDrawProductWarehouse(data,sPKey);
jQuery('#pw_id_click_'+sPKey).val('1');
$('#pw_id_'+sPKey).val(jQuery('#current_pw_id_'+sPKey).val());
}
});
} catch (err){
//alert(err.message);
}
}
/*
* This will draw Product warehouse with droplist
* author - vinayakj
* since - 6/29/2012
*/
function fncDrawProductWarehouse(data,sPKey) {
var aWareHouses, aSubWareHouses;
var sDisplay;
var bSelected = false;
$('#pw_id_'+sPKey)
.empty()
//.append('')
;
if (data!='') {
aWareHouses = data.split('|');
for (var i =0; i < aWareHouses.length; i++ ){
aSubWareHouses = aWareHouses[i].split('~');
sDisplay = aSubWareHouses[0];
sPwKey = aSubWareHouses[1];
$('#pw_id_'+sPKey).append(new Option(sDisplay, sPwKey));
}
} else {
$('#pw_id_'+sPKey).hide();
$('#no_warehouse_'+sPKey).show();
}
}
/**
* Function to get sub search value and action, then passed to location
* @author pijushb
* @since 7/3/2012
*/
function subSearchForm() {
sSubSearch = jQuery("#sub_search").val();
sActionLink = jQuery("#sub_search_form").attr("action");
sRedirectURL = sActionLink + "&sub_search="+sSubSearch
window.location = sRedirectURL
}
//Added styled modal to use instead of alert() -JMS
function styled_modal_alert(htmlmsg) {
jQuery('#styled_modal_text').html(htmlmsg);
jQuery('#styled_modal_container').show();
jQuery('#styled_modal_msg').show();
jQuery('#styled_modal_buttons').show();
}
jQuery('#styled_modal_close').click(function(e){
e.preventDefault();
jQuery('#styled_modal_container').hide();
jQuery('#styled_modal_msg').hide();
jQuery('#styled_modal_buttons').hide();
jQuery('#styled_modal_text').html('');
});