jQuery(function( $ ){
		//borrowed from jQuery easing plugin
		//http://gsgd.co.uk/sandbox/jquery.easing.php
		$.scrollTo.defaults.axis = 'xy'; 
		$.easing.elasout = function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
		};
});

$(document).ready(function() {
	
	$('.moreinfo, #totop, #loading, #succes, #bademail, #badserver').hide();
	
	// show sub navigation //
	$("#portfolio").mouseover(function(){
      $("#nav").stop().animate({ height: "102px"}, 300 );
    	}).click(function(){
      $("#nav").stop().animate({ height: "35px"}, 300 );
    });
	
	$("#portfolio").toggle(function(){
      $("#nav").stop().animate({ height: "102px"}, 300 );}
	  , function(){ $("#nav").stop().animate({ height: "35px"}, 300 );
	  $('#totop').show();
    });
	
	$("#subnavList").mouseover(function(){
      $("#nav").stop().animate({ height: "102px"}, 300 );
    	}).mouseleave(function(){
      $("#nav").stop().animate({ height: "35px"}, 300 );
    });
	
	$("#nav").mouseout(function(){
      $("#nav").stop().animate({ height: "35px"}, 300 );
    	}).mouseleave(function(){
      $("#nav").stop().animate({ height: "35px"}, 300 );
    });
	
	//// Show sub navigation ////

	
	
	// Show more info about project //
	$(".more").click(function(){ 
      $(this).closest(".block").stop().animate({ height: "320px"}, 300 );
	  $(".moreinfo").fadeIn();
	  $(this).next().show();
	  $(this).hide();
	  return false;
    });
	
	$(".close").click(function(){ 
      $(".block").stop().animate({ height: "146px"}, 300 );
	  $('.moreinfo').fadeOut();
	  $(".close").hide();
	  $(".more").show();
	  return false;
    });

	//// Show more info about project ////
	
	
	// navigation and sub navigation //
	
	$(".scrollAbout").click(function(){
      $.scrollTo( $('#abouttitle'), 1500, {offset:-80, easing:'elasout'} );
	  $('#totop').show();
	  return false;
    });
	
	$(".scrollPortfolio").click(function(){
	  $('#portfolio div.hidden').fadeIn('slow').removeClass('hidden');
      $.scrollTo( $('#selectedproj'), 2000, {offset:-110, easing:'elasout'} );
	  $('#totop').show();
	  return false;
    });
	
	$(".scrollContact").click(function(){
      $.scrollTo( $('#contacttitle'), 1500, {offset:-70, easing:'elasout'}  );
	  $('#totop').fadeIn('slow');
	  return false;
    });
	
	$("#totop").click(function(){
      $.scrollTo( '#quote', 2000, {offset: -85, easing:'elasout'} );
	  $('#totop').fadeOut('slow');
	  return false;
    });
	
	$(".scrollWeb").click(function(){
      $.scrollTo( $('#selectedproj'), 2000, {offset:-110, easing:'elasout'} );
	  $('#totop').fadeIn('slow');
	  return false;
    });
	
	$(".scrollGraphic").click(function(){
      $.scrollTo( $('#selectedproj'), 2000, {offset:-110, easing:'elasout'} );
	  $('#totop').fadeIn('slow');
	  return false;
    });
	
	$(".scrollMotion").click(function(){
      $.scrollTo( $('#selectedproj'), 2000, {offset:-110, easing:'elasout'} );
	  $('#totop').fadeIn('slow');
	  return false;
    });
	
	$(".scrollInteractive").click(function(){
      $.scrollTo( $('#selectedproj'), 2000, {offset:-110, easing:'elasout'} );
	  $('#totop').fadeIn('slow');
	  return false;
    });

	//// navigation and sub navigation ////
	
	// Portfolio filtering //
	$('ul#subnavList a').click(function() {
		$(this).css('outline','none');
		$('ul#subnavList .current').removeClass('current');
		$(this).parent().addClass('current');
		
		var filterVal = $(this).text().toLowerCase().replace(' ','-');
				
		if(filterVal == 'portfolio') {
			$('#portfoliowrap div.hidden').fadeIn('slow').removeClass('hidden');
		} else {
			
			$('#portfoliowrap .project').each(function() {
				if(!$(this).hasClass(filterVal)) {
					$(this).fadeOut('slow').addClass('hidden');
				} else {
					$(this).fadeIn('slow').removeClass('hidden');
				}
			});
		}
		
		return false;
	});
	//// Portfolio filtering ////
	
	// Contact form handeling //
	$('#submitinput').click(function() {
		$('#loading').fadeIn(100);
		$('#bademail').fadeOut();
		$('#badserver').fadeOut();
		$('#succes').fadeOut();
		});
		
		$('#myForm').ajaxForm(function(data) {
		if (data==1){
		$('#loading').fadeOut('fast');
		$('#succes').fadeIn();
		$('#myForm').resetForm();
		}
		else if (data==2){
		$('#loading').fadeOut();
		$('#badserver').fadeIn();
		}
		else if (data==3)
		{
		$('#loading').fadeOut();
		$('#bademail').fadeIn();
		}
	});
	//// Contact form handeling ////

	// Clearing formfields on focus //
	$("#nameinput, #emailinput, #commentinput, #checkinput").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
		}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
	/// Clearing formfields on focus ////

	// Parallax effect in the header //
	jQuery('#parallax').jparallax({mouseport: jQuery('body'), yparallax: false});
	jQuery('#parallaxtop').jparallax({mouseport: jQuery('body'), yparallax: false});
	/// Parallax effect in the header ///
	
	// fading images and quotes with innerfade //
	$('#quoteList').innerfade({ speed: 'slow', timeout: 10000, type: 'random' });
	$('.fade').innerfade({ speed: 'slow', timeout: 5000, type: 'random' }); 
	//// fading images and quotes with innerfade ////
	
	$('a[rel*=facebox]').facebox();
	
	$("#facebox").click(function(){
		$(document).trigger('close.facebox');
	  return false;
    });
	
});

// twitter script settings //
$(document).ready(function(){
	$(".tweet").tweet({
		join_text: "auto",
		count: 3,
		auto_join_text_default: "I said:<br />",
		auto_join_text_ed: "I",
		auto_join_text_ing: "I was",
		auto_join_text_reply: "I replied:<br />",
		auto_join_text_url: "I was checking out",
		loading_text: "Loading tweets..."
	});
	
	jQuery(function() {

    jQuery.getFeed({
        url: 'proxy.php?url=http://madebymice.tumblr.com/rss',
        success: function(feed) {
           
            var html = '';

            for(var i = 0; i < feed.items.length && i < 3; i++) {
            
                var item = feed.items[i];
                
                html += '<h3 class="title">'
                + '<a href="'
                + item.link
                + '">'
                + item.title
                + '</a>'
                + '</h3>';

                html += '<div class="date">'
                + item.updated
                + '</div>';

                html += '<div class="post">'
                + item.description
                + '</div>';
            }
			
            
			
            jQuery('#result').append(html);
			
			$('div.date').each(function(){
  			var $div = $(this);
  			$div.text( $div.text().slice(0, -9) );
			});
			
        }    
    });
});
	
});
//// twitter script settings ////

// Random quote without page refresh //
function getRandom() {
$("#quote").fadeOut("slow");
$(".quote").load("randomquote.php", '', callback);
}

function callback() {
$("#quote").fadeIn("slow");
setTimeout("getRandom();", 10000);
}

$(document).ready(getRandom);
// Random quote without page refresh //
		





