var CoreMetrics=new function(){this.name="CoreMetrics";this.CustomAttributesColl=null;this.IsAvailable=false;this.SpanishCulture="es.";this.SpanishPrefix="ES:";this.spanishLangAttr="ES";this.LangLoc_ShopActionTag=6;this.LangLoc_ProductView=4;this.LangLoc_PageView=10;this.LangLoc_Conversion=1;this.LangLoc_Element=2;var a=["<!-- mp_trans -->","<!-- mp_trans_disable_start -->","<!-- mp_trans_disable_end -->"];this.Constants={Initiation:1,Completion:2,AttributesDelimiter:"-_-",Delimiter:"|",Currency:"USD",PopUp:"POPUP",ManualLinkClickTag:"manual_cm_sp",WWWHome:"WWW:HOME",WWWPhones:"WWW:PHONES",WWWPhonesMBB:"WWW:PHONES:MOBILE BROADBAND",WWWShopPhones:"WWW:SHOP:PHONES",WWWShopPlans:"WWW:SHOP:PLANS",WWWShopAddOnsServices:"WWW:SHOP:ADDONS:SERVICES",WWWShopAddOnsAccessories:"WWW:SHOP:ADDONS:ACCESSORIES",WWWShopAddOns:"WWW:SHOP:ADDONS",WWWShopCartVersion:"WWW:SHOP:CART VERSION",WWWChooseServices_:"WWW:CHOOSE SERVICES:",WWWChooseAccessories_:"WWW:CHOOSE ACCESSORIES:",WWWDataCalculator:"WWW:DATACALCULATOR",ProductPhoneTabsFooter_:"PRODUCT:PHONE:TABS:FOOTER:",ProductPhoneTabsHeader_:"PRODUCT:PHONE:TABS:HEADER:",ProductModalCart:"PRODUCT:MODAL CART"};this.AddPageViewTag=function(b,f,d,e,c){if(this.IsAvailable){if(b==""){b=cG7.cM0[cm_ClientID]}b=this.CheckSpanishCulture(b);f=this.CheckSpanishCulture(f);c=this.SetSpanishLangAttr(c,this.LangLoc_PageView);cmCreatePageviewTag(b,f,d,e,c)}};this.AddProductViewTag=function(c,e,d,b,f){if(this.IsAvailable){c=this.StripMPTransComments(c);e=this.StripMPTransComments(e);d=this.CheckSpanishCulture(d);b=this.SetSpanishLangAttr(b,this.LangLoc_ProductView);cmCreateProductviewTag(c,e,d,b,f)}};this.AddProductViewTag=function(e,g,f,d,h,c,b){if(this.IsAvailable){e=this.StripMPTransComments(e);g=this.StripMPTransComments(g);f=this.CheckSpanishCulture(f);d=this.SetSpanishLangAttr(d,this.LangLoc_ProductView);cmCreateProductviewTagForPhoneDetail(e,g,f,d,h,c,b)}};this.AddShopAction5Tag=function(c,e,g,f,d,b){if(this.IsAvailable){if(f!=null&&parseFloat(f).toFixed){f=parseFloat(f).toFixed(2).toString()}c=this.StripMPTransComments(c);e=this.StripMPTransComments(e);d=this.CheckSpanishCulture(d);b=this.SetSpanishLangAttr(b,this.LangLoc_ShopActionTag);cmCreateShopAction5Tag(c,e,g,f,d,b)}};this.DisplayShopAction5Tag=function(){if(this.IsAvailable){cmDisplayShop5s()}};this.AddShopAction9Tag=function(h,i,j,f,b,e,g,d,c){if(this.IsAvailable){if(f!=null&&parseFloat(f).toFixed){f=parseFloat(f).toFixed(2).toString()}if(g!=null&&parseFloat(g).toFixed){g=parseFloat(g).toFixed(2).toString()}h=this.StripMPTransComments(h);i=this.StripMPTransComments(i);cmCreateShopAction9Tag(h,i,j,f,b,e,g,d,"",this.Constants.Currency,"","","",null,"")}};this.DisplayShopAction9Tag=function(){if(this.IsAvailable){cmDisplayShop9s()}};this.AddOrderTag=function(h,l,c,b,j,i,g,d,k,f,e){if(this.IsAvailable){if(l!=null&&parseFloat(l).toFixed){l=parseFloat(l).toFixed(2).toString()}cmCreateOrderTag(h,l,c,b,j,i,g,"",this.Constants.Currency,d,k,f,e)}};this.AddRegistrationTag=function(g,h,f,e,d,c,b){if(this.IsAvailable){cmCreateRegistrationTag(g,h,f,e,d,c,b)}};this.AddConversionEventTag=function(e,d,b,f,c){if(this.IsAvailable){cmCreateConversionEventTag(e,d,b,f,c)}};this.ElementTagCall=function(c,b){if(location.href.toLowerCase().indexOf("/services/")>0){this.AddElementTag(this.Constants.WWWChooseServices_+c,this.Constants.WWWShopAddOns,b)}else{this.AddElementTag(this.Constants.WWWChooseAccessories_+c,this.Constants.WWWShopAddOns,b)}};this.AddElementTag=function(c,b,d){if(this.IsAvailable){c=this.CheckSpanishCulture(c);b=this.CheckSpanishCulture(b);d=this.SetSpanishLangAttr(d,this.LangLoc_Element);cmCreateElementTag(c,b,d)}};this.ManualLinkTag=function(b){if(this.IsAvailable){cmCreateManualLinkClickTag(b,cG7.cM0[cm_ClientID])}};this.ManualLinkTag=function(b,c){if(this.IsAvailable){cmCreateManualLinkClickTag(b,c,cG7.cM0[cm_ClientID])}};this.ManualImpressionBannerCall=function(h){if(!this.IsAvailable){return}try{var c="";var f="";var b="";var g="";var j="";var d="";if($("#hdnPageName").val()=="homepage"){d=$("#main-offers").children(".slide")[h]}else{d=$(".cmetrics")[h]}b=CoreMetrics.GetPromoName(d);c=($("#hdnIsCookied").val()=="true")?"cookied":"def";f="MQ_A"+(h+1)+"_"+c;b=(b!="")?b:("Marquee_A_"+c);var i=this.Constants.ManualLinkClickTag;$(d).find("a").each(function(k){var l=$(this)[0].children[0].innerHTML;if(l!=null){l=l.replace(/ /g,"_");if(k>0){l=CoreMetrics.Constants.Delimiter+l}j+=l}});g=f+CoreMetrics.Constants.AttributesDelimiter+b+CoreMetrics.Constants.AttributesDelimiter+j;this.ManualImpressionTag(g)}catch(e){}};this.ManualImpressionTag=function(b){if(this.IsAvailable){cmCreateManualImpressionTag(cG7.cM0[cm_ClientID],b)}};this.AttributeDelimiterstring=function(c){var d="";for(var b=0;b<c;++b){d+=this.Constants.AttributesDelimiter}return d};this.AddCustomAttributes=function(){if(!this.IsAvailable||this.CustomAttributesColl==null){return}try{$("a").each(function(){var c=$(this)[0].id;$(CoreMetrics.CustomAttributesColl).each(function(){var d=$(this)[0].Key;if(c==d){$("#"+c).attr($(this)[0].AttributeName,$(this)[0].AttributeValue)}})})}catch(b){}};this.LinkImpressionTag=function(f){try{var b=$("#contentlist").children("li")[f];f=parseInt(f);var d="";var i="";var c="";var g="";g=($("#hdnIsCookied").val()=="true")?"cookied":"def";i=CoreMetrics.GetPromoName(b);d="MQ_A"+(f+1)+"_"+g;i=(i!="")?i:("Marquee_A_"+g);$(b).find("a").each(function(){var e=$(this)[0].innerText;if(e==undefined){e=$(this)[0].text}if(e){e=e.replace(/ /g,"_")}c=d+CoreMetrics.Constants.AttributesDelimiter+i+CoreMetrics.Constants.AttributesDelimiter+e;CoreMetrics.ManualImpressionTag(c)})}catch(h){}};this.AddPromotions=function(c,b){if(!this.IsAvailable){return}if(c=="homepage"){this.HomePagePromoTracking(b)}else{if(c=="shoppage"){this.ShopPagePromoTracking(b)}else{if(c=="deals"){this.DealsPagePromoTracking(b)}}}};this.HomePagePromoTracking=function(d){try{var c="";var g="";var b="";$("#contentlist").children("li").each(function(e){g=CoreMetrics.GetPromoName(this);c="MQ_A"+(e+1)+"_"+d;g=(g!="")?g:("Marquee_A_"+d);var h=CoreMetrics.Constants.ManualLinkClickTag;CoreMetrics.AddAttributes(this,c,g);if(e==0){$(this).find("a").each(function(){var i=$(this)[0].innerText;if(i==undefined){i=$(this)[0].text}if(i){i=i.replace(/ /g,"_")}b=c+CoreMetrics.Constants.AttributesDelimiter+g+CoreMetrics.Constants.AttributesDelimiter+i;CoreMetrics.ManualImpressionTag(b)})}});$("#side-offers").children("div").each(function(e){g=CoreMetrics.GetPromoName(this);c="MQ_C_"+d;g=(g!="")?g:("Marquee_C_"+d);var h=CoreMetrics.Constants.ManualLinkClickTag;CoreMetrics.AddAttributes(this,c,g)});$("#offer-tiles").children("li").each(function(e){g=CoreMetrics.GetPromoName(this);switch(e){case 0:c="TileA_"+d;break;case 1:c="TileB_"+d;break;case 2:c="TileC_"+d;break;default:c="Tile_"+d}g=(g!="")?g:("Tile_"+d);var h=CoreMetrics.Constants.ManualLinkClickTag;CoreMetrics.AddAttributes(this,c,g)})}catch(f){}};this.ShopPagePromoTracking=function(f){try{var c="";var h="";var b="";$("#contentlist").children("li").each(function(e){h=CoreMetrics.GetPromoName(this);c="MQ_A"+(e+1)+"_"+f;h=(h!="")?h:("Marquee_A_"+f);var i=CoreMetrics.Constants.ManualLinkClickTag;CoreMetrics.AddAttributes(this,c,h);if(e==0){$(this).find("a").each(function(){var j=$(this)[0].innerText;if(j==undefined){j=$(this)[0].text}if(j){j=j.replace(/ /g,"_")}b=c+CoreMetrics.Constants.AttributesDelimiter+h+CoreMetrics.Constants.AttributesDelimiter+j;CoreMetrics.ManualImpressionTag(b)})}});if(f=="cookied"){var d=$("#btnMyTMOLogin")[0].attributes.manual_cm_sp.value;if(d!=null){CoreMetrics.ManualImpressionTag(d)}}if(f=="cookied"){var d=$("#lnkSeeWhatNew")[0].attributes.manual_cm_sp.value;if(d!=null){CoreMetrics.ManualImpressionTag(d)}}$(".DealsPhonesProduct").children("ul").each(function(e){var j=$(".DealsPhonesProduct").children("ul").length;h=CoreMetrics.GetPromoName(this);if(h!=""){h=h.replace(/\s/g,"")}if(j>2){switch(e){case 0:c="PROD1_"+f;break;case 1:c="PROD2_"+f;break;case 2:c="PROD3_"+f;break;case 3:c="PROD4_"+f;break;default:c="PROD_"+f}}else{switch(e){case 0:c="PROD3_"+f;break;case 1:c="PROD4_"+f;break;default:c="PROD_"+f}}h=(h!="")?h:("PROD_"+f);var i=CoreMetrics.Constants.ManualLinkClickTag;CoreMetrics.AddAttributes(this,c,h);if(e==0){CoreMetrics.AddAttributesToButton(this,c,h)}$(this).find("a").each(function(){var k=$(this)[0].innerText;if(k==undefined){k=$(this)[0].text}if(k){k=k.replace(/ /g,"_")}b=c+CoreMetrics.Constants.AttributesDelimiter+h+CoreMetrics.Constants.AttributesDelimiter+k;CoreMetrics.ManualImpressionTag(b)})});$("#trPlanAdTile").children("td").each(function(e){h=CoreMetrics.GetPromoName(this);switch(e){case 0:c="TILEA_"+f;break;case 1:c="TILEB_"+f;break;default:c="TILE_"+f}h=(h!="")?h:("TILE_"+f);var i=CoreMetrics.Constants.ManualLinkClickTag;CoreMetrics.AddAttributes(this,c,h);if(e==0){CoreMetrics.AddAttributesToButton(this,c,h)}$(this).find("a").each(function(){var j=$(this)[0].innerText;if(j==undefined){j=$(this)[0].text}if(j){j=j.replace(/ /g,"_")}b=c+CoreMetrics.Constants.AttributesDelimiter+h+CoreMetrics.Constants.AttributesDelimiter+j;CoreMetrics.ManualImpressionTag(b)})})}catch(g){}};this.DealsPagePromoTracking=function(d){var c="";var e="";var b="";$(".cmetrics").each(function(f){e=CoreMetrics.GetPromoName(this);c="MQ_A"+(f+1)+"_"+d;e=(e!="")?e:("Marquee_A_"+d);var g=CoreMetrics.Constants.ManualLinkClickTag;CoreMetrics.AddAttributes(this,c,e)});$(".cppo-boxes ul").children("li").each(function(f){e=CoreMetrics.GetPromoName(this);switch(f){case 0:c="TileA_"+d;break;case 1:c="TileB_"+d;break;case 2:c="TileC_"+d;break;default:c="Tile_"+d}e=(e!="")?e:("Tile_"+d);var g=CoreMetrics.Constants.ManualLinkClickTag;CoreMetrics.AddAttributes(this,c,e)})};this.AddAttributes=function(f,c,e){var b="";var d=CoreMetrics.Constants.ManualLinkClickTag;$(f).find("a").each(function(){var g=$(this)[0].innerText;if(g==undefined){g=$(this)[0].text}if(g){g=g.replace(/ /g,"_")}b=c+CoreMetrics.Constants.AttributesDelimiter+e+CoreMetrics.Constants.AttributesDelimiter+g;if($(this).attr(d)==null&&g!=""){$(this).attr(d,b)}})};this.AddAttributesToButton=function(f,c,e){var b="";var d=CoreMetrics.Constants.ManualLinkClickTag;$(f).find("button").each(function(){var g=$(this)[0].innerText;if(g==undefined){g=$(this)[0].text}if(g){g=g.replace(/ /g,"_")}b=c+CoreMetrics.Constants.AttributesDelimiter+e+CoreMetrics.Constants.AttributesDelimiter+g;if($(this).attr(d)==null){$(this).attr(d,b)}})};this.GetPromoName=function(c){var b="";if(c.attributes!=null&&c.attributes.promoname!=null){b=c.attributes.promoname.value}else{$(c).find("div").each(function(){var d=this;if(d.attributes!=null&&d.attributes.promoname!=null){b=d.attributes.promoname.value;return false}})}if(b==""){if(c.title!=null&&c.title!=""){b=c.title;b=b.replace(/ /g,"_")}else{$(c).find("div").each(function(){var d=this;if(d.title!=null&&d.title!=""){b=d.title;b=b.replace(/ /g,"_");return false}})}}return b};this.StripMPTransComments=function(c){for(var b in a){var d=a[b];if(c.indexOf(d)>-1){c=c.replace(new RegExp(d,"g"),"")}}return c};this.CheckSpanishCulture=function(c){var b=document.location.hostname;if(b.toLowerCase().indexOf(CoreMetrics.SpanishCulture)!=-1){c=CoreMetrics.SpanishPrefix+c}return c};this.SetSpanishLangAttr=function(e,c){var b=e;c=(c>0)?c-1:c;var g=document.location.hostname;if(g.toLowerCase().indexOf(CoreMetrics.SpanishCulture)!=-1){if(e!=null&&e!=""){var f=e.split(CoreMetrics.Constants.AttributesDelimiter);if(c>f.length){for(d=f.length;d<c;d++){f[d]=""}}f[c]=CoreMetrics.spanishLangAttr;for(var d=0;d<f.length;d++){if(d==0){b=f[d]}else{b=b+CoreMetrics.Constants.AttributesDelimiter+f[d]}}}else{for(var d=0;d<c;d++){if(d==0){b=""}else{b=b+CoreMetrics.Constants.AttributesDelimiter+""}}b=b+CoreMetrics.Constants.AttributesDelimiter+CoreMetrics.spanishLangAttr}}return b}};
