/* 
 * 
 * Last Modified : 12 July 2010 13:22:56 GMT+1
 * 
 */

$(function() {
	
	/* 
	 * 
	 * External Links
	 * 
	 * * * * * * * * * * * * * * * * * * * * */
	
	$('a[rel=external]').click(function(e) {
		open(this.href);
		e.preventDefault();
	}).attr('title', 'Opens in a new window');
	
	/* 
	 * 
	 * Last List Item
	 * 
	 * * * * * * * * * * * * * * * * * * * * */
	
	$('li:last-child').addClass('last-item');
	
	/* 
	 * 
	 * Manipulate Umbraco's image alignment
	 * 
	 * * * * * * * * * * * * * * * * * * * * */
	
	$('#content img').each(function(e) {
		if ($(this).css('float') == 'left') {
			$(this).addClass('left');	
		}
		else if ($(this).css('float') == 'right') {
			$(this).addClass('right');
		}
	});
	
	/* 
	 * 
	 * It's The Final Countdown
	 * 
	 * * * * * * * * * * * * * * * * * * * * */
	
	$('.timer').fliptimer({
		year    : 2011,
		month   : 10,
		days    : 9,
		hours   : 9,
		minutes : 30
	});
	
	/* 
	 * 
	 * Content, Headings
	 * 
	 * * * * * * * * * * * * * * * * * * * * */
	
	$('#content h1').append('<span></span>');
	$('#content h3').append('<span></span>');
	
	/* 
	 * 
	 * Gallery
	 * 
	 * * * * * * * * * * * * * * * * * * * * */
	
	$('#content .gallery ul li.image a').fancybox({
		titlePosition : 'over',
		transitionIn  : 'elastic',
		transitionOut : 'elastic',
		type          : 'image'
	});
	
	$('#content .gallery ul li.video a').append('<span></span>');
	
	$('#content .gallery ul li.video a').click(function() {
		$.fancybox({
			autoScale     : false,
			height        : 495,
			href          : this.href.replace(new RegExp('watch\\?v=', 'i'), 'v/'),
			swf           : {
				allowfullscreen	: 'true',
				wmode          : 'transparent'
			},
			titlePosition : 'none',
			transitionIn  : 'elastic',
			transitionOut : 'elastic',
			type          : 'swf',
			width         : 680
		});
		return false;
	});
	
	/* 
	 * 
	 * Datepicker
	 * 
	 * * * * * * * * * * * * * * * * * * * * */
	$('.datepicker').datepicker({
		buttonImage     : '/images/calendar_16.png',
		buttonImageOnly : true,
		changeMonth     : true,
		changeYear      : true,
		dateFormat      : 'dd-mm-yy',
		direction       : 'left',
		showOn          : 'both',
		yearRange       : '1930:2000'
	});
	
});