// UPM Image
function upm_pop_img(src,w,h,name,title)
{var ww=parseInt(w);var wh=parseInt(h);if(ww<100)
{ww=125;}
if(wh<100)
{wh=125;ww+=75;}
var scroll=false;if(screen.width&&(screen.width<ww))
{scroll='yes';ww=screen.width;}
if(screen.height&&(screen.height<wh))
{scroll='yes';wh=screen.height;}
if(!title)
{title=name;}
var t=(screen.height)?(screen.height-wh)/2:0;var l=(screen.width)?(screen.width-ww)/2:0;var upm_pop_win=window.open('','upm_pop_win','top = '+t+', left = '+l+', width = '+ww+', height = '+wh+', toolbar = no, location = no, directories = no, status = no, menubar = no, scrollbars = '+scroll+', copyhistory = no, resizable = yes');upm_pop_win.document.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">');upm_pop_win.document.writeln('<html>');upm_pop_win.document.writeln('<head>');upm_pop_win.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=utf-8">');upm_pop_win.document.writeln('<meta http-equiv="imagetoolbar" content="no">');upm_pop_win.document.writeln('<title>'+title+'</title>');upm_pop_win.document.writeln('<style type="text/css">');upm_pop_win.document.writeln('<!--');upm_pop_win.document.writeln('body {');upm_pop_win.document.writeln('margin: 0;');upm_pop_win.document.writeln('padding: 0;');upm_pop_win.document.writeln('color: #000;');upm_pop_win.document.writeln('background-color: #fff;');upm_pop_win.document.writeln('text-align: center;');if(scroll==false)
{upm_pop_win.document.writeln('overflow: hidden;');}
upm_pop_win.document.writeln('}');upm_pop_win.document.writeln('');upm_pop_win.document.writeln('img {');upm_pop_win.document.writeln('margin: 0 auto;');upm_pop_win.document.writeln('padding: 0;');upm_pop_win.document.writeln('border: none;');if(wh==125)
{upm_pop_win.document.writeln('margin-top: '+Math.floor(50-(h/2))+'px;');}
upm_pop_win.document.writeln('}');upm_pop_win.document.writeln('-->');upm_pop_win.document.writeln('</style>');upm_pop_win.document.writeln('</head>');upm_pop_win.document.writeln('<body>');upm_pop_win.document.writeln('<div id="upm-image-view">');upm_pop_win.document.writeln('<img src="'+src+'" width="'+w+'" height="'+h+'" alt="">');upm_pop_win.document.writeln('</div>');upm_pop_win.document.writeln('</body>');upm_pop_win.document.write('</html>');upm_pop_win.document.close();upm_pop_win.focus();return false;}

//CBS Live Search
var cbs_live_search=(function(d){var f="",q,a,m,n,p,b,o,c,r,h,j;function g(){o.value="";k();o.focus()}function e(){clearTimeout(n);i(r);if(a){a=0;d(h).hide(600)}}function i(t,s){if(t){return t.css("visibility",s?"":"hidden")}}function k(){var s=o.value;if(s!=f){f=s;i(c,s);s=d.trim(s);if(s!=q.q){if(b){b.abort()}if((q.q=s).length<3){e()}else{i(r,1);b=d.ajax(d.extend(p,{data:q}))}}}}function l(){var s={width:j.clientWidth,height:j.clientHeight};if(!a){a=1;d(h).queue(function(){d(h).css(s).dequeue()}).show(600)}else{d(h).animate(s,600)}}return function(v,s,u,w,t){w=w&&/Apple Computer/.test(navigator.vendor)&&(parseInt(navigator.productSub)>=20020000);u="<p>"+u+"</p>";q=t;v=d("#"+v).append(d([j=i(d("<div />")).css("position","absolute")[0],h=d("<div />").css("display","none")[0]]).addClass("ls_results"))[0];o=d("input",v).focus(function(){if(d(o).hasClass("ls_inactive")){d(o).removeClass("ls_inactive");o.value=""}m=setInterval(k,1000)}).blur(function(){clearInterval(m);k();if(!w&&(o.value=="")){d(o).addClass("ls_inactive");o.value=s}}).keydown(function(x){if(x.keyCode==27){g()}})[0];r=i(d('<span class="ls_wait_image" />')).insertAfter(o);c=!w&&i(d('<span class="ls_reset_image" />')).click(g).insertAfter(o);if(d.browser.mozilla&&!document.getElementsByClassName){r.add(c).css("display","-moz-inline-stack")}if(w){d(v).addClass("ls_safari");o.type="search";d(o).attr({autosave:v.action,results:"5",placeholder:s})}else{d(o).attr({autocomplete:"off",value:s}).addClass("ls_inactive")}p={url:v.action,type:"POST",dataType:"html",success:function(x){clearTimeout(n);i(r);d([j,h]).html((x=="<none />")?u:x);n=setTimeout(l,50)},error:e}}})(jQuery);

//Masonry
;(function($){$.fn.masonry=function(options,callback){function placeBrick($brick,setCount,setY,setSpan,props){var shortCol=0;for(i=0;i<setCount;i++){if(setY[i]<setY[shortCol])shortCol=i;}
$brick.css({top:setY[shortCol],left:props.colW*shortCol+props.posLeft});for(i=0;i<setSpan;i++){props.colY[shortCol+i]=setY[shortCol]+$brick.outerHeight(true);}}
function masonrySetup($wall,opts,props){if(props.masoned&&opts.appendedContent!=undefined){var $brickParent=opts.appendedContent;}else{var $brickParent=$wall;}
props.$bricks=opts.itemSelector==undefined?$brickParent.children():$brickParent.find(opts.itemSelector);if(opts.columnWidth==undefined){props.colW=props.masoned?$wall.data('masonry').colW:props.$bricks.outerWidth(true);}else{props.colW=opts.columnWidth;}
props.colCount=Math.floor($wall.width()/props.colW);props.colCount=Math.max(props.colCount,1);}
function masonryArrange($wall,opts,props){if(!props.masoned)$wall.css('position','relative');if(!props.masoned||opts.appendedContent!=undefined){props.$bricks.css('position','absolute');}
var cursor=$('<div />');$wall.prepend(cursor);props.posTop=Math.round(cursor.position().top);props.posLeft=Math.round(cursor.position().left);cursor.remove();if(props.masoned&&opts.appendedContent!=undefined){props.colY=$wall.data('masonry').colY;for(var i=$wall.data('masonry').colCount;i<props.colCount;i++){props.colY[i]=props.posTop;};}else{props.colY=[];for(i=0;i<props.colCount;i++){props.colY[i]=props.posTop;}}
if(opts.singleMode){props.$bricks.each(function(){var $brick=$(this);placeBrick($brick,props.colCount,props.colY,1,props);});}else{props.$bricks.each(function(){var $brick=$(this);var colSpan=Math.ceil($brick.outerWidth(true)/props.colW);colSpan=Math.min(colSpan,props.colCount);if(colSpan==1){placeBrick($brick,props.colCount,props.colY,1,props);}else{var groupCount=props.colCount+1-colSpan;var groupY=[0];for(i=0;i<groupCount;i++){groupY[i]=0;for(j=0;j<colSpan;j++){groupY[i]=Math.max(groupY[i],props.colY[i+j]);}}
placeBrick($brick,groupCount,groupY,colSpan,props);}});}
props.wallH=0;for(i=0;i<props.colCount;i++){props.wallH=Math.max(props.wallH,props.colY[i]);}
$wall.height(props.wallH-props.posTop);callback.call(props.$bricks);$wall.data('masonry',props);}
function masonryResize($wall,opts,props){var prevColCount=$wall.data('masonry').colCount;masonrySetup($wall,opts,props);if(props.colCount!=prevColCount)masonryArrange($wall,opts,props);}
return this.each(function(){var $wall=$(this);var props=$.extend({},$.masonry);props.masoned=$wall.data('masonry')!=undefined;var previousOptions=props.masoned?$wall.data('masonry').options:{};var opts=$.extend({},props.defaults,previousOptions,options);props.options=opts.saveOptions?opts:previousOptions;callback=callback||function(){};if($wall.children().length>0){masonrySetup($wall,opts,props);masonryArrange($wall,opts,props);var resizeOn=previousOptions.resizeable;if(!resizeOn&&opts.resizeable){$(window).bind('resize.masonry',function(){masonryResize($wall,opts,props);});}
if(resizeOn&&!opts.resizeable)$(window).unbind('resize.masonry');}else{return this;}});};$.masonry={defaults:{singleMode:false,columnWidth:undefined,itemSelector:undefined,appendedContent:undefined,saveOptions:true,resizeable:true},colW:undefined,colCount:undefined,colY:undefined,wallH:undefined,masoned:undefined,posTop:0,posLeft:0,options:undefined,$bricks:undefined};})(jQuery);

//InfiniteScroll
;(function($){$.fn.infinitescroll=function(options,callback){function debug(){if(opts.debug){window.console&&console.log.call(console,arguments)}}
function areSelectorsValid(opts){for(var key in opts){if(key.indexOf&&key.indexOf('Selector')&&$(opts[key]).length===0){debug('Your '+key+' found no elements.');return false;}
return true;}}
function determinePath(path){path.match(relurl)?path.match(relurl)[2]:path;if(path.match(/^(.*?)\b2\b(.*?$)/)){path=path.match(/^(.*?)\b2\b(.*?$)/).slice(1);}else
if(path.match(/^(.*?)2(.*?$)/)){if(path.match(/^(.*?page=)2(\/.*|$)/)){path=path.match(/^(.*?page=)2(\/.*|$)/).slice(1);return path;}
debug('Trying backup next selector parse technique. Treacherous waters here, matey.');path=path.match(/^(.*?)2(.*?$)/).slice(1);}else{debug('Sorry, we couldn\'t parse your Next (Previous Posts) URL. Verify your the css selector points to the correct A tag. If you still get this error: yell, scream, and kindly ask for help at infinite-scroll.com.');props.isInvalidPage=true;}
return path;}
function getDocumentHeight(){return opts.localMode?($(props.container)[0].scrollHeight&&$(props.container)[0].scrollHeight):$(document).height()}
function isNearBottom(){var pixelsFromWindowBottomToBottom=0+
getDocumentHeight()-(opts.localMode?$(props.container).scrollTop():($(props.container).scrollTop()||$(props.container.ownerDocument.body).scrollTop()))-$(opts.localMode?props.container:window).height();debug('math:',pixelsFromWindowBottomToBottom,props.pixelsFromNavToBottom);return(pixelsFromWindowBottomToBottom-opts.bufferPx<props.pixelsFromNavToBottom);}
function showDoneMsg(){props.loadingMsg.find('img').hide().parent().find('div').html(opts.donetext).animate({opacity:1},2000).fadeOut('normal');opts.errorCallback();}
function infscrSetup(){if(props.isDuringAjax||props.isInvalidPage||props.isDone)return;if(!isNearBottom(opts,props))return;$(document).trigger('retrieve.infscr');}
function kickOffAjax(){props.isDuringAjax=true;props.loadingMsg.appendTo(opts.contentSelector).show();$(opts.navSelector).hide();props.currPage++;debug('heading into ajax',path);box=$(opts.contentSelector).is('table')?$('<tbody/>'):$('<div/>');box.attr('id','infscr-page-'+props.currPage).addClass('infscr-pages').appendTo(opts.contentSelector).load(path.join(props.currPage)+' '+opts.itemSelector,null,loadCallback);}
function loadCallback(){if(props.isDone){showDoneMsg();return false;}else{if(box.children().length==0){$.event.trigger("ajaxError",[{status:404}]);}
props.loadingMsg.fadeOut('normal');if(opts.animate){var scrollTo=$(window).scrollTop()+$('#infscr-loading').height()+opts.extraScrollPx+'px';$('html,body').animate({scrollTop:scrollTo},800,function(){props.isDuringAjax=false;});}
callback.call(box[0]);if(!opts.animate)props.isDuringAjax=false;}}
var opts=$.extend({},$.infinitescroll.defaults,options),props=$.infinitescroll,box;callback=callback||function(){};if(!areSelectorsValid(opts)){return false;}
props.container=opts.localMode?this:document.documentElement;opts.contentSelector=opts.contentSelector||this;var relurl=/(.*?\/\/).*?(\/.*)/,path=$(opts.nextSelector).attr('href');if(!path){debug('Navigation selector not found');return;}
path=determinePath(path);if(opts.localMode)$(props.container)[0].scrollTop=0;props.pixelsFromNavToBottom=getDocumentHeight()+
(props.container==document.documentElement?0:$(props.container).offset().top)-
$(opts.navSelector).offset().top;props.loadingMsg=$('<div id="infscr-loading" style="text-align: center;"><img alt="Loading..." src="'+
opts.loadingImg+'" /><div>'+opts.loadingText+'</div></div>');(new Image()).src=opts.loadingImg;$(document).ajaxError(function(e,xhr,opt){debug('Page not found. Self-destructing...');if(xhr.status==404){showDoneMsg();props.isDone=true;$(opts.localMode?this:window).unbind('scroll.infscr');}});$(opts.localMode?this:window).bind('scroll.infscr',infscrSetup).trigger('scroll.infscr');$(document).bind('retrieve.infscr',kickOffAjax);return this;}
$.infinitescroll={defaults:{debug:false,preload:false,nextSelector:"div.navigation a:first",loadingImg:"http://www.infinite-scroll.com/loading.gif",loadingText:"Loading the next set of posts...",donetext:"Congratulations, you've reached the end of the internet.",navSelector:"div.navigation",contentSelector:null,extraScrollPx:150,itemSelector:"div.post",animate:false,localMode:false,bufferPx:40,errorCallback:function(){}},loadingImg:undefined,loadingMsg:undefined,container:undefined,currPage:1,currDOMChunk:null,isDuringAjax:false,isInvalidPage:false,isDone:false};})(jQuery);