$.loader (
[
	// Init nav menu
	function () { $('#nav').hmenu (); },

	// Init tabs
	function () { $('#featured').tabs (); },

	// Comment form enhancements
	function ()
	{
		var submit = $('#respond #submit'); if (!submit.length) return;
		submit.children('input').css ({'display':'none'});
		$('<a href="#respond" tabindex="5"><span>Submit Comment</span></a>')
			.click (function () { submit.children('input').click (); return false; })
			.prependTo (submit)
		;
	},

	// Enable & attach AddThis widget
	function ()
	{
		if (!window.addthis_conf) return; // Exit if AddThis widget not loaded
		$('#content .post').each (function ()
		{
			var post = $(this);
			var link = post.find ('.header h2 a').eq (0);
			post.find ('a.addthis')
				.hover (
					function () { return addthis_open (this, '', escape(link.attr('href')), escape(link.text())); },
					function () { addthis_close (); }
				)
				.click (function () { return addthis_sendto (); });
		});
	},
	
	// Rotate GAX Point Vids thumbnails
	function ()
	{
		$('#featured .vid-list .vid-thumb img').each (function () 
		{
			var key = false, img = $(this), index = 0;
			if (key = img.attr('src').match(/http:\/\/img\.youtube\.com\/vi\/([^\/]+)\/0\.jpg/)[1])
				startVidSlideshow ();
			
			function startVidSlideshow () 
			{ 
				img.attr ('src', 'http://i3.ytimg.com/vi/'+key+'/'+index+'.jpg');
				index = (index+1)%3;
				setTimeout (arguments.callee, 5000 + 5000*Math.random()); 
			}
		})
	}
]);

function setCookie(c_name,value,expiredays){
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie = c_name+ "=" +escape(value)+";path=/"+((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

