// 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);

/*************************************************
**  jQuery Masonry version 1.3.1
**  Copyright David DeSandro, licensed MIT
**  http://desandro.com/resources/jquery-masonry
**************************************************/
;(function(e){var n=e.event,o;n.special.smartresize={setup:function(){e(this).bind("resize",n.special.smartresize.handler)},teardown:function(){e(this).unbind("resize",n.special.smartresize.handler)},handler:function(j,l){var g=this,d=arguments;j.type="smartresize";o&&clearTimeout(o);o=setTimeout(function(){jQuery.event.handle.apply(g,d)},l==="execAsap"?0:100)}};e.fn.smartresize=function(j){return j?this.bind("smartresize",j):this.trigger("smartresize",["execAsap"])};e.fn.masonry=function(j,l){var g=
{getBricks:function(d,b,a){var c=a.itemSelector===undefined;b.$bricks=a.appendedContent===undefined?c?d.children():d.find(a.itemSelector):c?a.appendedContent:a.appendedContent.filter(a.itemSelector)},placeBrick:function(d,b,a,c,h){b=Math.min.apply(Math,a);for(var i=b+d.outerHeight(true),f=a.length,k=f,m=c.colCount+1-f;f--;)if(a[f]==b)k=f;d.applyStyle({left:c.colW*k+c.posLeft,top:b},e.extend(true,{},h.animationOptions));for(f=0;f<m;f++)c.colY[k+f]=i},setup:function(d,b,a){g.getBricks(d,a,b);if(a.masoned)a.previousData=
d.data("masonry");a.colW=b.columnWidth===undefined?a.masoned?a.previousData.colW:a.$bricks.outerWidth(true):b.columnWidth;a.colCount=Math.floor(d.width()/a.colW);a.colCount=Math.max(a.colCount,1)},arrange:function(d,b,a){var c;if(!a.masoned||b.appendedContent!==undefined)a.$bricks.css("position","absolute");if(a.masoned){a.posTop=a.previousData.posTop;a.posLeft=a.previousData.posLeft}else{d.css("position","relative");var h=e(document.createElement("div"));d.prepend(h);a.posTop=Math.round(h.position().top);
a.posLeft=Math.round(h.position().left);h.remove()}if(a.masoned&&b.appendedContent!==undefined){a.colY=a.previousData.colY;for(c=a.previousData.colCount;c<a.colCount;c++)a.colY[c]=a.posTop}else{a.colY=[];for(c=a.colCount;c--;)a.colY.push(a.posTop)}e.fn.applyStyle=a.masoned&&b.animate?e.fn.animate:e.fn.css;b.singleMode?a.$bricks.each(function(){var i=e(this);g.placeBrick(i,a.colCount,a.colY,a,b)}):a.$bricks.each(function(){var i=e(this),f=Math.ceil(i.outerWidth(true)/a.colW);f=Math.min(f,a.colCount);
if(f===1)g.placeBrick(i,a.colCount,a.colY,a,b);else{var k=a.colCount+1-f,m=[];for(c=0;c<k;c++){var p=a.colY.slice(c,c+f);m[c]=Math.max.apply(Math,p)}g.placeBrick(i,k,m,a,b)}});a.wallH=Math.max.apply(Math,a.colY);d.applyStyle({height:a.wallH-a.posTop},e.extend(true,[],b.animationOptions));a.masoned||setTimeout(function(){d.addClass("masoned")},1);l.call(a.$bricks);d.data("masonry",a)},resize:function(d,b,a){a.masoned=d.data("masonry")!==null;var c=d.data("masonry").colCount;g.setup(d,b,a);a.colCount!=
c&&g.arrange(d,b,a)}};return this.each(function(){var d=e(this),b={};b.masoned=d.data("masonry")!==null;var a=b.masoned?d.data("masonry").options:{},c=e.extend({},e.fn.masonry.defaults,a,j),h=a.resizeable;b.options=c.saveOptions?c:a;l=l||function(){};g.getBricks(d,b,c);if(!b.$bricks.length)return this;g.setup(d,c,b);g.arrange(d,c,b);!h&&c.resizeable&&e(window).bind("smartresize.masonry",function(){g.resize(d,c,b)});h&&!c.resizeable&&e(window).unbind("smartresize.masonry")})};e.fn.masonry.defaults=
{singleMode:false,columnWidth:undefined,itemSelector:undefined,appendedContent:undefined,saveOptions:true,resizeable:true,animate:false,animationOptions:{}}})(jQuery);

/*
// Infinite Scroll jQuery plugin
// copyright Paul Irish, licensed GPL & MIT
// version 1.5.100504

// home and docs: http://www.infinite-scroll.com
*/

(function(a){a.fn.infinitescroll=function(n,i){function f(){b.debug&&window.console&&console.log.call(console,arguments)}function k(){return b.localMode?a(c.container)[0].scrollHeight&&a(c.container)[0].scrollHeight:a(document).height()}function l(){c.loadingMsg.find("img").hide().parent().find("div").html(b.donetext).animate({opacity:1},2E3,function(){a(this).parent().fadeOut("normal")});b.errorCallback()}function o(){if(c.isDone){l();return false}else{var d=g.children().get();if(d.length==0)return a.event.trigger("ajaxError",
[{status:404}]);for(;g[0].firstChild;)j.appendChild(g[0].firstChild);a(b.contentSelector)[0].appendChild(j);c.loadingMsg.fadeOut("normal");if(b.animate){var e=a(window).scrollTop()+a("#infscr-loading").height()+b.extraScrollPx+"px";a("html,body").animate({scrollTop:e},800,function(){c.isDuringAjax=false})}i.call(a(b.contentSelector)[0],d);if(!b.animate)c.isDuringAjax=false}}a.browser.ie6=a.browser.msie&&a.browser.version<7;var b=a.extend({},a.infinitescroll.defaults,n),c=a.infinitescroll,g,j;i=i||
function(){};if(!function(d){for(var e in d){if(e.indexOf&&e.indexOf("Selector")>-1&&a(d[e]).length===0){f("Your "+e+" found no elements.");return false}return true}}(b))return false;c.container=b.localMode?this:document.documentElement;b.contentSelector=b.contentSelector||this;b.loadMsgSelector=b.loadMsgSelector||b.contentSelector;var m=/(.*?\/\/).*?(\/.*)/,h=a(b.nextSelector).attr("href");if(h){h=function(d){d.match(m)&&d.match(m);if(d.match(/^(.*?)\b2\b(.*?$)/))d=d.match(/^(.*?)\b2\b(.*?$)/).slice(1);
else if(d.match(/^(.*?)2(.*?$)/)){if(d.match(/^(.*?page=)2(\/.*|$)/))return d=d.match(/^(.*?page=)2(\/.*|$)/).slice(1);f("Trying backup next selector parse technique. Treacherous waters here, matey.");d=d.match(/^(.*?)2(.*?$)/).slice(1)}else{if(d.match(/^(.*?page=)1(\/.*|$)/))return d=d.match(/^(.*?page=)1(\/.*|$)/).slice(1);f("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.");
c.isInvalidPage=true}return d}(h);if(b.localMode)a(c.container)[0].scrollTop=0;c.pixelsFromNavToBottom=k()+(c.container==document.documentElement?0:a(c.container).offset().top)-a(b.navSelector).offset().top;c.loadingMsg=a('<div id="infscr-loading" style="text-align: center;"><img alt="Loading..." src="'+b.loadingImg+'" /><div>'+b.loadingText+"</div></div>");(new Image).src=b.loadingImg;a(document).ajaxError(function(d,e){f("Page not found. Self-destructing...");if(e.status==404){l();c.isDone=true;
a(b.localMode?this:window).unbind("scroll.infscr")}});a(b.localMode?this:window).bind("scroll.infscr",function(){if(!(c.isDuringAjax||c.isInvalidPage||c.isDone)){var d=0+k()-(b.localMode?a(c.container).scrollTop():a(c.container).scrollTop()||a(c.container.ownerDocument.body).scrollTop())-a(b.localMode?c.container:window).height();f("math:",d,c.pixelsFromNavToBottom);d-b.bufferPx<c.pixelsFromNavToBottom&&a(document).trigger("retrieve.infscr")}}).trigger("scroll.infscr");a(document).bind("retrieve.infscr",
function(){c.isDuringAjax=true;c.loadingMsg.appendTo(b.loadMsgSelector).show();a(b.navSelector).hide();c.currPage++;f("heading into ajax",h);g=a(b.contentSelector).is("table")?a("<tbody/>"):a("<div/>");j=document.createDocumentFragment();g.load(h.join(c.currPage)+" "+b.itemSelector,null,o)});return this}else f("Navigation selector not found")};a.infinitescroll={defaults:{debug:false,preload:false,nextSelector:"div.navigation a:first",loadingImg:"http://www.infinite-scroll.com/loading.gif",loadingText:"<em>Loading the next set of posts...</em>",
donetext:"<em>Congratulations, you've reached the end of the internet.</em>",navSelector:"div.navigation",contentSelector:null,loadMsgSelector: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);


$(document).ready(function(){
var $wall = $('section');
//Masonry
	$wall.masonry({
		singleMode: true,
		/* animate: true, */
		resizeable: true,
		itemSelector : 'article'
		/* ,itemSelector: 'article:visible' */
	});
//Infinite scroll
	$wall.infinitescroll({
		navSelector  : '#olderNewer',  // selector for the paged navigation 
		nextSelector : '#olderNewer a.older',  // selector for the NEXT link (to page 2)
		itemSelector : 'article',     // selector for all items you'll retrieve
		loadingImg : '/images/ajaxloader.gif',
		donetext  : 'No more pages to load.',
		debug: true,
		errorCallback: function() { 
			// fade out the error message after 2 seconds
			$('#infscr-loading').animate({opacity: .8},2000).fadeOut('normal');   
		}
		},
		// call masonry as a callback
		function( newElements ) { 
			$(this).masonry({ appendedContent: $( newElements ) }); 
		}
	);
	/* $('p.pastOrFuture.list').hide(); */
});//doc.ready
