$.preLoadImages(
     [
          'img/header.png',
          'img/footer.png',
          'img/main.jpg',
		  'img/work.jpg',
		  'img/nav.jpg'
     ],function(){
          gogogo()
     }
);

function gogogo() {
		
	// Prepare...
	$('#load').fadeOut(1000);
	$('#wrap').show()
	$('#shadow').css({opacity:0, top:120}).show()
	$('#vcard').css({opacity:0, top:5}).show()
	$('#wrap > *').css({opacity:0})
	$('#portfolio ul').hide()
	
	//Prepare yourself!

	//Let the Show Begin
	$('body').animate({opacity:1}, 1300, function() {
		$('#header').css({opacity:0, top:-100}).animate({opacity:1, top:0}, 300)
		$('#nav').css({opacity:0}).animate({opacity:0}, 300, function() { $(this).animate({opacity:1}, 300) })
		$('.main').css({opacity:0, left:-100}).animate({opacity:0}, 600, function() { $(this).animate({opacity:1, left:0}, 300) })
		$('#website').css({opacity:0, right:-100}).animate({opacity:0}, 900, function() { $(this).animate({opacity:1, right:0}, 300) })
		$('#footer').css({opacity:0}).animate({opacity:0}, 1200, function() { $(this).animate({opacity:1}, 300) })
		$('#shade').css({opacity:0}).animate({opacity:0}, 1500, function() {
			$(this).animate({opacity:1}, 1000, function() {
				$('#shadow').animate({opacity:1, top:80})
				$('#vcard').animate({opacity:1, top:45})
				//Nav
				$(function() { $("#nav").lavaLamp({ fx: "backout", speed: 700 })});	

				//Work
				$('#portfolio ul').show().aviaSlider({
					blockSize: {height: 'full',width:44},
					transition: 'drop',
					switchMovement: true,
					appendControlls: '#port',
					showText: true,
					autorotation: true,
					animationSpeed:500,
					backgroundOpacity:1
				});	
				//Work
				$('#website.home ul').cycle({timeout:8000})
				//Testimonials
				$('#testy li a').click( function() {
					var dex = $('#testy li a').index(this);
					$('#ttt li').hide().eq(dex).fadeIn();
					$('#testy li a').removeClass('active')
					$(this).addClass('active')
					return false;
				})

			})
		})
	})
					
	//Tooltips
	$('#services li, #sw, #location').mouseenter( function() {
		$('.tooltip').stop(1,1).hide();
		$('.tooltip', this).show();
		$(this).css({color:'#fff'})
	})
	$('#services li, #sw, #location').mouseleave( function() {
		$('.tooltip').fadeOut(200);
		$(this).css({color:''})		
	})
		
	//Form
	var name = $('.txt').eq(0).val()
	var email = $('.txt').eq(1).val()
	var subject = $('.txt').eq(2).val()
	$('.txt').eq(0).focus( function () { if( $(this).val()==name ) { $(this).attr('value','') } })
	$('.txt').eq(1).focus( function () { if( $(this).val()==email ) { $(this).attr('value','') } })
	$('.txt').eq(2).focus( function () { if( $(this).val()==subject ) { $(this).attr('value','') } })
	$('.txt').eq(0).blur( function () { if( $(this).val()=='' ) { $(this).attr('value',name) } })
	$('.txt').eq(1).blur( function () { if( $(this).val()=='' ) { $(this).attr('value',email) } })
	$('.txt').eq(2).blur( function () { if( $(this).val()=='' ) { $(this).attr('value',subject) } })
	
	//Cufon
	Cufon.replace('h3, #portfolio span strong', {
		color: '-linear-gradient(#ccc, #999)'
	});	
	Cufon.replace('#nav', {hover: true});
	
	//Lightbox
	$("#portfolio li a.pp").prettyPhoto({
		showTitle: false, /* true/false */
		allowresize: true,
		theme: 'dark_rounded' /* true/false */
	});
	
	//Resume
	$('#clk').click( function() {
		$('#vcard, #shadow').stop(1,1)
		$('#vcard').animate({top:'-=25'}, 200)
		$('#vcard').stop(1,1).animate({top:'+=25'}, 800, 'bounceout')
		$('#shadow').animate({top:'+=5', opacity:.25}, 200)
		$('#shadow').stop(1,1).animate({top:'-=5', opacity:1}, 800, 'bounceout')
	})

}
