window.LGI=window.LGI||{};
LGI.VirginMedia=LGI.VirginMedia||{};
LGI.VirginMedia.ServiceabilityProductOptions=LGI.VirginMedia.ServiceabilityProductOptions||{};
LGI.VirginMedia.ServiceabilityProductOptions.showBBSpecialMessage=function(a){if(a.BroadBand.BroadbandSeenstatus===true){$(".serviceability-heropod .greatnewstext-placeholder .bbprelit").show();
$(".serviceability-heropod .greatnewstext-placeholder .bbnotprelit").hide()
}else{$(".serviceability-heropod .greatnewstext-placeholder .bbnotprelit").show();
$(".serviceability-heropod .greatnewstext-placeholder .bbprelit").hide()
}$(".serviceability-heropod .greatnewstext-placeholder .available").hide();
$(".serviceability-heropod .greatnewstext-placeholder .unavailable").hide()
};
LGI.VirginMedia.ServiceabilityProductOptions.updateProductOption=function(a){};
LGI.VirginMedia.ServiceabilityProductOptions.hideServiceabilityresultsSection=function(b){if(!LGI.VirginMedia.ServiceabilityProductOptions.isEditMode()){var a=b.find(".serviceability-results-section");
a.hide();
$(".serviceabilityresultssection").hide()
}};
LGI.VirginMedia.ServiceabilityProductOptions.isEditMode=function(){if(window.CQ!=undefined&&CQ.WCM!=undefined){return CQ.WCM.isEditMode(true)
}};
LGI.VirginMedia.ServiceabilityProductOptions.updateProductOptions=function(a){$(".serviceabilityresultssection").show()
};
LGI.VirginMedia.ServiceabilityProductOptions.isServicecheckCompleted=function(b){var a=sessionStorage.getItem("serviceabilitySummary");
if(!jQuery.isEmptyObject(a)){var c=JSON.parse(a);
if(c.BroadBand.Serviceability!=null||c.Phone.Serviceability!=null||c.MIA.Serviceability!=null){return true
}else{return false
}}else{return false
}};
LGI.VirginMedia.ServiceabilityProductOptions.isOffNetBroadband=function(b){var a=sessionStorage.getItem("serviceabilitySummary");
if(!jQuery.isEmptyObject(a)){var c=JSON.parse(a);
if(c.BroadBand.Serviceability=="OFFNET"||c.BroadBand.Serviceability=="nonserviceable"||c.BroadBand.Serviceability==null){return true
}else{return false
}}else{return false
}};
LGI.VirginMedia.ServiceabilityProductOptions.fetchAndDisplaySelectedAddressDetails=function(){var a=sessionStorage.getItem("selectedAddress");
if(!jQuery.isEmptyObject(a)){var b=JSON.parse(a);
$(".selectedaddressdetails .addresswithpincode").text(b.formattedDisplayAddress.businessFormattedDisplayAddressLine+", "+b.town+", "+b.postcode)
}};
LGI.VirginMedia.ServiceabilityProductOptions.appendQueryParamsToURL=function(b){var e="";
var c=sessionStorage.getItem("basketId");
var a=sessionStorage.getItem("postcodeval");
var f=sessionStorage.getItem("selectedAddress");
var d=false;
if(c&&b.indexOf("b=")<=-1){e=e+"b="+c;
d=true
}if(a&&b.indexOf("p=")<=-1){if(e.length>0){e=e+"&"
}e=e+"p="+a;
d=true
}if(f&&b.indexOf("u=")<=-1){f=JSON.parse(f);
if(e.length>0){e=e+"&"
}e=e+"u="+f.addressIdentification.UPRN;
d=true
}if(d==true){if(b.indexOf("?")>-1){b=b+"&"+e
}else{if(e.length>0){b=b+"?"+e
}}}return encodeURI(b)
};
LGI.VirginMedia.ServiceabilityProductOptions.showHeroAvailable=function(a){$(".serviceability-heropod."+a).show();
$(".serviceability-heropod."+a+" .hero-tickmark").show();
$(".serviceability-heropod."+a+" .hero-crossmark").hide();
$(".serviceability-heropod."+a+" .greatnewstext-placeholder .available").show();
$(".serviceability-heropod."+a+" .greatnewstext-placeholder .unavailable").hide();
$(".serviceability-heropod."+a+" .heropod-product-detail-section .unavailable").hide();
$(".additionaldetails-section .button").show()
};
LGI.VirginMedia.ServiceabilityProductOptions.showHeroUnavailable=function(a){$(".serviceability-heropod."+a).show();
$(".serviceability-heropod."+a+" .hero-tickmark").hide();
$(".serviceability-heropod."+a+" .hero-crossmark").show();
$(".serviceability-heropod."+a+" .greatnewstext-placeholder .available").hide();
$(".serviceability-heropod."+a+" .greatnewstext-placeholder .unavailable").show();
$(".serviceability-heropod."+a+" .heropod-product-detail-section .unavailable").show();
$(".additionaldetails-section .button").hide();
$(".serviceability-heropod .greatnewstext-placeholder .bbprelit").hide();
$(".serviceability-heropod .greatnewstext-placeholder .bbnotprelit").hide()
};
LGI.VirginMedia.ServiceabilityProductOptions.receiveServiceabilityResults=function(a,k){LGI.VirginMedia.ServiceabilityProductOptions.fetchAndDisplaySelectedAddressDetails();
if(!k){$(".serviceability-results-section").hide();
$(".contactinfo.lgi-wcmmode").hide();
var d=$(window).width();
if(d<=619){$(".postCodeEntry").addClass("textfieldMobile")
}$(".postCodeEntry").show();
$(".onClickButton").show();
$(".systemError.lgi-wcmmode").show();
$(".callBackButton.lgi-wcmmode").show();
$(".callMessage.lgi-wcmmode").show();
$(".callBackNumber.lgi-wcmmode").show();
var j="",g="",b="",h="",f="system error",e="system error",c="system error";
j=sessionStorage.getItem("primaryCategory");
g=sessionStorage.getItem("term");
b=sessionStorage.getItem("topResult");
h=sessionStorage.getItem("result1");
LGI.VirginMedia.ServiceabilityAnalytics.callServiceabilityResultUdlEvent(j,g,b,h,f,e,c)
}else{$(".display-selected-address").show();
$(".displayselectedaddress.section").show();
$(".serviceabilityresultssection").show();
$(".serviceability-results-section").show();
$(".serviceability-heropod").hide();
$(".systemfailuremsg-section").hide();
$(".additionaldetails-section .button").hide();
if(k.BroadBand.BroadBandspeed==null){$(".serviceability-prodopt.broadband").hide();
$(".serviceability-prodopt.voom").hide()
}if(k.BroadBand.Serviceability=="ON-NET"){if($(".serviceability-heropod.essentialbroadband")[0]){if(k.EB50Status&&k.EB50Status.status==="available"){LGI.VirginMedia.ServiceabilityProductOptions.showHeroAvailable("essentialbroadband");
LGI.VirginMedia.ServiceabilityProductOptions.showBBSpecialMessage(k);
$(".serviceability-heropod.essentialbroadband .button a").attr("href",k.EB50Status.redirectionPath);
LGI.VirginMedia.ServiceabilityProductOptions.setDownloadspeed($(".serviceability-heropod.essentialbroadband .productvariant.speed"),k.EB50Status.productDownloadSpeed);
$(".serviceability-heropod.essentialbroadband .productvariant.speed").show()
}else{LGI.VirginMedia.ServiceabilityProductOptions.showHeroUnavailable("essentialbroadband");
$(".serviceability-heropod.essentialbroadband .productvariant.speed").hide()
}}else{if($(".serviceability-heropod.broadband")[0]){$(".serviceability-heropod.broadband .button a").attr("href",k.OffnetBroadbandStatus.redirectionPath);
if(k.OffnetBroadbandStatus&&k.OffnetBroadbandStatus.status==="available"){LGI.VirginMedia.ServiceabilityProductOptions.setDownloadspeed($(".serviceability-heropod.broadband .productvariant.speed"),k.OffnetBroadbandStatus.productDownloadSpeed);
LGI.VirginMedia.ServiceabilityProductOptions.showHeroAvailable("broadband");
$(".serviceability-heropod.broadband .productvariant.speed").show()
}else{$(".serviceability-heropod.broadband .productvariant.speed").hide();
LGI.VirginMedia.ServiceabilityProductOptions.showHeroUnavailable("broadband")
}}else{if($(".serviceability-heropod.voom")[0]){if(k.VFStatus.status==="available"){LGI.VirginMedia.ServiceabilityProductOptions.showHeroAvailable("voom");
LGI.VirginMedia.ServiceabilityProductOptions.showBBSpecialMessage(k);
$(".serviceability-heropod.voom .button a").attr("href",k.VFStatus.redirectionPath);
LGI.VirginMedia.ServiceabilityProductOptions.setDownloadspeed($(".serviceability-heropod.voom .productvariant.speed"),k.VFStatus.productDownloadSpeed);
$(".serviceability-heropod.voom .productvariant.speed").show()
}else{LGI.VirginMedia.ServiceabilityProductOptions.showHeroUnavailable("voom");
$(".serviceability-heropod.voom .productvariant.speed").hide()
}}}}$(".serviceability-prodopt").hide();
$(".serviceability-prodopt.broadband .tickmark ").show();
$(".serviceability-prodopt.broadband .crossmark ").hide();
$(".producttilesection.broadband").show();
$(".serviceability-prodopt.broadband").show();
$(".serviceability-prodopt.voom .tickmark ").show();
$(".serviceability-prodopt.voom .crossmark ").hide();
$(".producttilesection.voom").show();
$(".serviceability-prodopt.voom").show();
if(k.VFStatus.status==="available"){LGI.VirginMedia.ServiceabilityProductOptions.setDownloadspeed($(".voom .speedsection .productvariant.speed"),k.VFStatus.productDownloadSpeed);
$(".voom .speedsection .productvariant.speed").show()
}else{$(".serviceability-prodopt.voom").show();
$(".voom .speedsection .productvariant.speed").hide();
$(".serviceability-prodopt.voom .tickmark ").hide();
$(".serviceability-prodopt.voom .crossmark ").show();
$(".producttilesection.voom").show()
}if(k.OffnetBroadbandStatus.status==="available"){LGI.VirginMedia.ServiceabilityProductOptions.setDownloadspeed($(".broadband .speedsection .productvariant.speed"),k.OffnetBroadbandStatus.productDownloadSpeed);
$(".voom .speedsection .productvariant.speed").show()
}else{$(".broadband .speedsection .productvariant.speed").hide();
$(".serviceability-prodopt.broadband .tickmark ").hide();
$(".serviceability-prodopt.broadband .tickmark ").show();
$(".producttilesection.broadband").hide();
$(".serviceability-prodopt.broadband").hide()
}}else{if(k.BroadBand.Serviceability=="OFF-NET"||k.BroadBand.Serviceability=="NONSERVICEABLE"||!k.BroadBand.Serviceability){if($(".serviceability-heropod.essentialbroadband")[0]){LGI.VirginMedia.ServiceabilityProductOptions.showHeroUnavailable("essentialbroadband");
$(".serviceability-heropod.essentialbroadband .greatnewstext-placeholder .bbprelit").hide();
$(".serviceability-heropod.essentialbroadband .greatnewstext-placeholder .bbnotprelit").hide();
$(".serviceability-heropod.essentialbroadband .productvariant.speed").hide()
}else{if($(".serviceability-heropod.broadband")[0]){if(k.OffnetBroadbandStatus.status==="available"){LGI.VirginMedia.ServiceabilityProductOptions.showHeroAvailable("broadband");
$(".serviceability-heropod.broadband .additionaldetails-section .button a").attr("href",k.OffnetBroadbandStatus.redirectionPath);
LGI.VirginMedia.ServiceabilityProductOptions.setDownloadspeed($(".serviceability-heropod.broadband .productvariant.speed"),k.OffnetBroadbandStatus.productDownloadSpeed);
$(".serviceability-heropod.broadband .productvariant.speed").show()
}else{LGI.VirginMedia.ServiceabilityProductOptions.showHeroUnavailable("broadband");
$(".serviceability-heropod.broadband .productvariant.speed").hide()
}}else{if($(".serviceability-heropod.voom")[0]){LGI.VirginMedia.ServiceabilityProductOptions.showHeroUnavailable("voom");
$(".serviceability-heropod.voom .productvariant.speed").hide()
}}}if(k.BroadBand.Serviceability=="NONSERVICEABLE"||!k.BroadBand.Serviceability){$(".producttilesection.broadband").hide();
$(".serviceability-prodopt.voom").show();
$(".producttilesection.voom").show();
$(".serviceability-prodopt.voom .crossmark ").show();
$(".serviceability-prodopt.voom .tickmark ").hide();
$(".voom .speedsection .productvariant.speed").hide();
$(".serviceability-prodopt.broadband .tickmark ").hide();
$(".serviceability-prodopt.broadband .crossmark ").hide()
}else{$(".serviceability-prodopt.broadband .tickmark ").show();
$(".producttilesection.broadband").show();
$(".serviceability-prodopt.broadband").show();
$(".serviceability-prodopt.voom .tickmark ").show();
$(".producttilesection.voom").show();
$(".serviceability-prodopt.voom").show();
if(k.VFStatus.status==="available"){LGI.VirginMedia.ServiceabilityProductOptions.setDownloadspeed($(".voom .speedsection .productvariant.speed"),k.VFStatus.productDownloadSpeed);
$(".voom .speedsection .productvariant.speed").show()
}else{$(".voom .speedsection .productvariant.speed").hide();
$(".serviceability-prodopt.voom .tickmark ").hide();
$(".serviceability-prodopt.voom .crossmark ").show();
$(".producttilesection.voom").show()
}if(k.OffnetBroadbandStatus.status==="available"){LGI.VirginMedia.ServiceabilityProductOptions.setDownloadspeed($(".broadband .speedsection .productvariant.speed"),k.OffnetBroadbandStatus.productDownloadSpeed);
$(".broadband .speedsection .productvariant.speed").show()
}else{$(".broadband .speedsection .productvariant.speed").hide();
$(".serviceability-prodopt.broadband .tickmark ").hide();
$(".producttilesection.broadband").hide()
}}}}if(k.MIA.Serviceability=="ON-NET"){if($(".serviceability-heropod.mia")[0]){LGI.VirginMedia.ServiceabilityProductOptions.showHeroAvailable("mia");
$(".serviceability-heropod.mia .productvariant.speed").not(".1gbps").hide();
$(".serviceability-heropod.mia .productvariant.speed.1gbps").show();
$(".serviceability-prodopt.mia").hide();
$(".additionaldetails-section.mia .button a").attr("href",k.MIAStatus.redirectionPath)
}else{$(".serviceability-prodopt.mia").show();
$(".serviceability-prodopt.mia .tickmark").show();
$(".serviceability-prodopt.mia .crossmark").hide();
$(".serviceability-prodopt.mia .productspecialmsg").hide();
$(".serviceability-prodopt.mia .productvariant .speed").show()
}}else{if($(".serviceability-heropod.mia")[0]){LGI.VirginMedia.ServiceabilityProductOptions.showHeroUnavailable("mia");
$(".serviceability-heropod.mia .productvariant.speed").hide();
$(".serviceability-prodopt.mia").hide()
}else{$(".serviceability-prodopt.mia").show();
$(".serviceability-prodopt.mia .tickmark").hide();
$(".serviceability-prodopt.mia .crossmark").show();
$(".serviceability-prodopt.mia .productspecialmsg").hide();
$(".serviceability-prodopt.mia .productvariant .speed").hide()
}}if(k.PhonelineStatus.status!="unavailable"&&(k.Phone.Serviceability=="ON-NET"||k.Phone.Serviceability=="OFF-NET")){if($(".serviceability-heropod.fixedphoneline")[0]){LGI.VirginMedia.ServiceabilityProductOptions.showHeroAvailable("fixedphoneline");
$(".serviceability-heropod.fixedphoneline .productvariant.speed").hide();
$(".serviceability-prodopt.fixedphoneline").hide();
$(".additionaldetails-section.fixedphoneline .button a").attr("href",k.PhonelineStatus.redirectionPath)
}else{$(".serviceability-prodopt.fixedphoneline").show();
$(".serviceability-prodopt.fixedphoneline .tickmark").show();
$(".serviceability-prodopt.fixedphoneline .crossmark").hide()
}}else{if($(".serviceability-heropod.fixedphoneline")[0]){LGI.VirginMedia.ServiceabilityProductOptions.showHeroUnavailable("fixedphoneline");
$(".serviceability-prodopt.fixedphoneline").hide();
$(".serviceability-heropod.fixedphoneline .productvariant.speed").hide()
}else{$(".serviceability-prodopt.fixedphoneline").show();
$(".serviceability-prodopt.fixedphoneline .tickmark").hide();
$(".serviceability-prodopt.fixedphoneline .crossmark").show()
}}$(".serviceability-prodopt.mobilesims").show();
$(".serviceability-prodopt.mobilesims .tickmark").show();
$(".serviceability-prodopt.msoffice365").show();
$(".serviceability-prodopt.msoffice365 .tickmark").show();
$(".serviceability-prodopt.dropbox").show();
$(".serviceability-prodopt.dropbox .tickmark").show();
$(".serviceability-prodopt.mobilesims .crossmark").hide();
$(".serviceability-prodopt.msoffice365 .crossmark").hide();
$(".serviceability-prodopt.dropbox .crossmark").hide();
LGI.VirginMedia.ServiceabilityAnalytics.captureDetailsForAnalytics();
setTimeout(function(){LGI.VirginMedia.ServiceabilityAnalytics.getNonHeroProducts()
},1000)
}var i=$(".heropod-product-detail-section .additionaldetails-section .button a").attr("href");
if(i&&i.indexOf("basketId=")<0&&i.indexOf("uprn=")<0){i=LGI.VirginMedia.ServiceabilityProductOptions.appendQueryParamsToURL(i);
$(".heropod-product-detail-section .additionaldetails-section .button a").attr("href",i)
}$(".sub-mast-header").find("a").each(function(l){var m=$(this).attr("href");
if(m&&m.indexOf("basketId=")<0&&m.indexOf("uprn=")<0){m=LGI.VirginMedia.ServiceabilityProductOptions.appendQueryParamsToURL(m);
$(this).attr("href",m)
}})
};
function checkServiceabilityAddress(t,g){console.log("in checkServiceabilityAddress");
sessionStorage.removeItem("serviceabilitySummary");
sessionStorage.removeItem("serviceabilityCheckStatus");
sessionStorage.removeItem("validateFlag");
var c=$("input.get-AccessServiceability-API").val(),f=null,m=null,n=null,a=null,j=null,d=null,u=null,h=null,i=null,x,e,w,s,v;
var q=new Date(),l=q.toUTCString();
var p=$("input.authheaderforgabp").val();
var r='Atmosphere atmosphere_app_id="'+p+'"';
var k={"Content-Type":"application/json",CountryCode:"UK",Authorization:r,Channel:"ecommerceportal",DepDate:l,Host:"lgi.akana.net","VMMD-requestTimestamp":"2018-05-14T16:50:21.224+01:00","VMMD-requestID":"uuid:f81d4fae-8jan-22e5-a765-00a0c91e7ee7","VMMD-userID":"AEM_VMB2_UK","VMMD-conversationID":"uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6","VMMD-senderURI":"Middleware","VMMD-activityName":"GetAvailableBusinessProducts",CorrelationId:LGI.VirginMedia.APIServices.createUUID()};
if(t.addressIdentification&&t.addressIdentification.UPRN){var b=$("input.catalogueId").val();
var o={UPRN:t.addressIdentification.UPRN,catalogueID:b,orderChannel:"VMBEcommerce"};
$.ajax({method:"GET",url:c,headers:k,data:o,dataType:"json",async:true,success:function(C,A,G){console.log(C);
sessionStorage.setItem("gabpResponse",JSON.stringify(C));
var z=C.GetAvailableBusinessProductsResponse.success;
if(z.availableProductOfferings){for(var D=0;
D<z.availableProductOfferings.length;
D++){var y=z.availableProductOfferings[D];
if(y.productCategoryCode.toUpperCase()==="BEL"){if(y.productOfferings.length!==0){a=y.productOfferings[0].productOfferingNetwork.toUpperCase()
}h=y.maxDownstreamSpeed
}if(y.productCategoryCode.toUpperCase()==="BROADBAND"){if(y.productOfferings.length!==0){j=y.productOfferings[0].productOfferingNetwork.toUpperCase()
}u=y.maxDownstreamSpeed
}if(y.productCategoryCode.toUpperCase()==="MIA"){if(y.productOfferings.length!==0){d=y.productOfferings[0].productOfferingNetwork.toUpperCase()
}i=y.maxDownstreamSpeed
}}if(z.siteDetails&&z.siteDetails.premiseServiceability&&z.siteDetails.premiseServiceability.servicesPreviouslySeen&&z.siteDetails.premiseServiceability.servicesPreviouslySeen.broadbandSeen){f=z.siteDetails.premiseServiceability.servicesPreviouslySeen.broadbandSeen
}if(z.siteDetails&&z.siteDetails.addressIdentification&&z.siteDetails.addressIdentification.siteReference){m=z.siteDetails.addressIdentification.siteReference
}if(z.siteDetails&&z.siteDetails.addressIdentification&&z.siteDetails.addressIdentification.addressIdentifier){n=z.siteDetails.addressIdentification.addressIdentifier
}}var E=LGI.VirginMedia.APIServices.getAllServiceabilityProductsScaffoldData();
for(var D=0;
D<E.serviceabilityproductconfig[0].productgrouplist.length;
D++){var H=JSON.parse(E.serviceabilityproductconfig[0].productgrouplist[D]);
if(H.productgroup==="voomfibre"){x=LGI.VirginMedia.ServiceabilityProductOptions.findMatchedProductDetails(H,z,"BROADBAND")
}if(H.productgroup==="eb50"){e=LGI.VirginMedia.ServiceabilityProductOptions.findMatchedProductDetails(H,z,"BROADBAND")
}if(H.productgroup==="offnetbb"){w=LGI.VirginMedia.ServiceabilityProductOptions.findMatchedProductDetails(H,z,"BROADBAND")
}if(H.productgroup==="phoneline"){s=LGI.VirginMedia.ServiceabilityProductOptions.findMatchedProductDetails(H,z,"BEL")
}if(H.productgroup==="mia"){v=LGI.VirginMedia.ServiceabilityProductOptions.findMatchedProductDetails(H,z,"MIA")
}}var F=$(".heropod-product-detail-section .additionaldetails-section .button a").attr("href");
if(F&&F.indexOf("basketId=")<0&&F.indexOf("uprn=")<0){F=LGI.VirginMedia.ServiceabilityProductOptions.appendQueryParamsToURL(F);
$(".heropod-product-detail-section .additionaldetails-section .button a").attr("href",F)
}$(".sub-mast-header").find("a").each(function(I){var J=$(this).attr("href");
if(J&&J.indexOf("basketId=")<0&&J.indexOf("uprn=")<0){J=LGI.VirginMedia.ServiceabilityProductOptions.appendQueryParamsToURL(J);
$(this).attr("href",J)
}});
var B={BroadBand:{Serviceability:j,BroadBandspeed:u,BroadbandSeenstatus:f},Phone:{Serviceability:a,PhoneSpeed:h},MIA:{Serviceability:d,MiaSpeed:i},siteid:m,addressid:n};
B.VFStatus=x;
B.EB50Status=e;
B.OffnetBroadbandStatus=w;
B.MIAStatus=v;
B.PhonelineStatus=s;
sessionStorage.setItem("serviceabilitySummary",JSON.stringify(B))
},failure:function(z,A,y){if(sessionStorage.getItem("serviceabilitySummary")){sessionStorage.removeItem("serviceabilitySummary")
}console.log("failure "+z);
console.log("in failure");
LGI.VirginMedia.ServiceabilityAnalytics.callServiceabilityResultUdlEventForFailureScenario()
},error:function(z,A,y){console.log("not working");
console.log("error data   "+JSON.stringify(z));
console.log("textStatus   "+JSON.stringify(A));
console.log("jqXHR   "+JSON.stringify(y));
LGI.VirginMedia.ServiceabilityAnalytics.callServiceabilityResultUdlEventForFailureScenario()
},complete:function(){sessionStorage.setItem("gabpCompleted","true");
if(!(sessionStorage.getItem("editPostcode")=="true")){if(sessionStorage.getItem("serviceabilitySummary")){var y=$.parseJSON(sessionStorage.getItem("serviceabilitySummary"));
LGI.VirginMedia.ServiceabilityAnalytics.captureDetailsForAnalytics();
if((y.BroadBand.Serviceability=="nonserviceable")&&(y.MIA.Serviceability=="nonserviceable")&&(y.Phone.Serviceability=="nonserviceable")){LGI.VirginMedia.ServiceabilityAnalytics.callServiceabilityResultUdlEventForOutofArea()
}}else{var E;
if(sessionStorage.getItem("selectedAddress")){E=JSON.parse(sessionStorage.getItem("selectedAddress")).town
}else{E=""
}var D="address",C=E,F="system error",B="system error";
sessionStorage.setItem("primaryCategory",D);
sessionStorage.setItem("term",C);
sessionStorage.setItem("topResult",F);
sessionStorage.setItem("result1",B)
}(g=="repeat")?showResults():"";
var z=sessionStorage.getItem("serviceabilityCheckStatus");
var A=sessionStorage.getItem("validateFlag");
if(g=="nonRepeat"&&z=="false"&&A=="true"){$("#contact-lead-form").submit()
}}}})
}}LGI.VirginMedia.ServiceabilityProductOptions.getSelectedProductDownloadSpeedBySKUid=function(e,c){if(e&&e.length>0){for(var b=0;
b<c.serviceabilityproductconfig[0].productgrouplist.length;
b++){var d=JSON.parse(c.serviceabilityproductconfig[0].productgrouplist[b]);
for(var b=0;
b<d.productdetails.length;
b++){var a=JSON.parse(d.productdetails[b]);
if(a.sku.toUpperCase()===e.toUpperCase()){if(a.proddownloadspeed){return a.proddownloadspeed
}else{return""
}}}}}else{return""
}};
LGI.VirginMedia.ServiceabilityProductOptions.getBroadbandCategorySpeedFromGABPResp=function(b){for(var a=0;
a<b.availableProductOfferings.length;
a++){var c=b.availableProductOfferings[a];
if(c.productCategoryCode.toUpperCase()==="BROADBAND"){return c.maxDownstreamSpeed
}}return""
};
LGI.VirginMedia.ServiceabilityProductOptions.getProductDetailsFromScaffoldingBySkuid=function(f,d){var a={};
if(f&&f.length>0){for(var c=0;
c<d.serviceabilityproductconfig[0].productgrouplist.length;
c++){var e=JSON.parse(d.serviceabilityproductconfig[0].productgrouplist[c]);
for(var c=0;
c<e.productdetails.length;
c++){var b=JSON.parse(e.productdetails[c]);
if(b.sku.toUpperCase()===f.toUpperCase()){a={status:"available",offeringNetwork:gabpProd.productOfferingNetwork,hubPagePath:b.hubpagepath,selectorpagepath:b.selectorpagepath};
return a
}}}}else{return a
}};
LGI.VirginMedia.ServiceabilityProductOptions.findMatchedProductDetails=function(o,s,d){var t,b=false;
if(o.productdetails){if(o.productdetails.length===1){b=true
}}for(var m=0;
m<o.productdetails.length;
m++){var u=JSON.parse(o.productdetails[m]);
for(var h=0;
h<s.availableProductOfferings.length;
h++){var f=s.availableProductOfferings[h];
if(f.productCategoryCode.toUpperCase()===d){var e=false;
if(f.productOfferings.length===1){e=true
}for(var g=0;
g<f.productOfferings.length;
g++){gabpProd=f.productOfferings[g];
if(u.sku===gabpProd.productID){var p="";
var q=LGI.VirginMedia.APIServices.getAllServiceabilityProductsScaffoldData();
var r=sessionStorage.getItem("selectedProdSKUid");
var a=LGI.VirginMedia.ServiceabilityProductOptions.getSelectedProductDownloadSpeedBySKUid(r,q);
if(a&&a.length>0&&o.productgroup==="voomfibre"){var c=LGI.VirginMedia.ServiceabilityProductOptions.getBroadbandCategorySpeedFromGABPResp(s);
var l=LGI.VirginMedia.ServiceabilityProductOptions.getProductDetailsFromScaffoldingBySkuid(r,q);
if(parseInt(c,10)>=500&&parseInt(a,10)>=500){p=l.hubPagePath
}else{if(parseInt(c,10)<500&&parseInt(a,10)>=500){p=l.selectorpagepath
}else{if(parseInt(c,10)>=500&&parseInt(a,10)<=350){p=l.selectorpagepath
}else{if(parseInt(c,10)>=350&&parseInt(a,10)<=350){p=l.hubPagePath
}else{p=l.selectorpagepath
}}}}}else{if(b||e){p=u.hubpagepath
}else{p=u.selectorpagepath
}}var n="";
if(parseInt(f.maxDownstreamSpeed,10)<parseInt(u.proddownloadspeed,10)){n=f.maxDownstreamSpeed
}else{n=u.proddownloadspeed
}t={status:"available",offeringNetwork:gabpProd.productOfferingNetwork,redirectionPath:p,productDownloadSpeed:parseInt(n,10)};
return t
}}}}}if(!t){t={status:"unavailable",offeringNetwork:"",redirectionPath:"",productDownloadSpeed:""}
}return t
};
LGI.VirginMedia.ServiceabilityProductOptions.setDownloadspeed=function(a,b){if(a){a.find("p:first").text(a.parent().find(".productspeedmaster").text().replace("{downloadspeed}",b))
}};
$("body").bind("updateServiceabilityResults",function(a,b){LGI.VirginMedia.ServiceabilityProductOptions.receiveServiceabilityResults(a,b)
});
window.LGI=window.LGI||{};
LGI.VirginMedia=LGI.VirginMedia||{};
LGI.VirginMedia.APIServices=LGI.VirginMedia.APIServices||{};
LGI.VirginMedia.APIServices.createUUID=function(){var b=new Date().getTime(),a="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var d=(b+Math.random()*16)%16|0;
b=Math.floor(b/16);
return(e=="x"?d:(d&3|8)).toString(16)
});
return a
};
LGI.VirginMedia.APIServices.createBasket=function(){var l=$("input.basketAPIBaseDomain").val();
var d=$("input.catalogueId").val();
var k=$("input.authheaderforbasket").val();
var c=l+"/basket";
var b="POST";
var e=false;
var i="";
var h='Atmosphere atmosphere_app_id="'+k+'"';
var j=new Date(),a=j.toUTCString();
var g={Accept:"application/json","content-type":"application/json","cache-control":"no-cache",channel:"ecommerceportal",countrycode:"uk",depdate:a,Authorization:h,CorrelationId:LGI.VirginMedia.APIServices.createUUID()},f={catalogueId:d};
return LGI.VirginMedia.APIServices.makeAjaxCall("Create basket",c,b,true,g,f)
};
LGI.VirginMedia.APIServices.getBasketByBasketId=function(e){var l=$("input.basketAPIBaseDomain").val();
var c=l+"/basket/"+e;
var k=$("input.authheaderforbasket").val();
var b="GET";
var d=false;
var i="";
var h='Atmosphere atmosphere_app_id="'+k+'"';
var j=new Date(),a=j.toUTCString();
var g={"content-type":"application/json","cache-control":"no-cache",Authorization:h,channel:"ecommerceportal",countrycode:"uk",depdate:a,CorrelationId:LGI.VirginMedia.APIServices.createUUID()},f=null;
return LGI.VirginMedia.APIServices.makeAjaxCall("Get basket by basket Id",c,b,false,g,f)
};
LGI.VirginMedia.APIServices.submitNonSensitiveDataToBasket=function(e,l,g){var n=$("input.basketAPIBaseDomain").val();
var c=n+"/basket/{basketId}/data/nonsensitive/{field}";
var m=$("input.authheaderforbasket").val();
c=c.replace("{basketId}",e);
c=c.replace("{field}",l);
var b="PUT";
var d=true;
var j="";
var k=new Date(),a=k.toUTCString();
var i='Atmosphere atmosphere_app_id="'+m+'"';
var h={"Content-Type":"application/json; charset=utf-8",Authorization:i,Channel:"ecommerceportal",CountryCode:"UK",DEPDate:a,CorrelationId:LGI.VirginMedia.APIServices.createUUID()},f=g;
LGI.VirginMedia.APIServices.makeAjaxCall("Submit non sensitive data to the basket",c,b,true,h,f)
};
LGI.VirginMedia.APIServices.submitSensitiveDataToBasket=function(d,h){var i=$("input.basketAPIBaseDomain").val();
var b=i+"/basket/{basketId}/data/sensitive/{field}";
b=b.replace("{basketId}",d);
b=b.replace("{field}",h);
var a="PUT";
var c=true;
var g="";
var f={"Content-Type":"application/json; charset=utf-8",Authorization:'Atmosphere atmosphere_app_id="B2B_OrderFlow_UK"'},e={address:"269 Winterthurway",mobilenumber:"08989898989",emailid:"test@test.com"};
LGI.VirginMedia.APIServices.makeAjaxCall("Submit Sensitive data to the basket",b,a,true,f,e)
};
LGI.VirginMedia.APIServices.makeAjaxCall=function(g,c,f,e,d,b){console.log("--------------Start>>>"+g+"-----------------------------------");
console.log("\nURL:>>"+c);
console.log("\nMethod:>>"+f);
console.log("\nRequest:>>"+JSON.stringify(b));
var a={};
$.ajax({method:f,url:c,headers:d,data:JSON.stringify(b),dataType:"json",async:e,success:function(k,l,j){if(j.hasOwnProperty("statusText")&&j.status==200){if(g=="Create basket"){var i=k.basketId;
sessionStorage.setItem("basketId",i)
}if(g=="Put offer into a basket"){sessionStorage.setItem("putOffer",JSON.stringify(k))
}if(g=="Get offer by catalogue item id"){sessionStorage.setItem("getOffer",JSON.stringify(k))
}}else{}var h=[];
a.status=l;
a.data=k;
h.push(a);
return a
},error:function(i,j){var h=[];
a.status=j;
a.data="";
h.push(a);
console.log("response ::::::: "+JSON.stringify(a));
return a;
console.log("\nError occured>>"+i.status)
}});
console.log(a);
return a;
console.log("--------------End>>>"+g+"-------------------------------------")
};
LGI.VirginMedia.getRequiredPageProperties=function(c,d){if(c){var a=c.products,b;
$.each(a,function(f,e){if(e["jcr:sku"]==d){b=e;
return false
}});
return b
}};
LGI.VirginMedia.APIServices.getPageProperties=function(b){console.log("PATH --------"+b);
var a="";
jQuery.ajax({beforeSend:function(c){c.setRequestHeader("Content-Type","application/json");
c.setRequestHeader("Accept","application/json")
},url:"/bin/data/productpageproperties/",type:"GET",dataType:"json",async:false,success:function(c){if(b){a=JSON.stringify(LGI.VirginMedia.getRequiredPageProperties(c,b))
}else{a=c
}return a
}});
return a
};
LGI.VirginMedia.APIServices.getAllProductsScaffoldData=function(){var a="";
jQuery.ajax({beforeSend:function(b){b.setRequestHeader("Content-Type","application/json");
b.setRequestHeader("Accept","application/json")
},url:"/bin/data/productpageproperties/",type:"GET",dataType:"json",async:false,success:function(b){a=b;
return a
}});
return a
};
LGI.VirginMedia.APIServices.getAllServiceabilityProductsScaffoldData=function(){var a=sessionStorage.getItem("serviceabilityProdScaffoldData");
var b=null;
if(a){b=JSON.parse(a)
}else{jQuery.ajax({beforeSend:function(c){c.setRequestHeader("Content-Type","application/json");
c.setRequestHeader("Accept","application/json")
},url:"/bin/data/serviceabilityconfig/",type:"GET",dataType:"json",async:true,success:function(c){b=c;
sessionStorage.setItem("serviceabilityProdScaffoldData",JSON.stringify(c))
}})
}return b
};
LGI.VirginMedia.APIServices.responseDataFormat=function(b,c,a){};
$(document).ready(function(){});