(function(){var A=YAHOO.lang,E=YAHOO.util.Dom,F=YAHOO.util.Event,B=ZC.Util,C=YAHOO.util.Selector;var D=ZC.Core.Block.Create("RepairQuote_Controller","Imperial");D.prototype.CustomSetupEnd=function(){if(this.GetAttrib("LocalePrompt")){B.Alert("This service is only useful within the UK.",{Icon:"BLOCK"})}return true};var D=ZC.Core.Block.Create("ChooseMark","Imperial");D.prototype.CustomSetupEnd=function(){F.delegate("marks","click",this.ChoseMark,"li",this,true)};D.prototype.ChoseMark=function(H,I,K){var G,J;if(F.getTarget(H).nodeName=="A"){return true}G=C.query("a.marklink",I,true);if(!A.isUndefined(G)&&G.href){if(YAHOO.env.ua.ie){var J=document.createElement("a");J.href=G.href;document.body.appendChild(J);J.click()}else{document.location=G.href}}F.stopEvent(H)};var D=ZC.Core.Block.Create("RepairQuote_DamagedAreas","Imperial");D.prototype.CustomSetupEnd=function(){var G,H;G=E.get("vehicle-damage-areas"),this.aAreas=E.getChildren(G);this.aAreas=this.aAreas.concat(E.getChildren(E.get("areas")));F.addListener(this.aAreas,"mouseenter",this.HighlightArea,{},this);F.addListener(this.aAreas,"mouseleave",this.LowlightArea,{},this)};D.prototype.ResolveToElWithID=function(G){while(G.nodeName!="LI"&&G.nodeName!="AREA"&&G.nodeName!="BODY"){G=G.parentNode}if(G.nodeName!="LI"&&G.nodeName!="AREA"){return false}return G};D.prototype.HighlightArea=function(I){var H=F.getTarget(I),G;H=this.ResolveToElWithID(H);if(!H){return true}B.ForEach(this.aAreas,this.LowlightArea,this);G=this.AreaNameFromAreaID(H.id);E.addClass([G,G+"-image"],"highlight")};D.prototype.LowlightArea=function(H){var G;if(!H.nodeName&&A.isObject(H)){H=F.getTarget(H)}G=this.AreaNameFromAreaID(H.id);E.removeClass([G,G+"-image"],"highlight")};D.prototype.AreaNameFromAreaID=function(G){return G.replace(/-area/,"")};var D=ZC.Core.Block.Create("RepairQuote_ChoosePart","Imperial");D.prototype.CustomSetupEnd=function(){var H,G;this.THIRD_PARTY_OPTION="THIRDPARTY";this.oPartID=this.GetWidget("ChoosePart.partid");this.oCustPartPrice=this.GetWidget("ChoosePart.OverridePartPrice");this.oRepairerPartPrice=this.GetWidget("ChoosePart.OverrideRepairerPartPrice");this.elRepairOptionsWrapper=E.get("repair-options");this.elPaintingOption=E.get("ChoosePart.NotRepairableNeedPainting");if(this.GetAttribDefault("PartChoiceAvailable")){E.addClass(this.elRepairOptionsWrapper,"hide")}if(!this.GetAttribDefault("PartChoiceAvailable")&&!this.GetPartAttrib("NONEOFTHEABOVE","AskPainting",true)){E.addClass(this.elPaintingOption,"hide")}this.elThirdPartyPartWrapper=E.get("third-party-part-details");if(this.GetAttribDefault("PartChoiceAvailable")||!this.GetAttribDefault("IsRepairer")){E.addClass(this.elThirdPartyPartWrapper,"hide")}if(this.GetAttribDefault("IsRepairer")){E.removeClass(E.getElementsByClassName("repaireroptions","div","repair-options"),"hide");E.removeClass(E.getElementsByClassName("repaireroptions","table","repair-options"),"hide")}F.delegate("partslist","click",this.HandlePartChoiceChange,"li",this,true);this.aelPartContainers=C.query("li","partslist");B.ForEach(this.aelPartContainers,function(I){if(E.hasClass(I,"preselected")){this.HandlePartChoiceChange(false,I,"partslist",false)}},this);if(this.oPartID.GetValue()){this.HandlePartChoiceChange({},E.get("overview-"+this.oPartID.GetValue(),E.get("partslist")))}G=E.getAttribute("ChoosePart.resolutiontype","value");if(G){this.ResolutionChange(G)}return true};D.prototype.GetPartAttrib=function(J,G,H){var I=this.GetAttribDefault("PartDef",[]);if(!A.isUndefined(I[J][G])){return I[J][G]}return H};D.prototype.HandlePartChoiceChange=function(G,H,I){var L,K,J,M;M=F.getTarget(G);if(M&&M.nodeName=="INPUT"&&E.hasClass(M,"brq-button")){this.HandleResolutionChange(G);return true}else{if(M&&(M.id=="admin-settings"||E.isAncestor("admin-settings",M))){return true}}B.ForEach(this.aelPartContainers,function(N){E.removeClass(N,"preselected")});E.addClass(H,"preselected");L=H.id.replace(/(overview-)/,"");this.oPartID.SetValue(L);if(this.GetAttribDefault("IsRepairer")){this.oCustPartPrice.SetValue(this.GetPartAttrib(L,"PartPrice",0));this.oRepairerPartPrice.SetValue(this.GetPartAttrib(L,"RepairerPartPrice",0))}if(this.GetPartAttrib(L,"AskPainting",true)){E.removeClass(this.elPaintingOption,"hide")}else{E.addClass(this.elPaintingOption,"hide")}if(L==this.THIRD_PARTY_OPTION){E.removeClass(this.elThirdPartyPartWrapper,"hide")}else{E.addClass(this.elThirdPartyPartWrapper,"hide")}H.appendChild(this.elRepairOptionsWrapper);E.removeClass(this.elRepairOptionsWrapper,"hide");E.addClass("admin-settings","hide");E.setAttribute("ChoosePart.resolutiontype","value","")};D.prototype.HandleResolutionChange=function(G){if(this.GetAttribDefault("IsRepairer")){var H=F.getTarget(G);F.preventDefault(G);this.ResolutionChange(H.name)}};D.prototype.ResolutionChange=function(H){var G="ChoosePart."+H;E.insertAfter("admin-settings",G);E.removeClass("admin-settings","hide");if(H.search(/NotRepairable/)!=-1){E.removeClass("replace-settings","hide");E.addClass("repair-settings","hide")}else{if(H.search(/Repairable/)!=-1){E.removeClass("repair-settings","hide");E.addClass("replace-settings","hide")}}if(this.GetPartAttrib(this.oPartID.GetValue(),"Paintable",true)||H.search(/NeedPainting/)!=-1){E.removeClass("painting-settings","hide")}else{E.addClass("painting-settings","hide")}E.removeClass("repairernotes","hide");E.setAttribute("ChoosePart.resolutiontype","value",H)};var D=ZC.Core.Block.Create("RepairQuote_Admin_EditEstimate","Imperial");D.prototype.CustomSetupEnd=function(){var G;this.EnableDisableAddToBasket();G=this.GetWidgetsBy(function(H){return H instanceof ZC.Core.Widget.Checkbox});B.ForEach(G,function(H){H.AddEvent(this.EnableDisableAddToBasket,"change",this)},this);return true};D.prototype.EnableDisableAddToBasket=function(){var H,I,G;H=this.GetWidget("DamagedAreas.AddToBasket");I=this.GetWidgetsBy(function(J){return J instanceof ZC.Core.Widget.Checkbox});G=B.Some(I,function(J){return J.GetValue()});H.Enable(G)}})();
