var Checkboxid="";var Checked="false";var checkedId="";function getServiceForButtonID(a){for(i=allRelations.length-1;i>=0;i--){if(allRelations[i].ID==a){return allRelations[i].ServiceName}}}function getServiceIdForButtonID(a){for(i=allRelations.length-1;i>=0;i--){if(allRelations[i].ID==a){return allRelations[i].ServiceID}}}function getServiceNameForButtonID(a){for(i=allRelations.length-1;i>=0;i--){if(allRelations[i].ServiceID==a){return allRelations[i].ServiceName}}}function getConflictsForButton(a){for(i=conflicts.length-1;i>=0;i--){if(conflicts[i].ID==a){return conflicts[i].Conflicts}}}function getBANConflictsForButton(a){for(i=conflictsBAN.length-1;i>=0;i--){if(conflictsBAN[i].ID==a){return conflictsBAN[i].Conflicts}}}function getCheckBoxForServiceId(a){for(idxRelation=allRelations.length-1;idxRelation>=0;idxRelation--){if(allRelations[idxRelation].ServiceID==a){return(allRelations[idxRelation].ID)}}return("")}function getButtonIdsForServiceId(b){var a=[];for(idxRelation=allRelations.length-1;idxRelation>=0;idxRelation--){if(allRelations[idxRelation].ServiceID==b){a.push(allRelations[idxRelation].ID)}}return a}function AlreadyInCart(a){if(typeof(servicesAddedForCurrentDevice)!="undefined"){serviceId=getServiceIdForButtonID(a);for(i=0;i<servicesAddedForCurrentDevice.length;i++){if(servicesAddedForCurrentDevice[i].ID==serviceId){return true}}}return false}function checkChangedTZone(b){if(b.checked==false){Checked="false";checkedId="";return}if(Checked!="false"){b.checked=false;var c=getServiceForCheckBox(b.id);var e=getServiceForCheckBox(checkedId);var d="You've chosen to add <b>"+c+"</b> to the current line on your account. This service conflicts with  <b>"+e+"</b> .<br><br> If you would like to add <b>"+c+"</b> and remove <b>"+e+"</b>, please click Continue.";document.getElementById("divServiceMsg").innerHTML=d;document.getElementById("hdnServiceID").value=getServiceIDForConflictService(b.id);var a=document.getElementById("divServiceMsg").innerHTML.length;if(navigator.userAgent.indexOf("MSIE")==-1){a=(a-180)/70*10+170}else{a=(a-180)/70*10+180}openModalDiv("modalDivServiceConflict","500","auto",function(){});return}if(Checked="false"){Checked="true";checkedId=b.id}}function buttonClicked(h,c){buttonId=getCheckBoxForServiceId(h);elem=document.getElementById("divMessages");var e=getConflictsForButton(buttonId);var a=getBANConflictsForButton(buttonId);var j=0;var g=false;if(null!=e){for(idxConflict=0;idxConflict<e.length;idxConflict++){g=false;var b=getButtonIdsForServiceId(e[idxConflict]);var d=0;for(d=0;d<b.length;d++){if(AlreadyInCart(b[d])){var k=getServiceIdForButtonID(b[d]);if(!(IsServciesBelongsToSameGroup(k,h)&&IsServciesMandatory(k,h))){j+=1}var f=b[d];g=true;break}}if(g==true){break}}}if(a!=""){j+=2}switch(j){case 0:if(c==0){__doPostBack("btnAddToCartTop","")}else{__doPostBack("btnMandatoryAddRemove","")}break;case 1:document.getElementById("hdnConflictReason").value=1;showIncompatibleMessage(buttonId,f,null);break;case 2:document.getElementById("hdnConflictReason").value=2;showIncompatibleMessage(buttonId,null,a);break;case 3:document.getElementById("hdnConflictReason").value=3;showIncompatibleMessage(buttonId,f,a);break}}function showIncompatibleMessageTZone(e,a){var b=getServiceForCheckBox(e);var d=getServiceForCheckBox(a);var c="You have chosen to add '"+b+"'. This service conflicts with  '"+d+"' . If you would like to add '"+b+"' you must uncheck '"+d+"'.";alert(c)}function showIncompatibleMessage(r,y,a){var z=document.getElementById("divNewBLSSvc").innerHTML;var b=document.getElementById("divNewNonBLSSvc").innerHTML;var f=document.getElementById("divConflictOther").innerHTML;var A=document.getElementById("divConflictCurrOther").innerHTML;var h=document.getElementById("divConflictCurr").innerHTML;var t=document.getElementById("divMsgAlertRemoveCustomPkgService").innerHTML;document.getElementById("divNewBLSSvc").style.display="none";document.getElementById("divNewNonBLSSvc").style.display="none";document.getElementById("divConflictOther").style.display="none";document.getElementById("divConflictCurrOther").style.display="none";document.getElementById("divConflictCurr").style.display="none";document.getElementById("divMsgAlertRemoveCustomPkgService").style.display="none";document.getElementById("hdnSenderID").value=r;var q=getServiceForButtonID(r);if(y!=null){document.getElementById("hdnCheckedID").value=y;var c=getServiceForButtonID(y)}var e="";var g=null;var s=null;if(a!=null){for(idxConflict=0;idxConflict<a.length;idxConflict++){g=a[idxConflict].split("&");if(g!=null){s=g[3].split("=");if(s!=null){if(e.length==0){e+=s[1]+", ";s=null}else{if(e.indexOf(s[1])==-1){e+=s[1]+", ";s=null}}}}g=null}e=e.substring(0,e.length-2)}var d=document.getElementById("divMsg");var m=false;for(idx=0;idx<BLS.length;idx++){if(BLS[idx].ID==r){m=(BLS[idx].IsBLS);break}}var p=0;var n=0;if(m=="True"){var j=document.getElementById("divMsgNewBLSSvc");j.innerHTML=z.replace(/{NewService}/g,q);j.style.display="block";if(j.innerHTML.length>=120){n+=15}document.getElementById("divMsgNewNonBLSSvc").style.display="none"}else{var w=document.getElementById("divMsgNewNonBLSSvc");w.innerHTML=b.replace(/{NewService}/g,q);w.style.display="block";if(w.innerHTML.length>=120){n+=15}document.getElementById("divMsgNewBLSSvc").style.display="none"}if(y!=null){document.getElementById("divMsgConflictOther").style.display="none";if(a==null){var o=document.getElementById("divMsgConflictCurr");o.innerHTML=h.replace(/{ConflictServiceCurr}/g,c);o.innerHTML=o.innerHTML.replace(/{NewService}/g,q);o.style.display="block";p+=o.innerHTML.length;document.getElementById("divMsgConflictCurrOther").style.display="none"}else{var v=document.getElementById("divMsgConflictCurrOther");v.innerHTML=A.replace(/{ConflictServiceCurr}/g,c);v.innerHTML=v.innerHTML.replace(/{ConflictServiceOther}/g,e);v.innerHTML=v.innerHTML.replace(/{NewService}/g,q);v.style.display="block";p+=v.innerHTML.length;document.getElementById("divMsgConflictCurr").style.display="none"}}else{var u=document.getElementById("divMsgConflictOther");u.innerHTML=f.replace(/{ConflictServiceOther}/g,e);u.innerHTML=u.innerHTML.replace(/{NewService}/g,q);u.style.display="block";p+=u.innerHTML.length;document.getElementById("divMsgConflictCurr").style.display="none";document.getElementById("divMsgConflictCurrOther").style.display="none"}var l=getServiceIdForButtonID(y);var x=IsServiceCustomPackageItem(l);if(x=="True"){var k=getServiceNameForServiceID(l);document.getElementById("divMsgAlertRemoveCustomPkgService").innerHTML=t.replace(/{CustomPkgService}/g,k);document.getElementById("divMsgAlertRemoveCustomPkgService").style.display="block";p+=document.getElementById("divMsgAlertRemoveCustomPkgService").innerHTML.length;n+=20}else{document.getElementById("divMsgAlertRemoveCustomPkgService").style.display="none";n=n-15}if(navigator.userAgent.indexOf("MSIE")==-1){p=(p-180)/70*10+170+n}else{p=(p-180)/70*10+180+n}openModalDiv("modalDivServiceConflict","500","auto",function(){})}function toggleCheckboxes(){var b=document.getElementById(document.getElementById("hdnCheckedID").value);if(!(b==null||b=="")){var a=document.getElementById(document.getElementById("hdnSenderID").value);a.checked=true;b.checked=false}}function displayModalDialog(d,a,c){var b="dialogHeight: 200px; dialogWidth: 300px; edge: Raised; center: Yes; help: No; resizable: No; status: No";var e=false;if(navigator.appName.indexOf("MSIE")!=-1){b="dialogHeight: 200; dialogWidth: 400; edge: raised; center: yes; help: no; resizable: no; status: no";alert(window.showModalDialog(d,e,b))}else{b="width=400,height=150,status=no,chrome=yes,modal=yes,centerscreen=yes";obj=window.open(d,e,b);obj.focus()}a.checked==e;c.checked==!e}function showIncompatibleMessageForName(c,b){var a="'"+b+"' is not compatible with  '"+c+"' ; please choose '"+b+"' or '"+c+"' and click its '' add to cart '' button to continue.";alert(a)}function errorClicked(){elem=document.getElementById("divMessages");elem.style.display="none";var a=document.getElementById(Checkboxid);a.checked=true;window.onscroll=null;closeModalPopup()}function removeClicked(){window.onscroll=null;closeModalPopup();elem=document.getElementById("divMessages");elem.style.display="none"}function removeClicked(a){if(typeof(servicesAddedForCurrentDevice)!="undefined"){for(i=0;i<servicesAddedForCurrentDevice.length;i++){if(servicesAddedForCurrentDevice[i].ServiceID==a){servicesAddedForCurrentDevice.splice(i,1);i=i-1}}}}function getGroupIDForServiceID(a){for(i=0;i<allRelations.length;i++){if(allRelations[i].ID==a){return allRelations[i].ServiceGroupID}}}function IsMandatroy(a){for(i=0;i<Mandatory.length;i++){if(Mandatory[i].ID==a&&Mandatory[i].IsMandatory=="True"){return true}}return false}function IsServciesBelongsToSameGroup(d,c){var a=getGroupIDForServiceID(d);var b=getGroupIDForServiceID(c);if(b==a){return true}else{return false}}function IsServciesMandatory(d,b){var c=IsMandatroy(d);var a=IsMandatroy(b);if(a==true&&c==true){return true}else{return false}}function getServiceForCheckBox(a){for(i=allRelations.length-1;i>=0;i--){if(allRelations[i].ID==a){return allRelations[i].ServiceName}}}function IsServiceCustomPackageItem(a){for(i=0;i<allRelations.length;i++){if(allRelations[i].ServiceID==a){return allRelations[i].IsCustomPkgItem}}}function getServiceNameForServiceID(a){for(i=0;i<allRelations.length;i++){if(allRelations[i].ServiceID==a){return allRelations[i].ServiceName}}}function showPackageItemRemoveMessage(d){var c=document.getElementById("divMsgRemoveCustomPkgService").innerHTML;document.getElementById("divMsgRemoveCustomPkgService").style.display="none";var b=getServiceNameForServiceID(d);document.getElementById("divMsgRemoveCustomPkgService").innerHTML=c.replace(/{CustomPkgService}/g,b);document.getElementById("divMsgRemoveCustomPkgService").style.display="block";a+=document.getElementById("divMsgRemoveCustomPkgService").innerHTML.length;var a=0;if(navigator.userAgent.indexOf("MSIE")==-1){a=(a-180)/70*10+170}else{a=(a-180)/70*10+180}openModalDiv("modalDivRemovePkgService","500","auto",function(){})}function getServiceIDForConflictService(a){for(i=allRelations.length-1;i>=0;i--){if(allRelations[i].ID==a){return allRelations[i].ServiceID}}}function IsServicesIncompatible(b){var c=getServiceNameForButtonID(b);if(checkedId!=""&&typeof(c)!="undefined"){var e=getServiceForCheckBox(checkedId);var d="You've chosen to add <b>"+c+"</b> to the current line on your account. This service conflicts with  <b>"+e+"</b> .<br><br> If you would like to add <b>"+c+"</b> and remove <b>"+e+"</b>, please click Continue.";document.getElementById("divServiceMsg").innerHTML=d;document.getElementById("hdnServiceID").value=b;var a=document.getElementById("divServiceMsg").innerHTML.length;if(navigator.userAgent.indexOf("MSIE")==-1){a=(a-180)/70*10+170}else{a=(a-180)/70*10+180}openModalDiv("modalDivServiceConflict","500","auto",function(){});return false}};
