$(document).ready( function() {

	// MODAL BOX SYSTEM (COLORBOX)
	$(".facebook_share").colorbox({ width:"800px", height:"55%", iframe:true, scrolling:false });
		
	// BUTTONS BACKGROUND EFFECT
	$('.wave_effect a')
	.css( {backgroundPosition: "-20px 35px"} )
	.mouseover(function(){
		$(this).stop().animate({backgroundPosition:"(-20px 94px)"}, {duration:500})
	})
	.mouseout(function(){
		$(this).stop().animate({backgroundPosition:"(40px 35px)"}, {duration:200, complete:function(){
			$(this).css({backgroundPosition: "-20px 35px"})
		}})
	})

	// SMOOTH SCROLLING
	$('#portfolio').localScroll();
	$('#footer').localScroll();

	//
	$('#header_logo').click(function() {
		$('#header_headline').effect('shake', {}, 70);
	});

	// ON PAGE RELOAD
	if (document.location.hash == '#nav-contact') {
		$( 'li#nav_contact' ).addClass( 'current' );
	}

	if (document.location.hash.split('-',1) == '#portfolio') {
		$( 'li#nav_portfolio' ).addClass( 'current' );
	}
	
	// DOWNLOAD RESUME
	if ($(window).width() > '1200') {
		$( '#download_resume' ).show();
		$( '#download_resume' ).click( function () {
			alert('Not ready yet, sorry about that.');
		} );
		$( '#download_resume_button' ).click( function () {
			alert('Not ready yet, sorry about that.');
		} );
		$( '#download_resume_heading' ).click( function () {
			alert('Not ready yet, sorry about that.');
		} );
	}
	$( '#download_resume_button' ).show();
	
	// PORTFOLIO PREVIEW INITIALIZATION
	$( '#prev' ).show();
	$( '#next' ).show();
    $(".carousel").jCarouselLite({
        btnNext: "#next",
        btnPrev: "#prev",
        visible: 2,
        scroll: 1,
        mouseWheel: false,
		speed: 200,
		circular: true,
		auto: 5000
    });

	// NAVIGATION MENU ACTIONS
	$( '#nav_home' ).click( show_home );
	$( '#nav_portfolio' ).click( show_portfolio );
	$( '#nav_skills_and_services' ).click( show_skills_and_services );
	$( '#nav_contact' ).click( show_contact );
	$( '#about_contact_link' ).click( show_contact );
	$( '#footer_contact_link' ).click( show_contact );
	$( '.portfolio_preview_link' ).click ( show_portfolio_project );
	$( '.portfolio_preview_desc' ).click ( show_portfolio_project );
		

	// NAVIGATION MENU INITIALIZATION
	$(".lavaLamp").lavaLamp({ fx: "backout", speed: 700})	
	    
	// SKILLS INITIALIZATION
	$( '#skills_more_button' ).show();
	$( '.skills_more' ).hide();
	$( '#skills_more_button' ).click( toggle_skills );

	// SERVICES INITIALIZATION
	$( '#services_more_button' ).show();
	$( '.services_more' ).hide();
	$( '#services_more_button' ).click( toggle_services );

	// PORTFOLIO INITIALIZATION
	$( '#portfolio' ).hide();

	// CONTACT INITIALIZATION
	$( '#contact' ).hide();

	// CONTACT FORM FEEDBACK
	$( '#feedback' ).hide().fadeIn( 1000, function() {
		$(this).effect("shake", {}, 100);
	} );
	
	// ABOUT INITIALIZATION
	$( '#about_more_button' ).show();
	$( '#about_more' ).hide();	
	$( '#about_more_button' ).click( toggle_about );


	// NAVIGATION MENU HIGHLIGHTING
	if (document.location.hash == '#nav-contact') {
		$( '#portfolio_preview' ).hide();
		$( '#skills' ).hide();
		$( '#services' ).hide();
		$( '#portfolio' ).hide();
		$( '#contact' ).show();
	}

	if (document.location.hash.split('-',1) == '#portfolio') {
		$( '#portfolio_preview' ).hide();
		$( '#skills' ).hide();
		$( '#services' ).hide();
		$( '#contact' ).hide();
		$( '#portfolio' ).show();
	}


} );


function show_home() {
	$( '#contact' ).slideUp( 600, function() {
		$( '#portfolio' ).slideUp( 600, function() {
			$( '#skills' ).slideUp( 600 );
			$( '#services' ).slideUp( 600, function() {
				$( '#portfolio_preview' ).slideUp( 600, function() {
					$( '#portfolio_preview' ).slideDown( 600, function() {
						$( '#link_toggle_skills' ).show();
						$( '#link_toggle_services' ).show();
						$( '.extra_skills' ).hide();
						$( '.extra_services' ).hide();
						$( '#skills' ).slideDown( 600 );
						$( '#services' ).slideDown( 600 );
					} );				
				} );
			} );			
		} );		
	} );
}


function show_portfolio() {
	$( '#contact' ).slideUp( 600, function() {
		$( '#portfolio' ).slideUp( 600, function() {
			$( '#skills' ).slideUp( 600 );
			$( '#services' ).slideUp( 600, function() {
				$( '#portfolio_preview' ).slideUp( 600, function() {
					$( '#portfolio' ).slideDown( 5000 );
				} );
			} );			
		} );		
	} );
}


function show_portfolio_project() {
		$( '#portfolio_preview' ).css( 'display' , 'none' );
		$( '#skills' ).css( 'display' , 'none' );
		$( '#services' ).css( 'display' , 'none' );
		$( '#contact' ).css( 'display' , 'none' );
		$( '#portfolio' ).css( 'display' , 'block' );
		$( 'li#nav_portfolio' ).addClass( 'current' );
}

function show_skills_and_services() {
	$( '#contact' ).slideUp( 600, function() {
		$( '#portfolio' ).slideUp( 600, function() {
			$( '#skills' ).slideUp( 600 );
			$( '#services' ).slideUp( 600, function() {
				$( '#portfolio_preview' ).slideUp( 600, function() {
					$( '#skills_more_button a' ).hide();
					$( '#services_more_button a' ).hide();
					$( '#skills' ).slideDown( 600, function() {
						$( '.skills_more' ).slideDown( 300 );
					});
					$( '#services' ).slideDown( 600, function() {
						$( '.services_more' ).slideDown( 300 );
					});				
				} );
			} );			
		} );		
	} );
}	


function show_contact() {
	$( '#contact' ).slideUp( 600, function() {
		$( '#portfolio' ).slideUp( 600, function() {
			$( '#skills' ).slideUp( 600 );
			$( '#services' ).slideUp( 600, function() {
				$( '#portfolio_preview' ).slideUp( 600, function() {
					$( '#contact' ).slideDown( 600 );
				} );
			} );			
		} );		
	} );
}

function toggle_skills() {
	if ( $( '.skills_more' ).css('display') == 'block' ) {
		$( '#skills_more_button a' ).html( '> extended <span style="color:#fd800a;">list...</span>' );
	} else {
		$( '#skills_more_button a' ).html( '> ...reduced <span style="color:#fd800a;">list</span>' );
	}
	$( '.skills_more' ).slideToggle( 600 );
	return false;
}


function toggle_services() {
	if ( $( '.services_more' ).css('display') == 'block' ) {
		$( '#services_more_button a' ).html( '> extended <span style="color:#fd800a;">list...</span>' );
	} else {
		$( '#services_more_button a' ).html( '> ...reduced <span style="color:#fd800a;">list</span>' );
	}
	$( '.services_more' ).slideToggle( 600 );
	return false;
}


function toggle_about() {
	if ( $( '#about_more' ).css('display') == 'block' ) {
		$( '#about_more_button a' ).html( '> read more <span style="color:#fd800a;">about me</span>' );
	} else {
		$( '#about_more_button a' ).html( '> ok, less <span style="color:#fd800a;">about me</span>' );
	}
	$( '#about_more' ).slideToggle( 600 );
	return false;
}

