var mergeSelectionLayerCommand = new Array(2);
mergeSelectionLayerCommand[0] = '/includes/pipeline_items_merge_selector_popup_body.jsp';
mergeSelectionLayerCommand[1] = '/user/pipeline_items_merge.cmd';
var mergeSelectionLayerFixedContainerId = "#widget-fixed-merge-selection-layer";
var mergeSelectionLayerContainerId = "#widget-storeSelection";
var mergeSelectionLayerCloseButClass = ".widget-close-but";
var hideTimeOuts = new Array();
var ssLoadingHTML = '
' +
'
' +
'
' +
' ' +
'
' +
'
' +
'
';
//aduvvuri 01/27/2011 BUG00015 - Added keepLoggedIn parameter to complete merging process before user login
function displayMergeOptionsLayer(dest) {
//showMergeOptionsLayer(dest, keepLoggedIn, false, 0);
var requestURL = mergeSelectionLayerCommand[0];
requestURL += "?dest=" + encodeURIComponent(dest);
layerUtil.openAjaxLayer(requestURL, {
escapeClose: false,
clickClose: false,
showClose: false,
title: 'How would you like to shop?',
modalClass: 'mergeCartLayer button-bottom'
});
}
//aduvvuri 01/27/2011 BUG00015 - Added keepLoggedIn parameter to complete merging process before user login
/* Function(s) to Show the mergeSelection Layer */
function showMergeOptionsLayer(dest, keepLoggedIn, refreshPage, refreshDelayTime) {
showMergeSelectionLayerLoading(ssLoadingHTML);
var requestURL = mergeSelectionLayerCommand[0];
var params = "keepLoggedIn=" + keepLoggedIn + "&dest=" + encodeURIComponent(dest);
$.ajax({
type: "POST",
url: requestURL,
data: params,
dataType: "html",
cache:false,
complete: function() {
$(mergeSelectionLayerCloseButClass).click(function() {
hideMergeLayer();
});
},
success: function(data) {
if (jQuery.trim(data) == "") {
hideMergeLayerLoading();
return false;
}
positionMergeSelectionLayer();
hideMergeLayerLoading();
$(mergeSelectionLayerContainerId).html(data);
$(mergeSelectionLayerContainerId).show();
if (refreshPage != undefined && refreshPage) {
setTimeout(function() {
location.reload(true);
}, refreshDelayTime != undefined ? refreshDelayTime : 0);
}
return true;
},
error: function() {
hideMergeLayerLoading();
return false;
}
});
}
function showMergeSelectionLayerLoading(htmlToShow) {
$(mergeSelectionLayerContainerId).remove();
//load, position, show new cart
$("body").append(htmlToShow);
$(mergeSelectionLayerContainerId).show();
}
;
function hideMergeLayerLoading() {
$(mergeSelectionLayerContainerId + " *").remove();
$(mergeSelectionLayerContainerId).html("");
}
;
//Center the positionMergeSelectionLayer
function positionMergeSelectionLayer() {
$(mergeSelectionLayerContainerId).center();
//Bring the positionMergeSelectionLayer down a bit since the center function is better suited to larger layers
$(mergeSelectionLayerContainerId).css({'top' : '50px', 'width' : '800px', 'left' : '50%', 'margin-left' : '-400px'});
}
;
//Display the layer in a fixed area.
function positionMergeSelectionLayerFixed() {
$(mergeSelectionLayerFixedContainerId).html($(mergeSelectionLayerContainerId));
}
;
//Edit this function if need to do something special on basket close.
function hideMergeLayer() {
$(mergeSelectionLayerContainerId).hide();
$(mergeSelectionLayerContainerId).remove();
}
;
function saveUserMergeOption(dest) {
var pipelineMergeChoice = $("input[name='pipelineMergeChoice']:checked").val();
if (pipelineMergeChoice == undefined) {
pipelineMergeChoice = '';
$("#mergeErrorMessageTop").html("You must select one option below");
$("#mergeErrorMessageBottom").html("You must select one option above");
$(".mergeErrorMessage").addClass("common-error");
return false;
} else {
$(".mergeErrorMessage").html("");
}
if (dest == undefined) {
dest = '';
}
// pipelineMergeChoice submitter form
var submitterId = "cartsMergeForm";
var submitterForm = jQuery("#" + submitterId);
if (submitterForm.length == 0) {
submitterForm = jQuery("");
submitterForm.attr("id", submitterId);
submitterForm.attr("action", "/user/pipeline_items_merge.cmd");
submitterForm.attr("method", "post");
submitterForm.appendTo(jQuery("body"));
}
// pipelineMergeChoice filed
var pipelineMergeChoiceId = "pipelineMergeSelected";
var pipelineMergeChoiceFiled = jQuery("#" + pipelineMergeChoiceId);
if (pipelineMergeChoiceFiled.length == 0) {
pipelineMergeChoiceFiled = jQuery("");
pipelineMergeChoiceFiled.attr("id", pipelineMergeChoiceId);
pipelineMergeChoiceFiled.attr("name", "pipelineMergeChoice");
pipelineMergeChoiceFiled.appendTo(submitterForm);
}
// pipelineMergeChoice destination filed
var destinationId = "pipelineMergeDestination";
var destinationFiled = jQuery("#" + destinationId);
if (destinationFiled.length == 0) {
destinationFiled = jQuery("");
destinationFiled.attr("id", destinationId);
destinationFiled.attr("name", "dest");
destinationFiled.appendTo(submitterForm);
}
// set submitter form field values
pipelineMergeChoiceFiled.val(pipelineMergeChoice);
destinationFiled.val(dest);
submitterForm.submit();
}