$(document).ready(function(){do_lightbox();$('title').bind("keyup",function(){do_lightbox();})});function submitForm(choice,cname,form){document[form][cname].value=choice;document[form].submit();}
function do_lightbox(){$('a.lightbox').lightBox();}
function refreshAds(list){for(var i=0;i<list.length;i++){var d=list[i];var url='http://'+document.location.host+'/openx/'+d+'/';$("#ad_"+d).load(url,{'ajax':'true'},function(){});}}
function pop_up_url(url,feat){popup=window.open(url,"popupwindow",feat);popup.focus()}
function fbs_click(){u=location.href;if(location.hash.length>1)
u='http://'+document.location.host+location.hash.substr(1);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;}
function tweet_click(){u=location.href;if(location.hash.length>1)
u='http://'+document.location.host+location.hash.substr(1);t=document.title;window.open('http://twitter.com/home?status='+encodeURIComponent(t)+': '+encodeURIComponent(u));return false;}
function refresh(){document.location.reload(true);}
function FBonlogin(){refresh();}
function logout(e){Boxy.ask("Are you sure you want to log out of nyunews.com?",["Yes","No"],function(val){if(val=="Yes"){$.ajax({url:'http://127.0.0.1:8000/accounts/logout/',type:"GET",complete:function(one,two){Boxy.alert("You are now logged out. Come back soon!",null,{title:"Goodbye!",modal:false});refresh();}});}},{title:"Logout",modal:false,fixed:false});}
function do_logout(){$.ajax({url:'http://127.0.0.1:8000/accounts/logout/',type:"GET",complete:function(one,two){refresh();}});}
function isIE(){if(navigator.userAgent.indexOf('MSIE')!=-1)
return true;return false;}
function initEvents(){$(document).ready(function(){$("#accordion").accordion();});}
function initSidebar(){$(document).ready(function(){$("#textlinks").get(0).innerHTML='<p><a href="http://www.credit.com" target="_blank">free credit report</a></p><p><a href="http://www.inkhead.com/personalized-pens+personalized-pencils/personalized-pens-_ca-152-1.html" target="_blank">discount personalized pens</a></p><p><a href="http://www.autotropolis.com/cars/used/search-page-basic.aspx" target="_blank">buy used cars</a></p>';});}
function loadScript(sScriptSrc,callbackfunction)
{var oHead=document.getElementsByTagName('head')[0];if(oHead)
{var oScript=document.createElement('script');oScript.setAttribute('src',sScriptSrc);oScript.setAttribute('type','text/javascript');var loadFunction=function()
{if(this.readyState=='complete'||this.readyState=='loaded')
{callbackfunction();}};oScript.onreadystatechange=loadFunction;oScript.onload=callbackfunction;oHead.appendChild(oScript);}}
(function($){function runTicker(settings){if(settings.firstRun==1){currentLength=settings.currentLength;currentItem=settings.currentItem;settings.firstRun=0;}
if(currentItem==settings.newsItemCounter+1){currentItem=0;}
if(currentLength==0){if(settings.newsLinks[currentItem].length>0){$(settings.newsList).empty().append('<li><a href="'+settings.newsLinks[currentItem]+'"></a></li>');}
else{$(settings.newsList).empty().append('<li></li>');}}
if(currentLength%2==0){placeHolder=settings.placeHolder1;}
else{placeHolder=settings.placeHolder2;}
if(currentLength<=settings.newsItems[currentItem].length+1){var tickerText=settings.newsItems[currentItem].substring(0,currentLength);if(settings.newsLinks[currentItem].length>0){$(settings.newsList+' li a').text(tickerText+placeHolder);}
else{$(settings.newsList+' li').text(tickerText+placeHolder);}
currentLength++;setTimeout(function(){runTicker(settings);settings=null;},settings.tickerRate);}
else{if(settings.newsLinks[currentItem].length>0){$(settings.newsList+' li a').text(settings.newsItems[currentItem]);}
else{$(settings.newsList+' li').text(settings.newsItems[currentItem]);}
currentLength=0;currentItem++;setTimeout(function(){runTicker(settings);settings=null;},settings.loopDelay);}}
$.fn.extend({newsTicker:function(settings){settings=jQuery.extend({newsList:"#news",tickerRate:80,startDelay:100,loopDelay:3000,placeHolder1:" |",placeHolder2:"_"},settings);var newsItems=new Array();var newsLinks=new Array();var newsItemCounter=0;$(settings.newsList+' li').each(function(){if($(this).children('a').length){newsItems[newsItemCounter]=$(this).children('a').text();newsLinks[newsItemCounter]=$(this).children('a').attr('href');}
else{newsItems[newsItemCounter]=$(this).text();newsLinks[newsItemCounter]='';}
newsItemCounter++;});settings=jQuery.extend(settings,{newsItems:newsItems,newsLinks:newsLinks,newsItemCounter:newsItemCounter-1,currentItem:0,currentLength:0,firstRun:1});setTimeout(function(){runTicker(settings);settings=null;},settings.startDelay);}});})(jQuery);function isIE(){if(navigator.userAgent.indexOf('MSIE')!=-1)
return true;return false;}
var ajax_request=null;var is_from_link=false;var hash=window.location.hash;if(hash.length>0)
if(hash.substring(1,2)=="/"){var newLoc=hash.substring(1);newLoc=newLoc.replace('?ref=ajax',"");newLoc=newLoc.replace('&ref=ajax',"");window.location=newLoc;}
$(document).ready(function(){updateClickHandler();setInterval("checkAnchor()",300);});function cancelLoad(){ajax_request.abort();clearLoad();}
function clearLoad(){$('.active_hub_loading').removeClass('active_hub_loading');document.body.style.cursor="default";$('#loader_box').remove();}
var targetDiv='ajax__fullbody';var autoDivs=',featurestripleft,pre_sidebar';function updateClickHandler(){$(".ajaxlink").unbind();$(".ajaxlink").click(function(evt){if(!evt.ctrlKey){evt.preventDefault();is_from_link=true;el=$(this).get(0);if($(this).hasClass('hublink')){hub=$(this).children().get(0).getAttribute('id').substr(4);setHub(hub);}
newHash=getNewHash(el,true,'link','href');setTarget(el);}});$(".ajaxform").unbind();$(".ajaxform").submit(function(evt){evt.preventDefault();el=$(this).get(0);var newHash=getNewHash(el,true,'form','action');setTarget(el);})
$(".silentajaxform").unbind();$(".silentajaxform").submit(function(evt){evt.preventDefault();el=$(this).get(0);var newHash=getNewHash(el,false,'form','action');setTarget(el);load_page_content(newHash,false);})
$(".silentajaxlink").unbind();$(".silentajaxlink").click(function(evt){if(!evt.ctrlKey){evt.preventDefault();is_from_link=true;el=$(this).get(0);newHash=getNewHash(el,false,'link','href');setTarget(el);}
load_page_content(newHash,false);});$('title').trigger('keyup');}
function getNewHash(el,change,type,dest){if(el.hasAttribute(dest)){var newHash=el.getAttribute(dest);newHash=newHash.replace('?ref=ajax',"");newHash=newHash.replace('&ref=ajax',"");if(type=='form'){PostText="";amp="";form=el;for(i=0;i<form.elements.length;i++){if(form.elements[i].type=="text"||form.elements[i].type=="textarea"||form.elements[i].type=="hidden"){PostText+=amp+form.elements[i].name+"="+encodeURIComponent(form.elements[i].value);}else if(form.elements[i].type=="checkbox"){PostText+=amp+form.elements[i].name+"="+form.elements[i].checked;}else if(form.elements[i].type=="select-one"){PostText+=amp+form.elements[i].name+"="+form.elements[i].options[form.elements[i].selectedIndex].text;}
amp="&";}
if(PostText.length>0){if(newHash.indexOf('?')==-1)
newHash+="?"+PostText;else
newHash+="&"+PostText;}}
if(newHash.indexOf('?')==-1)
newHash+="?ref=ajax";else
newHash+="&ref=ajax";if(change)
window.location.href="#"+newHash;return newHash;}
return'';}
function setTarget(el){if(el.hasAttribute('sendto'))
targetDiv=el.getAttribute('sendto');else
targetDiv='ajax__fullbody';}
var currentAnchor='';var oldAnchor=null;function checkAnchor(){if(currentAnchor!=document.location.hash){if(currentAnchor)
oldAnchor=currentAnchor.split('?')[0];currentAnchor=document.location.hash;if(!currentAnchor){var curHash=document.location.pathname;load_page_content(curHash,true);}
else{if(document.location.hash.indexOf('ref=ajax')!=-1){var curHash=document.location.hash.substr(1);if(curHash.substr(0,1)=='?'){if(oldAnchor&&oldAnchor.substr(1,1)!='?')
curHash=oldAnchor.substr(1)+curHash;else
curHash=document.location.pathname+curHash
currentAnchor='#'+curHash;document.location.hash=currentAnchor;}
load_page_content(curHash,true);}}}}
function load_page_content(url,loadAds){$('.active_hub_loading').removeClass('active_hub_loading');document.body.style.cursor="progress";$("<div id='loader_box'><p>loading...</p><a href='javascript:cancelLoad();'><div id='cancel'></div></a></div>").appendTo("body");var active_label=$('.active_hub').get(0);if(active_label)
$('.active_hub').addClass('active_hub_loading');var loaders=new Array();var targetDivs=targetDiv.split(',');prepareAjax(url,targetDivs,loadAds);}
var prepareAjaxFails=0;function prepareAjax(url,targetDivs,loadAds){var datastring='ajax=True&blocks=';for(var i=0;i<targetDivs.length;i++){datastring+=targetDivs[i]+',';}
doAjax(url,datastring,targetDivs,loadAds);}
function doAjax(url,datastring,targetDivs,loadAds){ajax_request=$.ajax({url:url,type:"GET",data:datastring.substring(0,datastring.length-1),success:function(html,textStatus){var success=true;var str="<div>"+html+"</div>";var a=new Array();var adSpots=new Array('leaderboard','banner1','banner2','sidebar1','sidebar2');for(var j=0;j<adSpots.length;j++){if($(str).find("#ad_"+adSpots[j]).html()==null){a[a.length]=adSpots[j];}}
for(var i=0;i<targetDivs.length;i++){if($("#"+targetDivs[i]).size()==1&&$(str).find("#"+targetDivs[i]).length==1){var inner=$(str).find('#'+targetDivs[i]).html();document.getElementById(targetDivs[i]).innerHTML=inner;var scripts=document.getElementById(targetDivs[i]).getElementsByTagName("script");for(var h=0;h<scripts.length;h++){eval(scripts[h].text);}
if(!isIE()){$("#"+targetDivs[i]).fadeTo('slow',1.0);}
prepareAjaxFails=0;}
else if(i!=targetDivs.length-1){if(autoDivs.search(targetDivs[i])==-1){if(success)
prepareAjaxFails++;success=false;}}}
if(success==true){var newTitle=$(str).find('title').html();if(newTitle!=null&&newTitle.length>0)
document.title=newTitle
else
document.title='nyunews.com'
var topEl=document.getElementById(targetDivs[0]);var topDis=topEl.offsetTop;var topOff=window.pageYOffset;if(is_from_link&&(topDis<(topOff-45)||topDis>(topOff+500))){if(topDis<250){$('html,body').animate({scrollTop:0},'slow')}
else{$('html,body').animate({scrollTop:(topDis-100)},'slow')}}
is_from_link=false;clearLoad();updateClickHandler();if(loadAds){var hub=$(str).find('#hubid').html();setHub(hub);pageTracker._trackPageview(url);refreshAds(a);}}
else{if(prepareAjaxFails<2){var a=new Array(['ajax__fullbody']);prepareAjax(url,a,loadAds);}}}});}
function setHub(hub){if($('.active_hub').length>0){removeClass($('.active_hub').get(0),'active_hub');}
if(!hub)
hub='home';addClass(document.getElementById('hub_'+hub),'active_hub');$('#header_navstretch').get(0).setAttribute('class','header_navstretch_'+hub);}
function change_active(link){var newActive=document.getElementById('ajax_'+link);if(newActive){document.getElementById('active').setAttribute('id','');document.getElementById('ajax_'+link).childNodes[0].setAttribute('id','active');}}
function hasClass(ele,cls){return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));}
function addClass(ele,cls){if(!this.hasClass(ele,cls))ele.className+=" "+cls;}
function removeClass(ele,cls){if(hasClass(ele,cls)){var reg=new RegExp('(\\s|^)'+cls+'(\\s|$)');ele.className=ele.className.replace(reg,' ');}}
$(document).ready(function(){initComments();$('title').bind("keyup",function(){initComments();})});function initComments(){$('.replies').hide();$('.showreplies').show();var form=document.getElementById('thecommentform');var h=$('.moveableform');var c=$('.commentform');var w=document.getElementById('commentformwrapper');var cancel=document.getElementById('cancelcomment');var cur_show;$("a.show").click(function(event){event.preventDefault();if(cur_show!=null)
cur_show.style.display='inline';var id=this.id.substr(5);var toplace=document.getElementById('comment_form_'+id)
toplace.appendChild(w);cancel.style.display='inline';var thread=form.elements['thread'];thread.value=id;cur_show=this;this.style.display='none';})
$("#cancelcomment").click(function(event){event.preventDefault();var toplace=document.getElementById('firstcomment')
toplace.appendChild(w);cancel.style.display='none';if(cur_show!=null)
cur_show.style.display='inline';var thread=form.elements['thread'];thread.value=null;})
$("a.showreplies").click(function(event){event.preventDefault();$(this).next(".replies").slideDown("normal");$(this).hide();})}