function cookie_encode(a){var b=encodeURIComponent(a);var c=b.replace(/(%7B|%7D|%3A|%22|%23|%5B|%5D)/g,function(a){return decodeURIComponent(a)});return c}jQuery.cookie=function(a,b,c){if(arguments.length>1&&String(b)!=="[object Object]"){c=jQuery.extend({},c);if(b===null||b===undefined){c.expires=-1}if(typeof c.expires==="number"){var d=c.expires,e=c.expires=new Date;e.setDate(e.getDate()+d)}b=String(b);return document.cookie=[encodeURIComponent(a),"=",c.raw?b:cookie_encode(b),c.expires?"; expires="+c.expires.toUTCString():"",c.path?"; path="+c.path:"",c.domain?"; domain="+c.domain:"",c.secure?"; secure":""].join("")}c=b||{};var f,g=c.raw?function(a){return a}:decodeURIComponent;return(f=(new RegExp("(?:^|; )"+encodeURIComponent(a)+"=([^;]*)")).exec(document.cookie))?g(f[1]):null}


jQuery(document).ready(function($) {
	// textbox wipe
	$( '#searchform input' ).click(function(){
			$(this).val('');
	});
	
	// custom select box
	$("select").selectBox();
	
	// post image slider
	$('.post-image').anythingSlider({
		autoPlay	:false,
		animationTime	: 200
	});
	
	$('.post-image img').click(function() {
		$(this).parent().parent().data('AnythingSlider').goForward();
	});
	
	// advent shiznit
	
	if($('#post-' + ADVENT_DATE.join('-')).length == 0) {
		$('.home #post-list li:first .entry-title').show();
		$('.home #post-list li:first p').show();
		$('.home #post-list li:first figure').css('visibility', 'visible');
		return;
	}
	
	$('#post-' + ADVENT_DATE.join('-')).each(function() {
	
		return false;
	
		var me = $(this);
		
		if($.cookie('advent')) {
			me.find('.entry-title').show();
			me.find('p').show();
			me.find('figure').css('visibility', 'visible');
			return false;
		}
		
		var date = ADVENT_DATE[0];
		
		me.find('.entry-title a').hide();
		me.find('.entry-title').append('<span>Day ' + new Date().getUTCDate() + '</span>').show();
		
		var box = $('<div class="advent"><span class="click">Click here to view</span><br /><span class="day">day</span><br /><span class="date">'+date+'</span></div>');
		me.find('.anythingWindow').prepend(box);

		me.find('figure').css('visibility', 'visible');
		
		box.click(function() {
			me.find('.entry-title span').remove();
			me.find('.entry-title a').show();
			me.find('p').show();
			$(this).animate({opacity: 0}, 300, function() {
				$(this).remove();
			});
			$.cookie('advent', '1');
		});
	});
	
});	
