function _shoppingList(shoppingListId){this.parentListId=undefined;this.shoppingListId=shoppingListId;this.productDivId=0;this.orgListItemId=0;this.productOpenCmsUuid=0;this.createNew=function(parentListId,estimateData){var url='/en/my-projects/shopping-list.html';var data={localeId:vReqBean.localeId,shoppingListId:'create_new'};if(parentListId>0){this.parentListId=parentListId;data['parentListId']=parentListId;}else{this.parentListId=undefined;}
if(estimateData!=undefined){data['estimateData']=estimateData;overlayWindow.replaceDiv({url:url,data:data});}else{overlayWindow.showDiv({url:url,data:data});}};this.saveList=function(newName){var url='/en/my-projects/shopping-list-save.html';var data={localeId:vReqBean.localeId,shoppingListId:this.shoppingListId};overlayWindow.showDiv({url:url,data:data});};this.doSaveList=function(){var vService=new VServiceRenameShoppingList();vService.shoppingListId=this.shoppingListId;vService.newName=$('#newShoppingListName').val();var thisClips;if(typeof clips!="undefined")
thisClips=clips;var that=this;overlayWindow.closeDiv(function(){var data=vService.getResponse();if(vService.isSuccessful){if(thisClips){thisClips.refreshShow(that.parentListId);}}});};this.closeList=function(){var thisClips;if(typeof clips!="undefined")
thisClips=clips;var that=this;overlayWindow.closeDiv(function(){if(thisClips){thisClips.refreshShow(that.parentListId);}});};this.displaySelectProductPaint=function(divId,openCmsUuid,channelCode){this.productDivId=divId;this.productOpenCmsUuid=openCmsUuid;var url='/en/my-projects/shopping-list-select-paint.html?openCmsUuid='+openCmsUuid+'&channelCode='+channelCode;if(myEstimator&&(myEstimator.isIntExt=="exterior")){url+="&isIntExt=exterior_products";}
overlayWindow.showDiv({url:url});};this.doSelectProductPaint=function(){var that=this;$("input[name='productPaintUuid']:checked").each(function(i,elem){var openCmsUuid=elem.value;var data={usrOrganizerListId:that.shoppingListId,openCmsUuid:openCmsUuid,localeId:vReqBean.localeId,finishValues:[]};$('#'+openCmsUuid+'_finish_select').find("input[name='finishValues']:checked").each(function(i,elem){data.finishValues.push(elem.value);});$.ajax({url:"shopping_list_paint.html",type:"POST",cache:false,async:false,data:(data),success:function(msg){$('#'+that.productDivId).after(msg);},error:function(XMLHttpRequest,textStatus,errorThrown){alert(errorThrown);}});});this.removeItem(this.productDivId,'opencms_product_paint',this.productOpenCmsUuid);overlayWindow.closeDiv();};this.skipSelectProductPaint=function(){overlayWindow.closeDiv();this.removeItem(this.productDivId,'opencms_product_paint',this.productOpenCmsUuid);};this.displaySelectProductPrimer=function(divId,openCmsUuid,channelCode){this.productDivId=divId;this.productOpenCmsUuid=openCmsUuid;var url='/en/my-projects/shopping-list-select-primer.html?openCmsUuid='+openCmsUuid+'&channelCode='+channelCode;if(myEstimator&&(myEstimator.isIntExt=="exterior")){url+="&isIntExt=exterior_products";}
overlayWindow.showDiv({url:url});};this.doSelectProductPrimer=function(){var that=this;$("input[name='productPrimerUuid']:checked").each(function(i,elem){var openCmsUuid=elem.value;var data={usrOrganizerListId:that.shoppingListId,openCmsUuid:openCmsUuid,localeId:vReqBean.localeId};$.ajax({url:"shopping_list_primer.html",type:"POST",cache:false,async:false,data:(data),success:function(msg){$('#'+that.productDivId).after(msg);},error:function(XMLHttpRequest,textStatus,errorThrown){alert(errorThrown);}});});this.removeItem(this.productDivId,'opencms_product_primer',this.productOpenCmsUuid);overlayWindow.closeDiv();};this.skipSelectProductPrimer=function(){this.removeItem(this.productDivId,'opencms_product_primer',this.productOpenCmsUuid);overlayWindow.closeDiv();};this.displaySelectProductFinish=function(divId,openCmsUuid,orgListItemId){this.productDivId=divId;this.productOpenCmsUuid=openCmsUuid;this.orgListItemId=orgListItemId;var url='/en/my-projects/shopping-list-select-finish.html?openCmsUuid='+openCmsUuid;overlayWindow.showDiv({url:url});};this.doSelectProductFinish=function(){var data={orgListItemId:this.orgListItemId,localeId:vReqBean.localeId,finishValues:[]};$("input[name='finishValues']:checked").each(function(i,elem){data.finishValues.push(elem.value);});var that=this;$.ajax({url:"shopping_list_paint.html",type:"POST",cache:false,async:false,data:(data),success:function(msg){$('#'+that.productDivId).replaceWith(msg);},error:function(XMLHttpRequest,textStatus,errorThrown){alert(errorThrown);}});overlayWindow.closeDiv();};this.skipSelectProductFinish=function(divId,openCmsUuid){overlayWindow.closeDiv();};this.removeEsimateItem=function(divId,itemType,orgListId){switch(divId){case'estimate_paint_primer':myEstimator.hide_estimate_paint_primer=true;break;case'estimate_contrasting_colors':myEstimator.hide_estimate_contrasting_colors=true;break;case'estimate_items_prep':myEstimator.hide_estimate_items_prep=true;if(myEstimator.hide_estimate_items_paint){divId='estimate_items';}
break;case'estimate_items_paint':myEstimator.hide_estimate_items_paint=true;if(myEstimator.hide_estimate_items_prep){divId='estimate_items';}
break;}
return estWorker.ajaxSaveToOrganizer(function(){var thatDiv=$('#'+divId);thatDiv.slideUp('fast',function(){thatDiv.remove();});});};this.removeItem=function(divId,itemType,orgListId){var vService=new VServiceRemoveOrgItem();vService.usrOrganizerListId=this.shoppingListId;vService.orgListId=orgListId;vService.type=itemType;var data=vService.getResponse();if(vService.isSuccessful){var thatDiv=$('#'+divId);thatDiv.slideUp('fast',function(){var parent=thatDiv.parent();thatDiv.remove();var children=parent.children();if(children.length==1){parent.slideUp('fast',function(){parent.remove();});}});}};this.doSearchRetailer=function(divId,retailerType){var zipCode=$('#'+divId+'_zipcode').val();var data={usrOrganizerListId:this.shoppingListId,retailerType:retailerType,localeId:vReqBean.localeId,zipCode:zipCode};$.ajax({url:"shopping_list_retailer.html",type:"POST",cache:false,async:false,data:(data),success:function(msg){$('#'+divId).replaceWith(msg);},error:function(XMLHttpRequest,textStatus,errorThrown){alert(errorThrown);}});};}
var shoppingList=new _shoppingList();
