mtUpdateSignInWidget=function(u){var el=document.getElementById('signin-widget-content');var content='';var register_link;var user_pic=document.getElementById('signin-user-icon');var toprail_signin=document.getElementById('ToprailSignin');if(!el)return;if(u){if(u&&u.is_authenticated){user=u;mtSaveUser()}else{return mtSignIn()}}else{u=mtGetUser()}if(u&&u.name){var url;if(u.is_authenticated){if(u.is_author){url='http://connect'+advBlogSettings.envPrefix+'.'+advBlogSettings.affiliateDomain+'/dashboard/'+encodeURIComponent(u.profile)+'/index.html'}else{url=u.url}}else if(u.url){url=u.url}else{url=null}var userName=u.name;if(userName.length>20){userName=userName.substr(0,16)+"..."}if(url)content+='You are signed in as<br /> <span><a href="'+url+'" class="user">'+userName+'</a></span><br />';else content+='You are signed in as<br /> <span class="user">'+userName+'</span><br />';if(u.is_author)var signOutFunction='mtSignOutOnClick()';if(document.location.href.match(/\/dashboard\/edit\.html/)){signOutFunction='mtSignOutOnClick(\'https://signup'+advBlogSettings.envPrefix+'.'+advBlogSettings.affiliateDomain+'/sign-in/\')'}content+='<a href="https://signup'+advBlogSettings.envPrefix+'.'+advBlogSettings.affiliateDomain+'/dashboard/edit.html" title="Edit your profile">Edit</a> | <a href="http://connect'+advBlogSettings.envPrefix+'.'+advBlogSettings.affiliateDomain+'/user/'+encodeURIComponent(u.profile)+'/index.html" title="View your public profile">Public profile</a> | <a href="javascript:void(0)" onclick="return '+signOutFunction+'" title="Sign out">Sign out</a>';var user_pic_url;var avatarPath=advBlogSettings.mediaUrl.replace(/([^\/])\/[^\/].+/,'$1');if(u.userpic){try{avatarPath=tr_avatar_url}catch(e){}if((u.userpic).match(/^http:\/\//)){user_pic_url=u.userpic}else{user_pic_url=avatarPath+'/'+u.userpic}}else{user_pic_url=advBlogSettings.mediaUrl+'/img/user_default.png'}user_pic.src=user_pic_url;toprail_signin.setAttribute('class','logged_in');document.getElementById('logged_in_widget').style.display='block';document.getElementById('logged_out_widget').style.display='none'}else{function profileLink(profileMode){theLink=signinSubDomain+advBlogSettings.envPrefix+'.'+advBlogSettings.affiliateDomain+'/'+profileMode+'/?return_to='+encodeURIComponent(document.URL);return theLink}document.getElementById('logged_out_widget').style.display='block';document.getElementById('logged_in_widget').style.display='none';document.getElementById('toprail-register-link').setAttribute('href',profileLink('register'));document.getElementById('toprail-login-register').setAttribute('href',profileLink('register'));document.getElementById('ForgotPassword').setAttribute('href',profileLink('remember'));document.getElementById('ToprailSigninForm').action=mtRegisterCGIPath+mtCommunityScript;document.getElementById('affiliate').value=advAffiliate;document.getElementById('v').value=advVersion;jQuery('#toprail-fb-link').attr('href',profileLink('sign-in')+'&option=Facebook');jQuery('#openIdLinks a').each(function(){var myClass=this.className.split(' ')[0];if(myClass!=''){this.href=profileLink('sign-in')+'&option='+myClass;jQuery(this).removeClass(myClass)}})}el.innerHTML=content;document.getElementById('ToprailSignin').style.display='block'};showLoginForm=function(obj){jQuery("#SigninNav li").removeClass('selected');jQuery(obj).addClass('selected');var id=obj.id;var rEx=/option/;jQuery("#SigninForms").children().hide();jQuery("#"+id.replace(rEx,'with')).show()};initSignIn=function(){if((document.getElementById('SignInDialog')!=null)){jQuery("#SignInDialog").jqm({overlay:30.01,modal:false})}};videoSearch=function(baseUrl){var loc=baseUrl+'/search='+escape($('#vidSearch').val())+'/index.html';window.location.href=loc};initEntryCreatePreview=function(){if(jQuery('#create-entry-form').size()){jQuery('#create-entry-form #entry-title').keyup(function(){jQuery('#postPreviewTitle').html(jQuery('#entry-title').val())});jQuery('#create-entry-form #entry-body').keyup(function(){jQuery('#postPreviewText').html(jQuery('#entry-body').val().replace(/(\r\n|\n)/g,'<br />'))});jQuery('#create-entry-form #entry-tags').keyup(function(){jQuery('#postPreviewTags').html("<span>Story tags:</span> "+jQuery('#entry-tags').val().replace(/,/g,' | '))})}};moderate=function(href){var isIE6=(jQuery.browser.name=='msie'&&jQuery.browser.versionNumber<7)?true:false;var overlay=document.createElement("div");overlay.setAttribute("id","ModerateOverlay");overlay.setAttribute("class","jqmWindow");document.body.appendChild(overlay);var boxtop=document.createElement("div");(isIE6)?boxtop.setAttribute("id","BoxTopIE6"):boxtop.setAttribute("id","BoxTop");var box=document.createElement("div");box.setAttribute("id","Box");var boxbottom=document.createElement("div");boxbottom.setAttribute("id","BoxBottom");overlay.appendChild(boxtop);overlay.appendChild(box);if(!isIE6)overlay.appendChild(boxbottom);jQuery("#BoxTop,#BoxTopIE6").html('<a href="" title="Click to close" class="jqmClose" id="ModerateClose"><!-- --></a>');var iframe=document.createElement("iframe");iframe.setAttribute("id","ModerateIframe");(jQuery.browser.name=='msie')?iframe.setAttribute("frameBorder","0"):iframe.setAttribute("frameborder","0");iframe.setAttribute("src",href);iframe.setAttribute("scrolling","no");box.appendChild(iframe);var destroyJQM=function(hash){hash.o.remove();jQuery("#ModerateOverlay").remove()};jQuery("#ModerateOverlay").center();jQuery("#ModerateOverlay").jqm({overlay:30.01,modal:true,onHide:destroyJQM});jQuery("#ModerateOverlay").jqmShow();return false};resetTabs=function(ulObj){jQuery(ulObj).children().remove("li[class*='mt_tab_active_']");jQuery.each(jQuery(ulObj).children(),function(){var prevLi=jQuery(this).prev("li");var nextLi=jQuery(this).next("li");jQuery(this).removeClass();jQuery(this).children("a").removeClass();if(!prevLi.length){jQuery(this).children("a").addClass("first")}if(!nextLi.length){jQuery(this).children("a").addClass("last")}})};setTab=function(liObj){var prevLi=jQuery(liObj).prev("li");var nextLi=jQuery(liObj).next("li");jQuery(liObj).addClass("mt_tab_active");if(prevLi.length){jQuery(liObj).before('<li class="mt_tab_active_left" />');prevLi.children("a").addClass("before")}else{jQuery(liObj).before('<li class="mt_tab_active_first" />');jQuery(liObj).children("a").removeClass("first")}if(nextLi.length){jQuery(liObj).after('<li class="mt_tab_active_right" />');nextLi.children("a").addClass("after")}else{jQuery(liObj).after('<li class="mt_tab_active_last" />');jQuery(liObj).children("a").removeClass("last")}};initTabs=function(){jQuery.each(jQuery(".mt_tabs ul").children(),function(){if(jQuery(this).hasClass("on")){setTab(this)}})};initTabsWithClick=function(ulObj){jQuery.each(jQuery(ulObj).children(),function(){if(jQuery(this).hasClass("on")){setTab(this)}jQuery(this).click(function(){resetTabs(jQuery(this).parent());jQuery(this).addClass("on");setTab(jQuery(this))})})};processAd=function(adId){var ad=jQuery("#"+adId+" a");var img=jQuery("#"+adId+" img");if(typeof ad=="object"){var re=new RegExp(/empty.gif/);var m=re.exec(ad.attr('href'));if(m!=null||jQuery("#"+adId).find("span[name],span[title]").length>0){jQuery("#"+adId).css({display:"none"})}}};shuffle=function(o){for(var j,x,i=o.length;i;j=parseInt(Math.random()*i),x=o[--i],o[i]=o[j],o[j]=x);return o};setSelectYear=function(id){var now=new Date();var start=now.getFullYear()-13;var end=now.getFullYear()-101;for(var x=start;x>end;x--){jQuery("#"+id).append('<option value="'+x+'">'+x+'</option>')}};validateValue=function(obj,msg){var scsRE=/[\s\~\`\!\@\#\$\%\^\&\*\(\)\=\+\{\}\;\:\'\"\/\?\,\.\<\>]/;if(obj.value.match(scsRE)!=null){alert(msg);return false}return true};var PageQuery=new function(){var q=window.location.search;this.q_str=(q.length>1)?q.substring(1,q.length):null;this.keyValuePairs=new Array();if(q){for(var i=0;i<this.q_str.split("&").length;i++){this.keyValuePairs[i]=this.q_str.split("&")[i]}}this.getValue=function(s){for(var j=0;j<this.keyValuePairs.length;j++){if(this.keyValuePairs[j].split("=")[0]==s)return this.keyValuePairs[j].split("=")[1]}return false};this.getParameters=function(){var a=new Array(this.keyValuePairs.length);for(var j=0;j<this.keyValuePairs.length;j++){a[j]=this.keyValuePairs[j].split("=")[0]}return a}};function hide(element){document.getElementById(element).style.display='none'};function showBubble(msg,l,t,w){if(!w)var w=170;jQuery("#InfoData").html(msg);jQuery("#InfoData").css('width',(w-27)+'px');jQuery("#InfoPopup").css({left:l,top:t,width:w+'px'});jQuery("#InfoPopup .roundbox_tl, #InfoPopup .roundbox_tr, #InfoPopup .roundbox_bl, #InfoPopup .roundbox_br").css('width',(w-14)+'px');jQuery('#InfoPopup').jqmShow()};function embedSlideshow(blogId,galleryId,galleryBasename,qstring){var slideshowUrl="/embedslideshow/"+blogId+"/"+galleryBasename+"/index.html?rewrite=true"+qstring;if((location.href).match(/www/)){slideshowUrl="/esi_hack.html?env="+advEnvPrefix+"&ssurl="+escape(slideshowUrl)}var ss_html="";jQuery.ajax({url:slideshowUrl,dataType:"html",success:function(html){ss_html=html},complete:function(xhr,status){if(ss_html){jQuery("#slideshow"+galleryId).html(ss_html);jQuery("#slideshow"+galleryId).fadeIn();jQuery(".ss_next"+galleryId+",.ss_prev"+galleryId).bind('click',function(){jQuery(".ss_next"+galleryId+",.ss_prev"+galleryId).unbind('click');jQuery("#slideshow"+galleryId).jCarouselLiteMod({abstracts:window['photoData'+galleryId].photos,scroll:5,visible:5,nextClass:".ss_next"+galleryId,prevClass:".ss_prev"+galleryId});jQuery(this).trigger('click')})}}})};loadContent=function(src,target){jQuery(target).html('<span class="loading"><img src="'+advBlogSettings.mediaUrl+'/img/loading-150.gif" alt="" width="150" height="150"/></span>');jQuery.ajax({url:src,dataType:"html",success:function(html){jQuery(target).html(html)}})};switchAdvTabs=function(el){var $tabCells=jQuery(el).parent().parent().children('td');$tabCells.not('.first_tab,.last_tab').removeClass();$tabCells.removeClass('fix_background');if(jQuery(el).parent().is('.first_tab')){$tabCells.removeClass('last_tab_active');jQuery(el).parent().addClass('first_tab_active')}else if($(el).parent().is('.last_tab')){$tabCells.removeClass('first_tab_active');jQuery(el).parent().addClass('last_tab_active');jQuery(el).parent().prev().addClass('fix_background')}else if($(el).parent().not('.first_tab,.last_tab')){$tabCells.removeClass('first_tab_active last_tab_active');jQuery(el).parent().addClass('tab_active');jQuery(el).parent().prev().addClass('fix_background')}else{}};fbs_click=function(){u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false};helperText=function(obj,helperName){if(jQuery.browser.name!='msie'){jQuery('#InfoPopup').jqmHide()}jQuery("#InfoData").html("");var msg;var o=jQuery(obj).offset();if(helperName=="followUs"){msg="Click each of these buttons to see the following:<br />&bull; The \"F\" Facebook symbol opens our Facebook Fan page in a new window<br />&bull; The \"t\" opens our Twitter page in a new window<br />&bull; The orange symbol takes you to our RSS feeds page in your current window<br />&bull; The cell phone symbol takes you a page all about our mobile service in your current window";showBubble(msg,o.left-130,o.top-148,300)}if(helperName=="activeUsers"){msg="Find the 5 users with the most comments in the past 48 hours. Click on the user's number, image or name and you'll see the full profile for the user. The Featured User allows you to discover members who have made comment, photo and/or video contributions throughout the site.";showBubble(msg,o.left-130,o.top-133,280)}if(helperName=="tags"){msg="This display of words shows you the most popular article tags for articles in your current category (news, sports, entertainment, etc.). The larger the tag text is, the more popular that tag is. ";showBubble(msg,o.left-130,o.top-103,280)}};popularTabs=function(obj,contentUrl){if((location.href).match(/www/)){contentUrl="/esi_hack.html?env="+advEnvPrefix+"&ssurl="+escape(contentUrl)}loadContent(contentUrl,"#PopularStories");switchAdvTabs(obj)};recommendPopUp=function(obj,btnType,entryId,blogId){if(jQuery.browser.name!='msie'){jQuery('#InfoPopup').jqmHide()}var u=mtGetUser();var contentUrl="/community/fakeScript.js?__mode=vote&blog_id="+blogId+"&f=count,scored&jsonp=newRecommend&id="+entryId;if((location.href).match(/www/)){contentUrl="/esi_hack.html?env="+advEnvPrefix+"&ssurl="+escape(contentUrl)}var message="";var leftOffset=35;var topOffset=60;var o=jQuery(obj).offset();if(u){jQuery.ajax({url:contentUrl,dataType:"text",async:false,cache:false,success:function(data){function newRecommend(scoreJson){for(var id in scoreJson){if(id=="error"){if(scoreJson[id]==""){message="You must be signed in to recommend."}else{if(scoreJson[id].match(/Already scored/i)){message="You have already recommended this story."}else{message="Error: "+scoreJson[id]}}}else{jQuery("#recommendCount").html(scoreJson[id].count);message="Thank you.  Your vote has been counted."}}}eval(data);if(btnType=="small"){leftOffset=65;topOffset=50}}})}else{message="You must be signed in to recommend. <a href=\""+signinSubDomain+advEnvPrefix+"."+advDomain+"/sign-in/?return_to="+encodeURIComponent(document.URL)+"\">Sign in with your existing account</a> or <a href=\"https://signup"+advEnvPrefix+"."+advDomain+"/register/?return_to="+encodeURIComponent(document.URL)+"\">create a new one now</a>.";if(btnType=="small"){leftOffset=65;topOffset=82}else{leftOffset=35;topOffset=90}}showBubble(message,o.left-leftOffset,o.top-topOffset)};followPopUp=function(obj,authorName,authorId){if(jQuery.browser.name!='msie'){jQuery('#InfoPopup').jqmHide()}jQuery("#InfoData").html("");var u=mtGetUser();var message="";var leftOffset=47;var topOffset=50;var o=jQuery(obj).offset();var followUrl="";if(u){if(!authorId){return false}else{followUrl="/following/"+u.profile+"/is_following/"+authorId+"/index.html";if((location.href).match(/www/)){followUrl="/esi_hack.html?env="+advEnvPrefix+"&ssurl="+escape(followUrl)}jQuery.ajax({url:followUrl,dataType:"text",async:false,cache:false,success:function(data){if(data==1){message="You are already following "+authorName+"."}else if(data==2){message="We're sorry.  You cannot follow yourself."}else if(data==0){followUrl="/following/"+u.profile+"/start_following/"+authorId+"/index.html";if((location.href).match(/www/)){followUrl="/esi_hack.html?env="+advEnvPrefix+"&ssurl="+escape(followUrl)}jQuery.ajax({url:followUrl,dataType:"text",async:false,cache:false,success:function(data){if(data==1){message="You are now following "+authorName+"."}else if(data==2){message="We're sorry.  You cannot follow yourself."}else{message="There was an error following "+authorName+"."}},error:function(){message="There was an error following "+authorName+"."}})}else{message="There was an error following "+authorName+"."}},error:function(){message="There was an error following "+authorName+"."}})}}else{message="You must be signed in to follow a user. <a href=\""+signinSubDomain+advEnvPrefix+"."+advDomain+"/sign-in/?return_to="+encodeURIComponent(document.URL)+"\">Sign in with your existing account</a> or <a href=\"https://signup"+advEnvPrefix+"."+advDomain+"/register/?return_to="+encodeURIComponent(document.URL)+"\">create a new one now</a>.";topOffset=82}showBubble(message,o.left-leftOffset,o.top-topOffset)};var advBlogSettings={relativeCgiPath:mtRelativeCGIPath,commScript:mtCommunityScript,version:advVersion,affiliate:advAffiliate,mediaUrl:mediaURL,envPrefix:advEnvPrefix,affiliateDomain:advDomain};var bwName=jQuery.browser.name;var bwVersion=jQuery.browser.versionNumber;mtInitAttachEvents=function(){};try{if(isSSF){}}catch(e){jQuery(function(){jQuery("img").lazyload({effect:"fadeIn",threshold:100})})}jQuery.elementReady('PageContent',function(){try{if(jQuery("#TopStoriesBox").length>0){url="/"+advAffiliate+"_hot_topics/index.html";if((location.href).match(/www/)){url="/esi_hack.html?env="+advEnvPrefix+"&ssurl="+escape(url)}jQuery.ajax({url:url,dataType:"html",success:function(html){jQuery("#TopStoriesBox").html(html);jQuery("#TopStoriesBox").slideDown().fadeIn();jQuery(".ts_next,.ts_prev").bind('click',function(){jQuery(".ts_next,.ts_prev").unbind('click');jQuery("#TopStories").jCarouselLiteMod({abstracts:hsData.stories,scroll:3,nextClass:".ts_next",prevClass:".ts_prev"});jQuery(this).trigger('click')})}})}}catch(e){}});jQuery().ready(function(){if(jQuery.browser.name=='msie'&&jQuery.browser.versionNumber<7){try{document.execCommand('BackgroundImageCache',false,true)}catch(e){}jQuery(".btn_signin").hover(function(){jQuery(this).addClass("btn_signin_mo")},function(){jQuery(this).removeClass("btn_signin_mo")});jQuery(".btn_signup").hover(function(){jQuery(this).addClass("btn_signup_mo")},function(){jQuery(this).removeClass("btn_signup_mo")});jQuery(".btn_save").hover(function(){jQuery(this).addClass("btn_save_mo")},function(){jQuery(this).removeClass("btn_save_mo")});jQuery(".btn_search").hover(function(){jQuery(this).addClass("btn_search_mo")},function(){jQuery(this).removeClass("btn_search_mo")});jQuery(".btn_write_post").hover(function(){jQuery(this).addClass("btn_write_post_mo")},function(){jQuery(this).removeClass("btn_write_post_mo")});jQuery(".btn_submit_photos_2").hover(function(){jQuery(this).addClass("btn_submit_photos_2_mo")},function(){jQuery(this).removeClass("btn_submit_photos_2_mo")});jQuery(".btn_submit_videos").hover(function(){jQuery(this).addClass("btn_submit_videos_mo")},function(){jQuery(this).removeClass("btn_submit_videos_mo")});jQuery(".btn_submit_photos").hover(function(){jQuery(this).addClass("btn_submit_photos_mo")},function(){jQuery(this).removeClass("btn_submit_photos_mo")});jQuery(".btn_preview").hover(function(){jQuery(this).addClass("btn_preview_mo")},function(){jQuery(this).removeClass("btn_preview_mo")});jQuery(".btn_post").hover(function(){jQuery(this).addClass("btn_post_mo")},function(){jQuery(this).removeClass("btn_post_mo")});jQuery(".btn_upload").hover(function(){jQuery(this).addClass("btn_upload_mo")},function(){jQuery(this).removeClass("btn_upload_mo")});jQuery(".btn_next").hover(function(){jQuery(this).addClass("btn_next_mo")},function(){jQuery(this).removeClass("btn_next_mo")})}jQuery(".print_window").click(function(){window.open(jQuery(this).attr('href'),'printWin','height=500,width=700,scrollbars=1,resizable=1,menubar=1');return false});initSignIn();jQuery("#InfoPopup").jqm({trigger:'.follow,.doRecommend,.helperText',overlay:0.01,modal:false});var fb_text=jQuery(".fb_share_count_inner").html();if(isNaN(parseInt(fb_text)))jQuery(".fb_share_count_inner").html('0')});mtAttachEvent("unload",mtEntryOnUnload);mtAttachEvent("advanceui",mtUpdateScores);mtAttachEvent('advanceui',mtUpdateSignInWidget);mtAttachEvent('advanceui',mtUserOnLoad);try{if(isSSF){mtFetchRemoteUser();jQuery.elementReady("Toprail_Leaderboard",function(){jQuery.elementReady("Sponsor_Ad",function(){mtFireEvent('advanceui')})});jQuery.elementReady("MainColumn",function(){jQuery.elementReady("Footer",function(){mtFireEvent('advanceui')})})}}catch(e){mtFetchRemoteUser();jQuery().ready(function(){mtFireEvent('advanceui')})}