dojo.registerModulePath("wc","wc");
dojo.require("dojo.html.*");
dojo.require("dojo.lang.*");
dojo.require("dojo.event.*");
dojo.require("dojo.widget.*");
dojo.require("dojo.xml.Parse");
dojo.require("dojo.json");
dojo.require("dojo.widget.ContentPane");
dojo.require("dojo.widget.ComboBox");
dojo.require("wc.widget.RefreshArea");
dojo.require("wc.render.RefreshController");
dojo.require("wc.render.Context");
dojo.require("wc.widget.WCAccordionContainer");
dojo.require("wc.widget.WCHtmlDropTarget");
dojo.require("wc.widget.TitlePaneTemplate");
dojo.require("wc.widget.ContentPaneTemplate");
dojo.require("wc.widget.ScrollablePane");
dojo.require("wc.widget.ProductQuickView");
dojo.require("wc.widget.ToolTipContent");
dojo.require("dojo.dom");
dojo.require("dojo.io.*");
dojo.require("dojo.lfx.*");
dojo.require("dojo.storage.*");
function wishListUpdated(){
};
function orderUpdated(){
};
function userChanged(){
};
function queryToParamObject(_1,_2,_3){
if(_2==null){
var _2=[];
}
var _4=_1.split("&");
for(var i=0;i<_4.length;i++){
var _6=_4[i];
var _7=_6.split("=");
if(_7!=null&&_7.length>1){
var _8=_7[0];
var _9=_7[1];
_2=updateParamObject(_2,_8,_9,_3);
}
}
return _2;
};
function updateParamObject(_a,_b,_c,_d,_e){
if(_a==null){
_a=[];
}
if(_a[_b]!=null&&_d){
if(dojo.lang.isArrayLike(_a[_b])){
if(_e!=null&&_e!=""){
_a[_b][_e]=_c;
}else{
_a[_b].push(_c);
}
}else{
var _f=_a[_b];
_a[_b]=[];
_a[_b].push(_f);
_a[_b].push(_c);
}
}else{
if(_e!=null&&_e!=""&&_e!=-1){
_a[_b+"_"+_e]=_c;
}else{
if(_e==-1){
var i=1;
while(_a[_b+"_"+i]!=null){
i++;
}
_a[_b+"_"+i]=_c;
}else{
_a[_b]=_c;
}
}
}
return _a;
};
storeAccordionJS={quickCartDrop:null,wishListDrop:null,compareDrop:null,compareCounter:0,compareRowCounter:0,compareItemCatEntry:new Object(),isComparePane:false,allSelectedFromCart:false,showStoreAccordionWaitTime:100,updateWaitTimeOut:1500,defaultShippingInfoParamObject:null,isDefaultShippingProvided:false,shipmentBlockObject:null,isShipmentBlockProvided:false,quickCartForm:[],wishListForm:[],isUpdateCartCalled:false,isShipmentPage:false,flexFlowOptions:new Object(),langId:"-1",storeId:"",catalogId:"",properties:new Object(),errorMessages:new Object(),setErrorMessage:function(key,_12){
this.errorMessages[key]=_12;
},getErrorMessage:function(key){
var _14=this.errorMessages[key];
if(_14==null){
_14="Could not get the message value for specified key "+key;
}
return _14;
},setProperty:function(_15,_16){
this.properties[_15]=_16;
},getProperty:function(_17){
return this.properties[_17];
},removeProperty:function(_18){
delete this.properties[_18];
},setCommonParameters:function(_19,_1a,_1b){
this.langId=_19;
this.storeId=_1a;
this.catalogId=_1b;
},onLoad:function(){
this.initStoreAccordionContainer();
this.quickCartPostRefreshHandler();
this.wishListPostRefreshHandler();
},showStoreAccordion:function(_1c){
if(busyCount>0){
dojo.lang.setTimeout(this,"showStoreAccordion",_1c);
}else{
var _1d=document.getElementById("storeaccordion_div");
var _1e=document.getElementById("espot_div");
_1d.style.visibility="visible";
_1e.style.visibility="visible";
dojo.html.show(_1d);
}
},initStoreAccordionContainer:function(){
dojo.event.kwConnect({srcObj:this,srcFunc:"updateCartWait",targetObj:this,targetFunc:"updateCart",delay:this.updateWaitTimeOut,once:true});
},toggleCheckboxes:function(_1f,_20){
checkAllNode=dojo.byId(_20);
checkItems=dojo.html.getElementsByClass(_1f+"_checkboxItems");
if(checkAllNode.checked){
if(dojo.lang.isArrayLike(checkItems)){
dojo.lang.forEach(checkItems,function(_21){
_21.checked=true;
});
}else{
checkItems.checked=true;
}
}else{
if(dojo.lang.isArrayLike(checkItems)){
var _22=0;
dojo.lang.forEach(checkItems,function(_23){
_23.checked=false;
});
}else{
checkItems.checked=false;
}
}
},updateShippingInfoParams:function(_24){
if(this.defaultShippingInfoParamObject==null){
this.defaultShippingInfoParamObject=new Object();
}
for(shippingInfoParamName in _24){
this.defaultShippingInfoParamObject[shippingInfoParamName]=_24[shippingInfoParamName];
this.isDefaultShippingProvided=true;
}
},resetShippingInfoParams:function(){
this.defaultShippingInfoParamObject=null;
this.isDefaultShippingProvided=false;
},updateShipmentBlockObject:function(_25){
this.shipmentBlockObject=_25;
this.isShipmentBlockProvided=true;
},resetShipmentBlockObject:function(){
this.shipmentBlockObject=null;
this.isShipmentBlockProvided=false;
},addItemWithShipingInfo:function(_26){
var _27=wc.service.declare({id:"AjaxAddOrderItemWithShipingInfo",actionId:"AjaxAddOrderItemWithShipingInfo",url:"AjaxOrderChangeServiceItemAdd",successHandler:function(_28){
},failureHandler:function(_29){
if(_29!=null&&_29.errorMessage!=null){
alertDialog(_29.errorMessage,this.storeId,this.catalogId,this.langId);
}else{
if(_29!=null&&_29.errorMessageKey!=null){
alertDialog(_29.errorMessageKey,this.storeId,this.catalogId,this.langId);
}else{
alert("Error");
}
}
}});
dojo.event.kwConnect({srcObj:_27,srcFunc:"successHandler",targetObj:this,targetFunc:"updateItemDefaultShipingInfo",once:true});
wc.service.invoke("AjaxAddOrderItemWithShipingInfo",_26);
cursor_wait();
},updateItemDefaultShipingInfo:function(_2a){
for(paramName in this.defaultShippingInfoParamObject){
for(items in _2a["orderItemId"]){
_2a=updateParamObject(_2a,paramName,this.defaultShippingInfoParamObject[paramName],false,-1);
}
}
this.alertParams(_2a);
wc.service.invoke("OrderItemShipmentBlockUpdate",_2a);
cursor_wait();
},quickCartDropEventHandler:function(_2b){
this.add2ShopCartAjaxForDroppedItems(_2b.dragSource.dragObject);
return true;
},add2ShopCartAjaxForDroppedItems:function(_2c){
var _2d=[];
_2d.storeId=this.storeId;
_2d.catalogId=this.catalogId;
_2d.langId=this.langId;
_2d.orderId=".";
_2d.catEntryId=_2c.catentryId;
_2d.quantity="1";
if(!this.isDefaultShippingProvided){
this.alertParams(_2d);
wc.service.invoke("AjaxAddOrderItem",_2d);
}else{
this.addItemWithShipingInfo(_2d);
}
cursor_wait();
},deleteFromCart:function(){
var _2e=[];
_2e.storeId=this.storeId;
_2e.catalogId=this.catalogId;
_2e.langId=this.langId;
var _2f=false;
checkItems=dojo.html.getElementsByClass("QuickCartForm_checkboxItems");
if(dojo.lang.isArrayLike(checkItems)){
dojo.lang.forEach(checkItems,function(_30){
if(_30.checked){
var _31=_30.value;
_31=eval("("+_31+")");
for(key in _31){
_2e=updateParamObject(_2e,key,_31[key],false,-1);
}
_2f=true;
}
});
}else{
if(checkItems.checked==true){
var _32=checkItems.value;
_32=eval("("+_32+")");
for(key in _32){
_2e=updateParamObject(_2e,key,_32[key],false);
}
_2f=true;
}
}
if(_2f){
_2e.orderId=".";
this.alertParams(_2e);
wc.service.invoke("AjaxDeleteOrderItem",_2e);
cursor_wait();
}
var _33=dojo.byId("checkAllCartItem");
_33.checked=false;
},moveFromCart:function(){
var _34=false;
var _35=[];
_35.storeId=this.storeId;
_35.catalogId=this.catalogId;
_35.langId=this.langId;
var _36=[];
_36.storeId=this.storeId;
_36.catalogId=this.catalogId;
_36.langId=this.langId;
checkItems=dojo.html.getElementsByClass("QuickCartForm_checkboxItems");
if(dojo.lang.isArrayLike(checkItems)){
dojo.lang.forEach(checkItems,function(_37){
if(_37.checked){
var _38=_37.value;
_38=eval("("+_38+")");
for(key in _38){
var _39=_38[key];
_35=updateParamObject(_35,key,_39,false,-1);
_36=updateParamObject(_36,key,_39,false,-1);
}
_34=true;
}
});
}else{
if(checkItems.checked==true){
var _3a=checkItems.value;
_3a=eval("("+_3a+")");
for(key in _3a){
_35=updateParamObject(_35,key,_3a[key],false);
_36=updateParamObject(_36,key,_3a[key],false);
}
_34=true;
}
}
if(_34){
_35.orderId=".";
this.alertParams(_35);
wc.service.invoke("AjaxDeleteOrderItem",_35);
cursor_wait();
_36.URL="SuccessfulAJAXRequest";
this.alertParams(_36);
wc.service.invoke("AjaxInterestItemAdd",_36);
cursor_wait();
}
var _3b=dojo.byId("checkAllCartItem");
_3b.checked=false;
},updateCartWait:function(_3c,_3d){
},updateCart:function(_3e,_3f){
var _40=parseInt(_3e.value);
if(!isNaN(_40)){
var _41=[];
_41.storeId=this.storeId;
_41.catalogId=this.catalogId;
_41.langId=this.langId;
_41.orderId=".";
_41.quantity=_40;
_41.orderItemId=_3f;
this.alertParams(_41);
wc.service.invoke("AjaxUpdateOrderItem",_41);
cursor_wait();
}else{
}
},wishListDropEventHandler:function(_42){
this.add2WishListAjaxForDroppedItems(_42.dragSource.dragObject);
return true;
},add2WishListAjaxForDroppedItems:function(_43){
var _44=[];
_44.storeId=this.storeId;
_44.catalogId=this.catalogId;
_44.langId=this.langId;
if(_43.catentryId==null){
return;
}
if(typeof _43.orderId!="undefined"&&typeof _43.orderItemId!="undefined"){
_44.orderId=".";
_44.orderItemId=_43.orderItemId;
this.alertParams(_44);
wc.service.invoke("AjaxDeleteOrderItem",_44);
cursor_wait();
}
_44.URL="SuccessfulAJAXRequest";
_44.catEntryId=_43.catentryId;
this.alertParams(_44);
wc.service.invoke("AjaxInterestItemAdd",_44);
cursor_wait();
},deleteFromWishList:function(){
var _45=[];
_45.storeId=this.storeId;
_45.catalogId=this.catalogId;
_45.langId=this.langId;
var _46=false;
checkItems=dojo.html.getElementsByClass("WishListForm_checkboxItems");
if(dojo.lang.isArrayLike(checkItems)){
dojo.lang.forEach(checkItems,function(_47){
if(_47.checked){
var _48=_47.value;
_48=eval("("+_48+")");
for(key in _48){
_45=updateParamObject(_45,key,_48[key],true);
}
_46=true;
}
});
}else{
if(checkItems.checked==true){
var _49=checkItems.value;
_49=eval("("+_49+")");
for(key in _49){
_45=updateParamObject(_45,key,_49[key],false);
}
_46=true;
}
}
if(_46){
_45.URL="SuccessfulAJAXRequest";
this.alertParams(_45);
wc.service.invoke("AjaxInterestItemDelete",_45);
cursor_wait();
}
var _4a=dojo.byId("checkAllWishListItem");
_4a.checked=false;
},moveFromWishList:function(){
var _4b=[];
_4b.storeId=this.storeId;
_4b.catalogId=this.catalogId;
_4b.langId=this.langId;
var _4c=false;
checkItems=dojo.html.getElementsByClass("WishListForm_checkboxItems");
if(dojo.lang.isArrayLike(checkItems)){
dojo.lang.forEach(checkItems,function(_4d){
if(_4d.checked){
var _4e=_4d.value;
_4e=eval("("+_4e+")");
for(key in _4e){
_4b=updateParamObject(_4b,key,_4e[key],false,-1);
}
_4c=true;
}
});
}else{
if(checkItems.checked==true){
var _4f=checkItems.value;
_4f=eval("("+_4f+")");
for(key in _4f){
_4b=updateParamObject(_4b,key,_4f[key],false);
}
_4c=true;
}
}
if(_4c){
_4b.orderId=".";
if(!this.isDefaultShippingProvided){
this.alertParams(_4b);
wc.service.invoke("AjaxAddOrderItem",_4b);
}else{
this.addItemWithShipingInfo(_4b);
}
cursor_wait();
}
var _50=dojo.byId("checkAllWishListItem");
_50.checked=false;
},fastCheckout:function(_51){
wc.service.declare({id:"FastCheckOutPrepareOrder",actionId:"FastCheckOutPrepareOrder",url:"AjaxOrderProcessServiceOrderPrepare",formId:_51,successHandler:function(_52){
cursor_clear();
wc.service.invoke("AjaxSubmitOrder");
},failureHandler:function(_53){
if(_53!=null&&_53.errorMessage!=null){
alertDialog(_53.errorMessage,this.storeId,this.catalogId,this.langId);
}else{
alert("Error");
}
}});
wc.service.declare({id:"FastCheckOutOrderCopy",actionId:"FastCheckOutOrderCopy",url:"AjaxOrderCopy",formId:_51,successHandler:function(_54){
cursor_clear();
wc.service.invoke("FastCheckOutPrepareOrder");
cursor_wait();
},failureHandler:function(_55){
if(_55!=null&&_55.errorMessage!=null){
alertDialog(_55.errorMessage,this.storeId,this.catalogId,this.langId);
}else{
alert("Error");
}
}});
wc.service.invoke("FastCheckOutOrderCopy");
cursor_wait();
},showCompare:function(_56){
this.isComparePane=_56;
},getStorageKey:function(){
var _57="CompareItems";
var _58=this.getProperty("sessionId");
var _59=0;
for(i=0;i<_58.length;i++){
_59=_59+_58.charCodeAt(i);
}
_57=_57+_59;
return _57;
},initializeCompare:function(){
var _5a=this.getStorageKey();
if(this.isComparePane){
this.compareCounter=0;
this.compareRowCounter=0;
this.compareItemCatEntry=new Object();
var _5b=StorageJS.load(_5a);
if(_5b!=null){
this.compareItemCatEntry=_5b;
}
var _5c=document.getElementById("compareZone");
var _5d=_5c.childNodes;
for(i=0;i<_5d.length;i++){
if(_5d[i].id!="compareDropZoneImg"){
_5c.removeChild(_5d[i]);
}
}
var _5e=true;
for(catEntryIdentifier in this.compareItemCatEntry){
this.compareCounter++;
if(this.compareCounter<=6){
var _5f=document.CompareForm.catentryId[this.compareCounter-1].value=catEntryIdentifier;
for(i=0;i<_5d.length;i++){
if(_5d[i].id=="compareDropZoneImg"){
_5c.removeChild(_5d[i]);
}
}
var td1=document.createElement("td");
td1.setAttribute("id","compareCatentry"+_5f);
var _61=document.createElement("div");
_61.setAttribute("id","compareCatentryCheckBoxContainer"+_5f);
var _62=document.createElement("input");
_62.setAttribute("id","compareCatentryCheckBox"+_5f);
_62.setAttribute("type","checkbox");
_62.setAttribute("class","CompareForm_checkboxItems");
_62.setAttribute("value",catEntryIdentifier);
_61.appendChild(_62);
var _63=document.createElement("div");
_63.setAttribute("id","compareCatentryContainer"+_5f);
td1.appendChild(_61);
td1.appendChild(_63);
_63.innerHTML=this.compareItemCatEntry[catEntryIdentifier];
var _64=dojo.dom.getFirstChildElement(_63);
var _65=new dojo.dnd.HtmlDragSource(_64,"compare_item");
_65.dragObject["catentryId"]=catEntryIdentifier;
if(((this.compareCounter-1)%3)==0){
this.compareRowCounter++;
var tr1=document.createElement("tr");
tr1.setAttribute("id","compareRow"+this.compareRowCounter);
}else{
var tr1=document.getElementById("compareRow"+this.compareRowCounter);
}
tr1.appendChild(td1);
if(_5e){
var _67=document.createElement("table");
var _68=document.createElement("tbody");
_68.setAttribute("id","compareItemsTable");
_67.appendChild(_68);
_68.appendChild(tr1);
_5c.appendChild(_67);
}else{
var _68=document.getElementById("compareItemsTable");
_68.appendChild(tr1);
}
_5e=false;
}
}
}
},Add2CompareAjax:function(_69,_6a){
var _6b=this.getStorageKey();
if(_69 in this.compareItemCatEntry||_69==null){
alert(this.getErrorMessage("compareItemExist"));
return false;
}else{
this.compareCounter++;
if(this.compareCounter<=6){
document.CompareForm.catentryId[this.compareCounter-1].value=_69;
var _6c=_6a.innerHTML.replace(/^\s+/,"").replace(/\s+$/,"");
_6c=_6c.replace(/\"/g,"'").replace(/\r|\n|\r\n|\n\r/g,"");
this.compareItemCatEntry[_69]=_6c;
StorageJS.save(_6b,this.compareItemCatEntry,-1);
this.initializeCompare();
}else{
alert(this.getErrorMessage("compareMaxItems"));
}
}
},Add2CompareAjaxWith:function(_6d,_6e,url){
var _70=this.getStorageKey();
if(_6d in this.compareItemCatEntry||_6d==null){
alert(this.getErrorMessage("compareItemExist"));
}else{
this.compareCounter++;
if(this.compareCounter<=6){
document.CompareForm.catentryId[this.compareCounter-1].value=_6d;
var _id="Compare_Item_"+_6d;
var _72=""+"\t<a id='imgcatBrowse"+_id+"' href='"+url+"' >\n"+"\t\t<img src='"+_6e+"' alt='"+_6e+"' border='0' />\n"+"\t</a>\n";
_72=_72.replace(/\"/g,"'").replace(/\r|\n|\r\n|\n\r/g,"");
this.compareItemCatEntry[_6d]=_72;
StorageJS.save(_70,this.compareItemCatEntry,-1);
this.initializeCompare();
}else{
alert(this.getErrorMessage("compareMaxItems"));
}
}
},compareDropEventHandler:function(_73){
_73.dragSource.type="compare_item";
var _74=_73.dragObject.domNode;
var _75=_73.dragSource.dragObject.catentryId;
var _76=_73.dragObject.domNode;
var _74=_76.cloneNode(true);
this.Add2CompareAjax(_75,_74);
},increaseCompareCounter:function(){
this.compareCounter++;
},deleteFromCompareZone:function(){
var _77=this.getStorageKey();
checkItems=dojo.html.getElementsByClass("CompareForm_checkboxItems");
var _78=[];
if(dojo.lang.isArrayLike(checkItems)){
dojo.lang.forEach(checkItems,function(_79){
if(_79.checked){
var _7a=parseInt(_79.value);
_78.push(_7a);
this.compareCounter--;
}
});
}else{
if(checkItems.checked==true){
var _7b=parseInt(checkItems.value);
_78.push(_7b);
this.compareCounter--;
}
}
for(index in _78){
delete this.compareItemCatEntry[_78[index]];
}
StorageJS.save(_77,this.compareItemCatEntry,-1);
this.initializeCompare();
var _7c=dojo.byId("checkAllCompareItem");
_7c.checked=false;
},compareProducts:function(){
var _7d=this.getStorageKey();
var _7e=StorageJS.load(_7d);
if(_7e!=null){
this.compareItemCatEntry=_7e;
}
var url=document.CompareForm.action+"?storeId="+document.CompareForm.storeId.value+"&catalogId="+document.CompareForm.catalogId.value+"&langId="+document.CompareForm.langId.value+"&categoryId="+document.CompareForm.categoryId.value;
for(catEntryIdentifier in this.compareItemCatEntry){
url=url+"&catentryId="+catEntryIdentifier;
}
document.location.href=url;
},quickCartPostRefreshHandler:function(){
if(!("quickCart" in this.flexFlowOptions)||("quickCart" in this.flexFlowOptions&&this.flexFlowOptions["quickCart"]==true)){
var _80="QuickCartForm";
var _81="miniQuickCartText";
if(document.getElementById(_81)){
document.getElementById("QuickCartTilePaneString").innerHTML=document.getElementById(_81).value;
}
this.updateShipmentSelectBoxes();
}
},wishListPostRefreshHandler:function(){
if(!("wishList" in this.flexFlowOptions)||("wishList" in this.flexFlowOptions&&this.flexFlowOptions["wishList"]==true)){
var _82="WishListForm";
var _83="miniWishListText";
if(document.getElementById(_83)){
document.getElementById("WishListTilePaneString").innerHTML=document.getElementById(_83).value;
}
}
},updateShipmentSelectBoxes:function(){
if(this.isShipmentPage){
this.shipmentBlockObject=shipmentPageJS.getQuickCartHelperObjects();
if(this.shipmentBlockObject!=null){
var _84="";
var _85=dojo.widget.manager.getWidgetsByFilter(this.quickCartProductQuickViewFilter,false);
for(widget in _85){
var _86=_85[widget];
if(_86!=null&&_86.shipmentSelectBoxId!=null){
var i=_86.orderItemId;
var _88=document.getElementById("SelectBoxSelectedValue_"+i);
for(_89 in this.shipmentBlockObject){
var _8a=this.shipmentBlockObject[_89];
var _89=parseInt(_89);
if(_86.addressId==_8a.addressId&&_86.shipModeId==_8a.shipModeId){
_84=_89+1;
break;
}
}
_88.innerHTML=_84;
}else{
alert("shipmentSelectBoxId property is not set under additionalProperties for ProductQuickViewWidget");
}
}
}
}
},quickCartProductQuickViewFilter:function(_8b){
var _8c="productquickview";
if(_8b.widgetType.toLowerCase()==_8c){
tempStr=_8b.identifier;
tempStr=tempStr.substring(0,17);
if(tempStr=="quickCartCatEntry"){
return true;
}
}
return false;
},shipmentChanged:function(_8d,_8e){
_8d=eval("( "+_8d+" )");
var _8f=dojo.byId(_8e).options[dojo.byId(_8e).selectedIndex].value;
if(shipmentPageJS.isValidBlock(_8f)){
var _90=eval("("+shipmentPageJS.getQuickCartHelperObjects()[_8f-1]+")");
for(newParam in _90){
_8d=updateParamObject(_8d,newParam,_90[newParam],false);
}
this.updateItemShipingInfo(_8d);
}else{
alert("Please select a valid address and shipping method in Shipment "+_8f);
}
},updateItemShipingInfo:function(_91){
wc.service.invoke("OrderItemShipmentBlockUpdate",_91);
cursor_wait();
},showShipment:function(_92){
this.isShipmentPage=_92;
},setFlexFlowOptions:function(key,_94){
this.flexFlowOptions=updateParamObject(this.flexFlowOptions,key,_94,false);
},alertParams:function(_95){
var str="";
for(x in _95){
str=str+"\n"+x+":"+_95[x];
}
}};

