$(document).ready(function() {
	
	// Add platform classes
	if (navigator.appVersion.indexOf("Mac")!=-1) {
	$('html').addClass('mac');
	} else {
		$('html').addClass('pc');
	}
	
	// Reduce FOUT in Firefox
	if($.browser.mozilla){
		$("body").addClass("moz-loading");
		$(window).load(function() {
			$("body").removeClass("moz-loading",300);			
			});
		};
		
	$('body.home').parent().addClass('front');
		
	// adds hooks to the first and last list items
  	$("ul li:first-child").addClass("first-item");
	$("ul li:last-child").addClass("last-item");
	$("ol li:first-child").addClass("first-item");
	$("ol li:last-child").addClass("last-item");
	$(".related a:last-child").addClass("last-item");
	$("#content div.post:first").addClass("first-item");
	$("#content div.post:last").addClass("last-item");
	$("#content .entry h2:first-child").addClass("first-item");
			
	// cleans up nasty shit from WYSIWYG
	$('p').removeAttr('style');
	$('span').removeAttr('style');
	
	// Object Wrapper 
	$('#content object').wrap('<div class="embed" />');
	
	// applies image alignment classes in the content areas
	$("#content img").each(function(index){
	     if ($(this).css('float') == 'left') {
	         $(this).addClass('img-left');
	     } else if ($(this).css('float') == 'right') {
	         $(this).addClass('img-right');
	     }
	});
	
	$('li.project').click(function(){
	  	window.location=$(this).find("a").attr("href"); return false;
	});

	$('li.project .entry p').append('&hellip;&nbsp;<a class="read_more">More</a>'); 
	
	// Add classes to links what link to images
	$('#content .entry a[href$="jpeg"], #content .entry a[href$="gif"], #content .entry a[href$="jpg"], #content .entry a[href$="png"]').addClass('image');
	
	// Add classes to links what link to pdfs
	$('#content .entry a[href$=".pdf"]').addClass('pdf file btn');
	
	// Add classes to links what link to archives
	$('#content .entry a[href$=".zip"]').addClass('zip file btn');
	
	
	// Stops linking to .taxonomy page until these are required
	$('.project ul.meta li a').click(function(event) {
		  event.preventDefault();
		});	
	
	// Spans for zoom and movie icons
	$('a.image').append('<span class="icon"> Larger Image</span>');
	$('a.video').append('<span class="caption"> Watch the trailer</span><span class="icon"> Play</span>');
	
	$("a.image").fancybox({
				'overlayColor'	: '#000',
				'overlayOpacity': 0.7
				});			
	
	$("a.video").click(function() {
		$.fancybox({
				'padding'		: 4,
				'autoScale'		: false,
				'transitionIn'	: 'none',
				'transitionOut'	: 'none',
				'titleShow'		: false,
				'overlayColor'	: '#000',
				'overlayOpacity': 0.7,
				'width'			: 680,
				'height'		: 495,
				'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
				'type'			: 'swf',
				'swf'			: {
				   	 'wmode'		: 'transparent',
					'allowfullscreen'	: 'true'
				}
			});

		return false;
	});
		
	$('.entry a').filter(function() {
		return this.hostname && this.hostname !== location.hostname;
		}).addClass('external');		
	
	
});


