$(document).ready(function() {
	/*SUPERSIZED GALLERY*/
jQuery(function($){
				$.supersized({
				
					//Functionality
					slideshow               :   1,		//Slideshow on/off
					autoplay				:	1,		//Slideshow starts playing automatically
					start_slide             :   10,		//Start slide
					slide_interval          :   10000,	//Length between transitions
					transition              :   1, 		//0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
					transition_speed		:	500,	//Speed of transition
					new_window				:	0,		//Image links open in new window/tab
					pause_hover             :   0,		//Pause slideshow on hover
					keyboard_nav            :   0,		//Keyboard navigation on/off
					performance				:	3,		//0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)
 
					//Size & Position
					min_width		        :   0,		//Min width allowed (in pixels)
					min_height		        :   0,		//Min height allowed (in pixels)
					vertical_center         :   1,		//Vertically center background
					horizontal_center       :   0,		//Horizontally center background
					fit_portrait         	:   0,		//Portrait images will not exceed browser height
					fit_landscape			:   1,		//Landscape images will not exceed browser width
					
					//Components
					navigation              :   0,		//Slideshow controls on/off
					thumbnail_navigation    :   0,		//Thumbnail navigation
					slide_counter           :   0,		//Display slide numbers
					slide_captions          :   0,		//Slide caption (Pull from "title" in slides array)
			slides : [
				{image : 'img/slides/slide1.jpg', title : 'Orb Chairs'},
				{image : 'img/slides/slide2.jpg', title : 'Cadaques, ES'},
				{image : 'img/slides/slide3.jpg', title : 'Philidelphia, PA'},
				{image : 'img/slides/slide4.jpg', title : 'New Jersey Shore'},
				{image : 'img/slides/slide5.jpg', title : 'Roxbourough, CO'},
				{image : 'img/slides/slide6.jpg', title : 'Montjüich, Barcelona, Catalunya ES'},
				{image : 'img/slides/slide7.jpg', title : 'Leaf Beetle'},
				{image : 'img/slides/slide8.jpg', title : 'Montjich, Barcelona, Catalunya ES'},
				{image : 'img/slides/slide9.jpg', title : 'Modern Couch'},
				{image : 'img/slides/slide10.jpg', title : 'Sagrada Familia, Barcelona, Catalunya ES'},
				{image : 'img/slides/slide11.jpg', title : 'Port Vell, Barcelona, Catalunya ES'},
				{image : 'img/slides/slide12.jpg', title : 'Falling @ Symbols'},
				{image : 'img/slides/slide13.jpg', title : 'City Park, Denver, CO'},
				{image : 'img/slides/slide13.jpg', title : 'iPhone Renders'}
			]
		});

		
			
	});
$(window).load(function() {
	/*CUFON*/
	Cufon.replace('h2, h3, h4');
		
	/*AUTO MODAL*/
	$('.caption .arrow a').addClass('modal');
		
	/*QUICKSAND*/
	$(function() { 
    var $data = $("ul.portfolio").clone();

    $("ul.filter li a").click(function(e) {
        $("ul.filter li a").removeClass("active");    

        var filterClass=$(this).attr('class').split(' ').slice(-1)[0];

        if (filterClass == 'all') {
            var $filteredData = $data.find('li');
        } else {
            var $filteredData = $data.find('li[data-type=' + filterClass + ']');
        }
        $("ul.portfolio").quicksand($filteredData, {
            duration: 800,
            easing: 'easeInOutQuad'
			}, function(){
				Cufon.replace('h2, h3, h4');
				callCaption();
				callNudge();
				callFancybox();
        });

        $(this).addClass("active");
        return false;
    });
	
	/*NUDGE*/
	$(callNudge=function(){
		$('.arrow,#resume .close').nudge({
			property: 'margin',
			direction: 'right',
			amount: -10,
			duration: 400
		});
	});
	});
	
	/*ROTATE*/
	$('.message').rotate({maxAngle:25,minAngle:-55,
		bind:
			[
				{"mouseover":function(){$(this).rotateAnimation(-4);}},
				{"mouseout":function(){$(this).rotateAnimation(0);}}
			]
		});
		
	/*CAPTIONS*/
	$('div.caption').hide();
	$(callCaption=function(){
		$('ul.portfolio li').hover(function(){$(this).find('div.caption').stop(false,true).fadeIn("fast");},function(){$(this).find('div.caption').stop(false,true).fadeOut("slow");});
	});
	
	/*RESUME SHOW/HIDE*/
	$('div.footer div.banner').click(function() {
		$('div#content').fadeOut("fast");
		$('div#resume').fadeIn("fast");
	});
	$('#resume .close').click(function() {
		$('div#resume').fadeOut("fast");
		$('div#content').fadeIn("fast");
	});

	/*IE RENDERING ENGINE HACK*/
	if ($.browser.msie) {
  		//document.execCommand("BackgroundImageCache", false, true);
	   //$('ul.portfolio li div.caption').css('filter', 'alpha(opacity=100)');
	   //$('ul.portfolio li div.caption').css('filter', 'alpha(opacity=80)');
	   //$('#supersized, ul.portfolio li .caption').attr('backgroundColor','#000');
	//  $('#supersized').remove();
	   //$.fn.supersized.options = {slideshow:0}
	   var i;
		for (i in document.images) {
    if (document.images[i].src) {
        var imgSrc = document.images[i].src;
        if (imgSrc.substr(imgSrc.length-4) === '.png' || imgSrc.substr(imgSrc.length-4) === '.PNG') {
            document.images[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='crop',src='" + imgSrc + "')";
        }
    }
}
	}
 
	/*EMAIL SPAM KILLER*/
	$(function() {
   		$('.email').each(function() {
			  var $email = $(this);
			  var address = $email.text()
				 .replace('@%)', '@')
				 .replace('4@!#', '.');
			  $email.html('<a href="mailto:' + address + '">'
				 + address +'</a>');
		});
	});
	
	/*FANCYBOX MODAL*/
	$(callFancybox=function(){
		$(".modal").fancybox({
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'speedIn'		:	600, 
			'speedOut'		:	200, 
			'overlayShow'	:	true
		});
	});
});
});
