if(polopoly){throw ("Initialized twice")}var polopoly={};polopoly.service={};polopoly.user={init:function(){this.data=this._initCookie("cata");this.sessionData=this._initCookie("data")},_initCookie:function(c){var a=polopoly.cookie.get(c);if(!a){return}var d=polopoly.base64.stringDecode(a);if(!d){return}try{var b=polopoly.json.parse(d)}catch(f){return}return b},getServiceSettings:function(b,a){if(!this.data||!this.data[b]){return}return this.data[b][a]},setServiceSettings:function(c,a,b){if(!this.data){this.data={}}if(!this.data[c]){this.data[c]={}}this.data[c][a]=b;this._persistDataInCookie()},getSessionServiceSettings:function(b,a){if(!this.sessionData||!this.sessionData[b]){return}return this.sessionData[b][a]},setSessionServiceSettings:function(c,a,b){if(!this.sessionData){this.sessionData={}}if(!this.sessionData[c]){this.sessionData[c]={}}this.sessionData[c][a]=b;this._persistSessionDataInCookie()},_persistDataInCookie:function(){var a=polopoly.json.stringify(this.data);var b=polopoly.base64.stringEncode(a);polopoly.cookie.set("cata",b)},_persistSessionDataInCookie:function(){var a=polopoly.json.stringify(this.sessionData);var b=polopoly.base64.stringEncode(a);polopoly.cookie.setForSession("data",b)},isLoggedIn:function(){return polopoly.cookie.get("sessionKey")!=null&&polopoly.cookie.get("loginName")!=null&&polopoly.cookie.get("userId")!=null},isOnPlant:function(){return polopoly.cookie.get("OP")!=null},isOptimumUser:function(){return polopoly.cookie.get("ValidatedOptimumUserID")!=null},isNewsdaySubscriber:function(){var a=polopoly.base64.stringDecode(polopoly.cookie.get("NDAL"));return(a!=null&&((a=="Premium1")||(a=="Both")))},isSubscriber:function(){var a=polopoly.base64.stringDecode(polopoly.cookie.get("NDAL"));return(polopoly.user.isOptimumUser()||polopoly.user.isNewsdaySubscriber()||(a=="CompAccount"))},isSubscriberAll:function(){return(polopoly.user.isOptimumUser()&&polopoly.user.isNewsdaySubscriber())},isMigratedUser:function(){return polopoly.cookie.get("MigratedUser")},name:function(){return polopoly.base64.stringDecode(polopoly.cookie.get("loginName"))},displayName:function(){return polopoly.base64.stringDecode(polopoly.cookie.get("displayName"))},popMessageCookie:function(a){var f=polopoly.cookie.get(a);var b=polopoly.base64.stringDecode(f);if(b.length){var c;try{c=polopoly.json.parse(b)}catch(d){}return c}},refreshUserData:function(b,a){jQuery.ajax({cache:false,error:b,success:a,timeout:3000,type:"GET",url:"/membership/refresh"})}};polopoly.cookie={clear:function(a){document.cookie=a+"= ; expires=01 Jan 1970 00:00:00 UTC; path=/"},set:function(a,b){document.cookie=a+"="+b+"; expires=01 Jan 2038 00:00:00 UTC; path=/"},setForSession:function(a,b){document.cookie=a+"="+b+"; expires=-1; path=/"},get:function(a){return polopoly.util.stringAsHashValue(a,document.cookie,";")}};polopoly.comments={get:function(b,d,a,c){jQuery.get(b,{comments:d,ajax:"true",ot:"example.AjaxPageLayout.ot"},function(e){$(a).html(e);if(c){c(a)}},"html")}};polopoly.fav={get:function(b,d,a,c){jQuery.get(b,{playlist:d,ajax:"true",ot:"example.AjaxPageLayout.ot"},function(e){$(a).html(e);if(c){c(a)}},"html")}};polopoly.json={_cx:/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,_escapable:/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,_gap:null,_indent:null,_meta:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},_rep:null,_f:function(a){return a<10?"0"+a:a},init:function(){if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(a){return this.getUTCFullYear()+"-"+this._f(this.getUTCMonth()+1)+"-"+this._f(this.getUTCDate())+"T"+this._f(this.getUTCHours())+":"+this._f(this.getUTCMinutes())+":"+this._f(this.getUTCSeconds())+"Z"};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()}}},_quote:function(a){this._escapable.lastIndex=0;return this._escapable.test(a)?'"'+a.replace(this._escapable,function(b){var d=this._meta[b];return typeof d==="string"?d:"\\u"+("0000"+b.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'},_str:function(h,e){var c,b,j,a,f=this._gap,d,g=e[h];if(g&&typeof g==="object"&&typeof g.toJSON==="function"){g=g.toJSON(h)}if(typeof this._rep==="function"){g=this._rep.call(e,h,g)}switch(typeof g){case"string":return this._quote(g);case"number":return isFinite(g)?String(g):"null";case"boolean":case"null":return String(g);case"object":if(!g){return"null"}this._gap+=this._indent;d=[];if(Object.prototype.toString.apply(g)==="[object Array]"){a=g.length;for(c=0;c<a;c+=1){d[c]=this._str(c,g)||"null"}j=d.length===0?"[]":this._gap?"[\n"+this._gap+d.join(",\n"+this._gap)+"\n"+f+"]":"["+d.join(",")+"]";this._gap=f;return j}if(this._rep&&typeof this._rep==="object"){a=this._rep.length;for(c=0;c<a;c+=1){b=this._rep[c];if(typeof b==="string"){j=this._str(b,g);if(j){d.push(this._quote(b)+(this._gap?": ":":")+j)}}}}else{for(b in g){if(Object.hasOwnProperty.call(g,b)){j=this._str(b,g);if(j){d.push(this._quote(b)+(this._gap?": ":":")+j)}}}}j=d.length===0?"{}":this._gap?"{\n"+this._gap+d.join(",\n"+this._gap)+"\n"+f+"}":"{"+d.join(",")+"}";this._gap=f;return j}},stringify:function(d,b,c){var a;this._gap="";this._indent="";if(typeof c==="number"){for(a=0;a<c;a+=1){this._indent+=" "}}else{if(typeof c==="string"){this._indent=c}}this._rep=b;if(b&&typeof b!=="function"&&(typeof b!=="object"||typeof b.length!=="number")){throw new Error("JSON.stringify")}return this._str("",{"":d})},parse:function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}this._cx.lastIndex=0;if(this._cx.test(text)){text=text.replace(this._cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}};polopoly.util={querystringValue:function(a){return this.stringAsHashValue(a,location.search.substr(1),"&")},stringAsHashValue:function(e,c,b){if(c&&c!=""){var a=c.split(b);for(var d=0;d<a.length;d++){var f=jQuery.trim(a[d]);if(f.substring(0,e.length+1)==(e+"=")){return decodeURIComponent(f.substring(e.length+1))}}}}};polopoly.base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",stringDecode:function(a){return this._utf8_decode(this.decode(a))},decode:function(d){try{if(d.length==0){return""}}catch(c){return""}d=d.replace(/[^A-Za-z0-9\+\/\=]/g,"");d=this._padIfNecessary(d);var a="";var m,k,h;var l,j,g,f;var b=0;do{l=this._keyStr.indexOf(d.charAt(b++)||"=");j=this._keyStr.indexOf(d.charAt(b++)||"=");g=this._keyStr.indexOf(d.charAt(b++)||"=");f=this._keyStr.indexOf(d.charAt(b++)||"=");m=(l<<2)|(j>>4);k=((j&15)<<4)|(g>>2);h=((g&3)<<6)|f;a=a+String.fromCharCode(m);if(g!=64){a=a+String.fromCharCode(k)}if(f!=64){a=a+String.fromCharCode(h)}}while(b<d.length);return a},_padIfNecessary:function(a){if((a.length%4)==0){return a}var c=(4-(a.length%4));for(var b=0;b<c;b++){a+="="}return a},stringEncode:function(a){return this.encode(this._utf8_encode(a))},encode:function(c){var a="";var k,h,f,j,g,e,d;var b=0;while(b<c.length){k=c.charCodeAt(b++);h=c.charCodeAt(b++);f=c.charCodeAt(b++);j=k>>2;g=((k&3)<<4)|(h>>4);e=((h&15)<<2)|(f>>6);d=f&63;if(isNaN(h)){e=d=64}else{if(isNaN(f)){d=64}}a=a+this._keyStr.charAt(j)+this._keyStr.charAt(g)+this._keyStr.charAt(e)+this._keyStr.charAt(d)}return a},_utf8_encode:function(b){b=b.replace(/\r\n/g,"\n");var a="";for(var e=0;e<b.length;e++){var d=b.charCodeAt(e);if(d<128){a+=String.fromCharCode(d)}else{if((d>127)&&(d<2048)){a+=String.fromCharCode((d>>6)|192);a+=String.fromCharCode((d&63)|128)}else{a+=String.fromCharCode((d>>12)|224);a+=String.fromCharCode(((d>>6)&63)|128);a+=String.fromCharCode((d&63)|128)}}}return a},_utf8_decode:function(a){var b="";var d=0;var e=c1=c2=0;while(d<a.length){e=a.charCodeAt(d);if(e<128){b+=String.fromCharCode(e);d++}else{if((e>191)&&(e<224)){c2=a.charCodeAt(d+1);b+=String.fromCharCode(((e&31)<<6)|(c2&63));d+=2}else{c2=a.charCodeAt(d+1);c3=a.charCodeAt(d+2);b+=String.fromCharCode(((e&15)<<12)|((c2&63)<<6)|(c3&63));d+=3}}}return b}};polopoly.loginBox={_login:{auth:"authError",perm:"permError",down:"downError","default":"defaultError"},init:function(){document.__ppUseDefLogin=false;try{this.defLogin=p_l_i18n.defaultLoginName}catch(m){this.defLogin="E-mail"}defLogin=this.defLogin;window.setTimeout(this._tryAutoFill,500);jQuery(".clearable").focus(function(){m=jQuery(this);if(document.__ppUseDefLogin&&m.val()==defLogin){m.val("")}});jQuery(".clearable").blur(function(){m=jQuery(this);if(document.__ppUseDefLogin&&m.val()==""){m.val(defLogin)}});jQuery(".not-loggedin .submit").click(function(){var s=jQuery(this).parents(".not-loggedin");var t=s.find(".loginname");var e=s.find(".password");if(t.val()==defLogin&&e.val()==defLogin){t.val("");e.val("")}});jQuery(".clearable").blur();var q=polopoly.cookie.get("loginName");var d=polopoly.cookie.get("sessionKey");if(polopoly.user.isLoggedIn()){jQuery(".loggedin").show();jQuery(".loggedin .user-name").append(polopoly.user.displayName())}else{if(polopoly.user.isMigratedUser()){jQuery(".migrated-resetpassword").show()}else{jQuery(".not-loggedin").show()}}if(polopoly.user.isNewsdaySubscriber()){var g=1000;var i="tnd";var r=846970;var a=new Date();var n=a.getFullYear();var l=a.getMonth();var p=a.getDate();var f=a.getHours();var c=a.getMinutes();var b=a.getSeconds();yearStr=n.toString();l+=1;if(l<10){monthStr="0"+l.toString()}else{monthStr=l.toString()}if(p<10){dayStr="0"+p.toString()}else{dayStr=p.toString()}if(f<10){hourStr="0"+f.toString()}else{hourStr=f.toString()}if(c<10){minuteStr="0"+c.toString()}else{minuteStr=c.toString()}if(b<10){secondStr="0"+b.toString()}else{secondStr=b.toString()}var k=yearStr+monthStr+dayStr+hourStr+minuteStr+secondStr;var j=g+new Number(k)+r;var o="http://www.liveedition.net/newsday/login_tnds.aspx?u="+g.toString()+"&t="+k+"&cs="+j;var h='<a href="'+o+'">e-Edition</a>';jQuery(".loggedin .eelink").append(h)}this._trySetError(".not-loggedin .form-error",polopoly.util.querystringValue("login_formerror"));if(polopoly.util.querystringValue("login_formerror")){jQuery("#loginForm").show()}},_trySetError:function(a,b){if(!b){return}var c=p_l_i18n[this._login[b]]||p_l_i18n[this._login["default"]];jQuery(a).css("display","block").text(c)},_tryAutoFill:function(){if(jQuery(".loginname").val()==""&&jQuery(".password").val()==""){jQuery(".loginname").val(this.defLogin);jQuery(".password").val(this.defLogin);document.__ppUseDefLogin=true}}};polopoly.util.lrumap=function(b,a){if(b){myMap=b}else{myMap=[]}if(!a){a=10}return{map:myMap,size:a,get:function(e){var d=this._findId(e);if(d){var c=this.map[d][1];this._setLeader(d);return c}},rawMap:function(){return this.map},put:function(e,d){var c=this._findId(e);if(c){this.map[c]=[e,d]}else{this.map.unshift([e,d])}if(this.map.length>this.size){this.map.splice(this.size)}},remove:function(d){var c=this._findId(d);if(c){this.map.splice(c,1)}},_findId:function(c){for(key in this.map){if(this.map[key][0]==c){return key}}},_setLeader:function(d){var c=this.map[key];this.map.splice(key,1);this.map.unshift(c)}}};polopoly.newslist={create:function(c,h,d,a,i){var b=polopoly.newslist._getNameFromId(c,h);if(!polopoly.newslist.allListIds){polopoly.newslist.allListIds=[]}polopoly.newslist.allListIds[h]=d;if(!polopoly.newslist.defaultListIds){polopoly.newslist.defaultListIds=[]}polopoly.newslist.defaultListIds[h]=a;jQuery("#edit_"+b+" .button").click(function(){jQuery("#"+b+" .settings").slideToggle(100)});var g=this.getSelection(c,h,i);jQuery("#"+b+" :checkbox").removeAttr("checked");for(var f=0;f<g.length;f++){checkedValue="#c"+h.replace(".","_")+"-"+g[f].replace(".","_");jQuery("#"+b+" "+checkedValue).attr("checked","checked")}if(i&&polopoly.user.isLoggedIn()||!i){jQuery("#edit_"+b).show()}var e=jQuery("#"+b+" input.save");if(i){e.click(function(){polopoly.newslist.storeOnServer(c,h)})}else{e.click(function(){polopoly.newslist.storeInCookie(c,h)})}this.updateList(c,h,i)},getSelection:function(c,a,d){var b;if(d){b=polopoly.user.getSessionServiceSettings(c,a)}else{b=polopoly.user.getServiceSettings(c,a)}return b?b:polopoly.newslist.defaultListIds[a]},_storeInCookie:function(d,a,c){var e=jQuery("#"+c+" input:checkbox:checked");var b=[];jQuery.each(e,function(){b[b.length]=this.value});polopoly.user.setServiceSettings(d,a,b);this.updateList(d,a,false)},_storeInSessionCookie:function(d,a,c){var e=jQuery("#"+c+" input:checkbox:checked");var b=[];jQuery.each(e,function(){b[b.length]=this.value});polopoly.user.setSessionServiceSettings(d,a,b);this.updateList(d,a,true)},storeInCookie:function(c,a){var b=polopoly.newslist._getNameFromId(c,a);polopoly.newslist._storeInCookie(c,a,b);jQuery("#"+b+" .settings").hide(100)},storeOnServer:function(c,a){var b=polopoly.newslist._getNameFromId(c,a);jQuery("#error_"+b).hide();polopoly.newslist._storeInSessionCookie(c,a,b);jQuery.ajax({cache:false,data:{sdid:c,siid:a},error:function(e,f,d){jQuery("#error_"+b+"").show()},success:function(e,d){jQuery("#"+b+" .settings").hide(100)},timeout:2000,type:"POST",url:"/membership/persist"})},updateList:function(d,l,a){var b=polopoly.newslist._getNameFromId(d,l);var k=this.getSelection(d,l,a);if(k.length==0){jQuery("#"+b+" .lists").html("<div class='no_selection'><h4>customize my news and stay on top of what matters to you</h4>Get a quick view of the news and information that is most important to you. Click the 'edit my settings' button below and get started now.</div>");return}var f=polopoly.newslist.allListIds[l];var c=[];for(var g=0;g<k.length;g++){if(polopoly.newslist._contains(f,k[g])){c.push(k[g])}}var e=[];var j=c.length;for(var g=0;g<c.length;g++){var h=c[g];jQuery.get("/cmlink/"+l,{topic:h,mode:"ajax",comment:"true"},function(i,m,n){return function(q){i[m]=q;var r=true;for(var o=0;o<n;o++){if(!i[o]){r=false}}if(r){var p="";for(var o=0;o<n;o++){p+=i[o]}jQuery("#"+b+" .lists").html(p)}}}(e,g,j),"html")}},_contains:function(c,b){if(!c){return false}for(var a=0;a<c.length;a++){if(c[a]==b){return true}}return false},_getNameFromId:function(b,a){return"newsList_"+a.replace(".","_")}};polopoly.passwordMeter={_colors:["#FF0000","#FF0000","#FFCC00","#00CC00","#00FF00"],create:function(d,f){var b="is"+Math.ceil(Math.random()*3000);jQuery(f).html("<div id='"+b+"' style='height: 100%;'></div>");var e=jQuery(f).width();var c=function a(g,h){return function(j){var l=jQuery(d).val();var k=g(l);var i=k>0?Math.ceil(k/4*e):(l.length>0?0.01*e:0);jQuery("#"+b).css("width",i+"px");jQuery("#"+b).css("background-color",h[k])}}(this._testPassword,this._colors);jQuery(d).keyup(c)},_testPassword:function(a){score=0;if(a.length<5){score+=3}else{if(a.length>4&&a.length<8){score+=6}else{if(a.length>7&&a.length<16){score+=12}else{if(a.length>15){score+=18}}}}if(a.match(/[a-z]/)){score+=1}if(a.match(/[A-Z]/)){score+=5}if(a.match(/\d+/)){score+=5}if(a.match(/(.*[0-9].*[0-9].*[0-9])/)){score+=5}if(a.match(/.[!,@,#,$,%,^,&,*,?,_,~]/)){score+=5}if(a.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)){score+=5}if(a.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)){score+=2}if(a.match(/([a-zA-Z])/)&&a.match(/([0-9])/)){score+=2}if(a.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/)){score+=2}if(score<5){return 0}else{if(score>=5&&score<15){return 1}else{if(score>=15&&score<30){return 2}else{if(score>=30&&score<35){return 3}else{return 4}}}}}};jQuery().ready(function(){return function(b){for(var a=0;a<b.length;a++){for(key in b[a]){var c=b[a][key];if(typeof(c.init)=="function"){c.init()}}}}([polopoly,polopoly.service])});var userId=polopoly.cookie.get("userId");var userIdTmp=polopoly.cookie.get("userIdTmp");var NDAL=polopoly.base64.stringDecode(polopoly.cookie.get("NDAL"));if(polopoly.user.isLoggedIn()){var userLoggedIn="true"}else{var userLoggedIn="false"};
