function tpc(){}tpc.user=undefined;tpc.getUser=function(){if(tpc.user==undefined){$.ajax({async:false,url:"/components/account/user/jsonProfile",dataType:"json",success:function(a){tpc.user=a}})}return tpc.user};tpc.handleAlert=function(){var b;if(_displayAlert){b=_displayAlert}else{return}if(b.level==1){var c="/components/content/alert/?id="+b.id;$.fn.colorbox({width:"35%",href:c,onClosed:function(){$.ajax({url:"/components/content/alert/ignore/?id="+b.id})}})}else{if(b.level==2){$.ajax({url:"/components/content/alert/?id="+b.id,success:function(a){$("#udr-user-msg").html(a);$("#udr-user-msg a").each(function(e){var d=$(this).attr("href");if(d.indexOf("ajax:")===0){$(this).bind("click",function(){$(".msg-level-two ul").remove();$(".msg-level-two h2").append($("<img/>").attr("src","/universal/images/loading-12.gif").attr("border","0").css("vertical-align","middle").css("margin","0 10px"));$.ajax({url:d.substring(5,d.length),dataType:"json",success:function(f){$(".msg-level-two h2").html(f.message);setTimeout("hideLevelTwoMessage()","5000")}})});$(this).attr("href","javascript:;")}else{alert("Normal anchor")}});$("#udr-user-msg").fadeIn("slow").css("float","left").effect("highlight",{})}})}else{if(b.level==3){$.ajax({url:"/components/content/alert/?id="+b.id,success:function(a){$("body").prepend(a);setTimeout("showLevelThreeMessage()","2000")}})}else{alert("MESSAGE LEVEL: "+b.level);if(confirm(b.message)){document.location.href=b.url}}}}};function hideLevelTwoMessage(){$("#udr-user-msg").fadeOut("slow")}function showLevelThreeMessage(){$(".msg-level-three").show("blind",{})}var _displayAlert;function udrInitUser(){$("body").prepend($("<div/>").attr("style","margin: 0 auto; width: 1000px;").append($("<div/>").attr("id","user-top-tab").html('<img src="/universal/images/loading-fb-666.gif" alt="Loading..." border="0" style="vertical-align: middle;" />')).append($("<br />").attr("clear","all"))).prepend($("<div/>").attr("style","height:3px;background-color:#f7f8ea; border-bottom: 1px solid #bbbda1;"));var a=tpc.getUser();$("#user-top-tab").find("img:first").fadeOut().remove();$("#user-top-tab").append($("<span/>").attr("id","udr-user-msg").attr("style","margin-right: 10px;").html("").hide());if(a.id>0){$("#user-top-tab").append($("<span/>").addClass("username").html("").append($("<a/>").attr("href","/components/account/user/getprofile").html(a.loginName))).append($("<span/>").addClass("sep").html("|")).append($("<a/>").attr("href","/components/account/logout").html("Log out"));if(a.alerts){for(var b=0;b<a.alerts.length;b++){if(a.alerts[b].level==1){_displayAlert=a.alerts[b];break}else{if(!_displayAlert){_displayAlert=a.alerts[b]}}}if(_displayAlert){setTimeout("tpc.handleAlert()","50")}}}else{$("#user-top-tab").append($("<a/>").attr("href","/components/account/login").html("Login")).append($("<span/>").addClass("sep").html("|")).append($("<a/>").attr("href","/components/account/registration").html("Register"))}}function udrInitMobileUser(){var a=tpc.getUser();if(a.id>0){$(".login-block").append($("<a/>").attr("class","view").attr("href","/components/account/user/getprofile").html(a.loginName)).append($("<span/>").addClass("sep").html("|")).append($("<a/>").attr("href","/components/account/logout").html("Log out"))}else{$(".login-block").append('<a id="loginToggle" class="view" href="/components/account/login">Login</a>').append($("<span/>").addClass("sep").html("|")).append('<a id="registerToggle" class="view" href="/components/account/registration">Register</a>')}}tpc.param=function(b,d){if(d==null){d=""}b=b.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var c=new RegExp("[\\?&]"+b+"=([^&#]*)");var a=c.exec(window.location.href);return(a==null)?d:a[1]};tpc.trim=function(b){try{return b.replace(/^\s*|\s*$/g,"")}catch(a){return b}};tpc.emailArticle=function(){tpc_e_init();$("#email-article").modal()};function tpcjsonreq(a){this.url=a;this.noCacheIE="&noCacheIE="+(new Date()).getTime();this.head=document.getElementsByTagName("head").item(0);this.scriptId="JScriptID"+tpcjsonreq.scriptCounter++}tpcjsonreq.scriptCounter=1;tpcjsonreq.prototype.buildScriptTag=function(){this.scriptObj=document.createElement("script");this.scriptObj.setAttribute("type","text/javascript");this.scriptObj.setAttribute("charset","utf-8");this.scriptObj.setAttribute("src",this.url+this.noCacheIE);this.scriptObj.setAttribute("id",this.scriptId)};tpcjsonreq.prototype.removeScriptTag=function(){this.head.removeChild(this.scriptObj)};tpcjsonreq.prototype.addScriptTag=function(){this.head.appendChild(this.scriptObj)};
