var dx={call:function(a,b,c,d){var a="/api/?type=json&method="+a+"."+b,e;for(e in c)c.hasOwnProperty(e)&&(a+="&"+e+"="+c[e]);$.ajax({url:a,dataType:"jsonp",success:d})},flash:function(a){var b=a.height/a.width,c=$(".gallerySingle").width();if(a.width>c)a.width=c,a.height=Math.round(c*b);$(".gallerySingle").flash(a)},featured:function(){var a=0,b=null,c=null,d=1E3/41,e=function(){var b=(new Date).getTime()-c,d=960-(a*240+Math.floor(240*(b/8E3)));$("#featured").css("background-position","-"+d+"px 100%");
b>8E3&&(a++,a>=4?($("#featured li:not(:first)").hide(),$("#featured li:last").show().fadeOut(),a=0):$("#featured li:eq("+a+")").fadeIn(),c=(new Date).getTime())};(function(){$("#featured").find("li:not(:first)").hide();c=(new Date).getTime();b=setInterval(e,d);$("#featured a").mouseover(function(){clearInterval(b);c=(new Date).getTime();e()}).mouseout(function(){b=setInterval(e,d);c=(new Date).getTime()})})()},archives:function(){var a=new Date,b=a.getMonth(),c=a.getFullYear(),d=[31,28,31,30,31,30,
31,31,30,31,30,31],e=["January","February","March","April","May","June","July","August","September","October","November","December"],h=function(a){var i,h,f=b+1+"/1/"+c;if(f=Date.parse(f)){f=new Date(f);f.setDate(1);var g=f.getMonth();i=e[g];h=f.getFullYear();for(var g=g===1?h%4===0?29:28:d[g],m=f.getDay(),j="<table><tbody><tr>",l=0,n=f.getDay(),f=0;f<n;f++)j+='<td class="noDate">&nbsp;</td>';for(f=0;f<g;f++)l=f+m,l%7===0&&(j+="</tr>"),j+='<td class="day'+(f+1)+'">'+(f+1)+"</td>";for(l++;l%7!==0;)j+=
'<td class="noDate">&nbsp;</td>',l++;j+="</tr></tbody></table>";$("#archives div").html(j);$("#archives h3").html(i+" "+h)}if(a.body.count>0){i=0;for(h=a.body.content.length;i<h;i++)g=(new Date(a.body.content[i].date*1E3)).getDate(),$("td.day"+g).addClass("hasPosts")}},g=function(){var a=b+1,d=c,e="",e="";a>12&&(a=1,d++);e=a+"/1/"+d;a+1>12&&(a=0,d++);dx.call("content","getContent",{max:0,noCount:"true",noTags:"true",maxdate:a+1+"/1/"+d,mindate:e,select:"title,perma,date",contentType:"art,video,blog,portfolio"},
h)};$("#archives .control").click(function(a){switch($(a.target).attr("rel")){case "prev":b--;break;case "next":b++}b<0&&(b=11,c--);b>11&&(b=0,c++);g()});g();$("#archives").delegate(".hasPosts","click",function(){var a=(b+1).toString();window.location.href="/archives/"+(a.length<2?"0"+a:a)+"/"+c+"/"})},comments:function(){var a=0,b=0,c=function(a){if(a=$(a.target).attr("rel")){var b=a*30,c=b+30-1;$(".comment").show();$(".comment:gt("+c+")").hide();$(".comment:lt("+b+")").hide();$(".commentPages .selected").removeClass("selected");
$('.commentPages [rel="'+a+'"]').addClass("selected")}};$(".commentReply").click(function(a){a=$(a.target).parent().find(".user").text();$("#commentBody").val("@"+a).focus()});(function(){a=$(".commentReply").length;if(a>30){b=Math.ceil(a/30);$(".comment:gt(29)").hide();var d='<ul class="commentPages">',e;for(e=0;e<b;e++)d+='<li><a href="#comments" class="commentPage'+(e===0?" selected":"")+'" rel="'+e+'">'+(e+1)+"</a></li>";d+="</ul>";$("#comments").append(d);$(d).insertAfter("#comments h3");$(".commentPage").click(c)}})()},
gallery:function(){var a=function(a){a.preventDefault();var b=$(a.target).attr("href");b||(b=$(a.target).parents("a:first").attr("href"));b=b.match(/entry\/(.*?)\//)[1];$("#galleryBg").fadeIn(400,function(){var a=b;$("#galleryItem").prepend('<iframe src="/gallery/'+a+'/" id="galleryItem" frameborder="0"></iframe>')});$("#galleryItem").show().animate({width:"800px"})},b=function(){$("#galleryBg").fadeOut();$("#galleryItem").animate({width:0}).fadeOut();$("#galleryItem iframe").remove()};$(function(){$("#gallery a").click(a);
$("#galleryBg").detach().appendTo("body").click(b);$("#galleryItem").css("margin-top",($(window).height()-$("#galleryItem").height())/2+"px");$("#galleryItem .close").click(b)})},poll:function(a){var b=$("#poll"+a),c=function(a){if(typeof a.body.items!=="undefined"&&a.body.items.length>0){var c='<div class="graph"><h4>'+a.body.title+"</h4><ul>",h,g;h=0;for(g=a.body.items.length;h<g;h++){var k=a.body.items[h];c+="<li><span>"+k.title+"</span>"+(k.votes>0?'<div class="bar" style="width:'+k.percent/2+
'%;"></div>':"")+'<div class="data">'+k.percent+"% - "+k.votes+" votes</div></li>"}c+="</ul></div>";b.replaceWith(c)}};b.submit(function(d){d.preventDefault();d=b.find('input[name="poll_option"]:checked').val();dx.call("poll","vote",{id:a,item:d},c)})}};
(function(){var a=function(){var a=!1;$("label.error").removeClass("error");$("#commentName").length&&!$("#commentName").val()&&(a=!0,$('label[for="commentName"]').addClass("error"));if($("#commentEmail").length&&!$("#commentEmail").val())a=!0,$('label[for="commentEmail"]').addClass("error");else if($("#commentEmail").length){var c=$("#commentEmail").val();c.match(/([\w\d]+)@([\w\d]+)\.([\w])/)?$("#botProof").val(hex_md5(c)):a=!0}$("#commentBody").val()||(a=!0,$('label[for="commentBody"]').addClass("error"));
return!a};$(function(){$("#commentForm").submit(a)})})();(function(a){a.fn.video=function(b){this.each(function(){a(this).append('<embed width="610" height="350" src="/global/flash/jcplayer.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" align="middle" play="true" loop="true" scale="noScale" wmode="window" devicefont="false" bgcolor="#ffffff" name="jcplayer" menu="true" allowfullscreen="true" salign="TL" allowscriptaccess="sameDomain" flashvars="videoURL='+b+'&amp;autoHide=true&amp;margins=10&amp;offsetY=35&amp;highlightColor=0xf26716" type="application/x-shockwave-flash" />')})}})(jQuery);
(function(a){a.fn.youtube=function(b){this.each(function(){a(this).append('<embed width="540" height="304" src="http://www.youtube.com/v/'+b+"?enablejsapi=1&playerapiid="+a(this).attr("id")+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" align="middle" wmode="window" llowscriptaccess="sameDomain" type="application/x-shockwave-flash" />')})}})(jQuery);
(function(a){var b=null,c=function(a){var c=b.val();if(c.length>0)window.location="/search/"+c+"/";a.preventDefault()},d=function(){console.log("hey");b.val()=="Search for stuff..."&&b.removeClass("default").val("")},e=function(){b.val()==""&&b.addClass("default").val("Search for stuff...")};a(function(){b=a("#search input");b.addClass("default").blur(e).focus(d).val("Search for stuff...");a("#search form").submit(c)})})(jQuery);$(function(){$(".gallery a").length>0&&$(".gallery a").lightBox()});

/* AND A MERRY CHRISTMAS! 
$(function() {

	var
	
	phrases = 
		[
			'Ho ho ho!<br />Merry Christmas, bitches!',
			'Fuck yeah! PEPSI!',
			'Gave that bitch a present. Bitches love presents.',
			'What I want for christmas is something I haven\'t seen or heard in a long time: Sex.',
			'I\'m drunk as shit',
			'Let\'s go punch a reindeer',
			'Who\'s your daddy?',
			'Wanna get high?'
		],
	
	santaClick = function(e) {
		$('#santa').remove();
		$('#wrapper').css('margin', '0 auto');
	},
	
	init = function() {
		
		$('body').append('<div id="santa"><p>' + phrases[Math.floor(Math.random() * phrases.length)] + '<span>Hide me</span></p><span></div>');
		$('#santa').click(santaClick);
		
	};
	
	init();

}); */
