// JavaScript Document

	$(document).ready(function() {
		
		////////////////////////
		///                  ///
		/// GLOBAL VARIABLES ///
		///                  ///
		////////////////////////
		
			easingNav = 'easeOutQuart';
			easingSlide = 'easeInOutExpo';
			easingShare = 'easeOutQuart';
			
			
		//////////////////
		///            ///
		/// NAVIGATION ///
		///            ///
		//////////////////

			$('#nav_welcome')
			
				.css({ backgroundPosition: "0 -51px" })
				
				.mouseover(function(){
					$(this).stop().animate({ backgroundPosition: "0 0" }, { duration: 400, easing: easingNav })
				})
				
				.mouseout(function(){
					$(this).stop().animate({ backgroundPosition: "0 -51px" }, { duration: 800, easing: easingNav })
				})
	
			$('#nav_portfolio')
			
				.css({ backgroundPosition: "0 -51px" })
				
				.mouseover(function(){
					$(this).stop().animate({ backgroundPosition: "0 0" }, { duration: 400, easing: easingNav })
				})
				
				.mouseout(function(){
					$(this).stop().animate({ backgroundPosition: "0 -51px" }, { duration: 800, easing: easingNav })
				})
	
			$('#nav_about')
			
				.css({ backgroundPosition: "0 -51px" })
				
				.mouseover(function(){
					$(this).stop().animate({ backgroundPosition: "0 0" }, { duration: 400, easing: easingNav })
				})
				
				.mouseout(function(){
					$(this).stop().animate({ backgroundPosition: "0 -51px" }, { duration: 800, easing: easingNav })
				})
	
			$('#nav_contact')
			
				.css({ backgroundPosition: "0 -51px" })
				
				.mouseover(function(){
					$(this).stop().animate({ backgroundPosition: "0 0"}, { duration: 400, easing: easingNav })
				})
				
				.mouseout(function(){
					$(this).stop().animate({ backgroundPosition: "0 -51px" }, { duration: 800, easing: easingNav })
				})
				
		
		//////////////////
		///            ///
		/// THUMBNAILS ///
		///            ///
		//////////////////
		
			$(".thumb_hover").animate({ opacity: "0" });
		
			$(".thumbnail")
				
				.mouseover(function(){
					$(this).find(".thumb_hover").stop().animate({ opacity: "1" }, {duration: 1600, easing: easingNav });
				})
				
				.mouseout(function(){
					$(this).find("a .thumb_hover").stop().animate({ opacity: "0" }, {duration: 1600, easing: easingNav });
				})
				
		
		//////////////////
		///            ///
		/// IMAGE REEL ///
		///            ///
		//////////////////
		
			$(".slideshow").each(function(){

				// Calculate values of the Image Reel
				
					var imageWidth = $(this).find(".image_container").width();
					var imageAmount = $(this).find(".image_reel img").size();
					var reelWidth = imageWidth * imageAmount;
					
				// Assigned
				
					$(this).find(".image_reel").css({ width: reelWidth });
					
				// Reel Movement/Navigation
						
					$(this).find(".arrow_left").click(function(){
					
						if ($(this).siblings(".image_container").children(".image_reel:animated").length < 1) {
					
							var marginLeft = ($(this).siblings(".image_container").children(".image_reel").css("marginLeft")).replace("px", "");
							marginLeft = marginLeft.replace("-", "");
							
								if (marginLeft >= imageWidth) {
									$(this).siblings(".image_container").children(".image_reel").animate({ marginLeft: "+=" + imageWidth + "" }, { duration: 1400, easing: easingSlide });
								}
							
						}
					
					});
				
					$(this).find(".arrow_right").click(function(){
						
						if ($(this).siblings(".image_container").children(".image_reel:animated").length < 1) {
						
							var marginLeft = ($(this).siblings(".image_container").children(".image_reel").css("marginLeft")).replace("px", "");
							marginLeft = marginLeft.replace("-", "");
							
							var maxMargin = reelWidth - imageWidth;
							
								if (marginLeft < maxMargin) {
									$(this).siblings(".image_container").children(".image_reel").animate({ marginLeft: "-=" + imageWidth + "" }, { duration: 1400, easing: easingSlide });
								}
						
						}
						
					});
				
			});
				
				
		/////////////////////////////
		///                       ///
		/// LANGUAGES TRANSITIONS ///
		///                       ///
		/////////////////////////////
		
			$('#html_css_image').css({ opacity: "0" })
			$('#html_css_image_grey').css({ opacity: "1" })
	
			$('#html_css')
			
				.mouseover(function(){
					$('#html_css_image').stop().animate({ top: "10px", opacity: "1", filter: "alpha(opacity = 100)" }, { duration: 800, easing: easingShare })
					$('#html_css_image_grey').stop().animate({ top: "-67px", opacity: "0", filter: "alpha(opacity = 0)" }, { duration: 800, easing: easingShare })
				})
				
				.mouseout(function(){
					$('#html_css_image').stop().animate({ top: "30px", opacity: "0" }, { duration: 800, easing: easingShare })
					$('#html_css_image_grey').stop().animate({ top: "-47px", opacity: "1" }, { duration: 800, easing: easingShare })
				})
				
			$('#javascript_image').css({ opacity: "0" })
			$('#javascript_image_grey').css({ opacity: "1" })
	
			$('#javascript')
			
				.mouseover(function(){
					$('#javascript_image').stop().animate({ top: "0", opacity: "1" }, { duration: 800, easing: easingShare })
					$('#javascript_image_grey').stop().animate({ top: "-130px", opacity: "0" }, { duration: 800, easing: easingShare })
				})
				
				.mouseout(function(){
					$('#javascript_image').stop().animate({ top: "15px", opacity: "0" }, { duration: 800, easing: easingShare })
					$('#javascript_image_grey').stop().animate({ top: "-110px", opacity: "1" }, { duration: 800, easing: easingShare })
				})
				
			$('#jquery_image').css({ opacity: "0" })
			$('#jquery_grey').css({ opacity: "1" })
	
			$('#jquery')
			
				.mouseover(function(){
					$('#jquery_image').stop().animate({ top: "10px", opacity: "1" }, { duration: 800, easing: easingShare })
					$('#jquery_image_grey').stop().animate({ top: "-67px", opacity: "0" }, { duration: 800, easing: easingShare })
				})
				
				.mouseout(function(){
					$('#jquery_image').stop().animate({ top: "30px", opacity: "0" }, { duration: 800, easing: easingShare })
					$('#jquery_image_grey').stop().animate({ top: "-47px", opacity: "1" }, { duration: 800, easing: easingShare })
				})
				
			$('#ajax_image').css({ opacity: "0" })
			$('#ajax_image_grey').css({ opacity: "1" })
	
			$('#ajax')
			
				.mouseover(function(){
					$('#ajax_image').stop().animate({ top: "0", opacity: "1" }, { duration: 800, easing: easingShare })
					$('#ajax_image_grey').stop().animate({ top: "-95px", opacity: "0" }, { duration: 800, easing: easingShare })
				})
				
				.mouseout(function(){
					$('#ajax_image').stop().animate({ top: "20px", opacity: "0" }, { duration: 800, easing: easingShare })
					$('#ajax_image_grey').stop().animate({ top: "-75px", opacity: "1" }, { duration: 800, easing: easingShare })
				})
				
			$('#php_image').css({ opacity: "0" })
			$('#php_grey').css({ opacity: "1" })
	
			$('#php')
			
				.mouseover(function(){
					$('#php_image').stop().animate({ top: "5px", opacity: "1" }, { duration: 800, easing: easingShare })
					$('#php_image_grey').stop().animate({ top: "-79px", opacity: "0" }, { duration: 800, easing: easingShare })
				})
				
				.mouseout(function(){
					$('#php_image').stop().animate({ top: "25px", opacity: "0" }, { duration: 800, easing: easingShare })
					$('#php_image_grey').stop().animate({ top: "-59px", opacity: "1" }, { duration: 800, easing: easingShare })
				})
				
			$('#mysql_image').css({ opacity: "0" })
			$('#mysql_grey').css({ opacity: "1" })
	
			$('#mysql')
			
				.mouseover(function(){
					$('#mysql_image').stop().animate({ top: "5px", opacity: "1" }, { duration: 800, easing: easingShare })
					$('#mysql_image_grey').stop().animate({ top: "-81px", opacity: "0" }, { duration: 800, easing: easingShare })
				})
				
				.mouseout(function(){
					$('#mysql_image').stop().animate({ top: "25px", opacity: "0" }, { duration: 800, easing: easingShare })
					$('#mysql_image_grey').stop().animate({ top: "-61px", opacity: "1" }, { duration: 800, easing: easingShare })
				})
				
				
		/////////////////////////////
		///                       ///
		/// CONTACT FORM DYNAMICS ///
		///                       ///
		/////////////////////////////
			
			$('#current_site_choice').hide();
			$('#choice_search_engine').hide();
			$('#search_engine_other').hide();
			$('#choice_social_network').hide();
			$('#social_network_other').hide();
			$('#choice_client').hide();
			$('#choice_article').hide();
			$('#choice_newsletter').hide();
			$('#choice_flyer_poster').hide();
			$('#choice_other').hide();
			
			$('#radio_current_site_choice_yes').click(function() {
				
				$('#current_site_choice').fadeIn(200);
				
			});
			
			$('#radio_current_site_choice_no').click(function() {
				
				$('#current_site_choice').fadeOut(200);
				
			});
			
			$('#radio_search_engine').click(function() {
				
				$('#choice_search_engine').delay(200).fadeIn(200);
				$('#search_engine_other').delay(200).fadeIn(200);
				$('#choice_social_network').fadeOut(200);
				$('#choice_client').fadeOut(200);
				$('#choice_article').fadeOut(200);
				$('#social_network_other').fadeOut(200);
				$('#choice_newsletter').fadeOut(200);
				$('#choice_flyer_poster').fadeOut(200);
				$('#choice_other').fadeOut(200);
				
			});
			
			$('#radio_social_network').click(function() {
				
				$('#choice_search_engine').fadeOut(200);
				$('#search_engine_other').fadeOut(200);
				$('#choice_social_network').delay(200).fadeIn(600);
				$('#social_network_other').delay(200).fadeIn(600);
				$('#choice_client').fadeOut(200);
				$('#choice_article').fadeOut(200);
				$('#choice_newsletter').fadeOut(200);
				$('#choice_flyer_poster').fadeOut(200);
				$('#choice_other').fadeOut(200);
				
			});
			
			$('#radio_client').click(function() {
				
				$('#choice_search_engine').fadeOut(200);
				$('#search_engine_other').fadeOut(200);
				$('#choice_social_network').fadeOut(200);
				$('#social_network_other').fadeOut(200);
				$('#choice_client').delay(200).fadeIn(600);
				$('#choice_article').fadeOut(200);
				$('#choice_newsletter').fadeOut(200);
				$('#choice_flyer_poster').fadeOut(200);
				$('#choice_other').fadeOut(200);
				
			});
			
			$('#radio_article').click(function() {
				
				$('#choice_search_engine').fadeOut(200);
				$('#search_engine_other').fadeOut(200);
				$('#choice_social_network').fadeOut(200);
				$('#social_network_other').fadeOut(200);
				$('#choice_client').fadeOut(200);
				$('#choice_article').delay(200).fadeIn(600);
				$('#choice_newsletter').fadeOut(200);
				$('#choice_flyer_poster').fadeOut(200);
				$('#choice_other').fadeOut(200);
				
			});
			
			$('#radio_newsletter').click(function() {
				
				$('#choice_search_engine').fadeOut(200);
				$('#search_engine_other').fadeOut(200);
				$('#choice_social_network').fadeOut(200);
				$('#social_network_other').fadeOut(200);
				$('#choice_client').fadeOut(200);
				$('#choice_article').fadeOut(200);
				$('#choice_newsletter').delay(200).fadeIn(600);
				$('#choice_flyer_poster').fadeOut(200);
				$('#choice_other').fadeOut(200);
				
			});
			
			$('#radio_business_card').click(function() {
				
				$('#choice_search_engine').fadeOut(200);
				$('#search_engine_other').fadeOut(200);
				$('#choice_social_network').fadeOut(200);
				$('#social_network_other').fadeOut(200);
				$('#choice_client').fadeOut(200);
				$('#choice_article').fadeOut(200);
				$('#choice_newsletter').fadeOut(200);
				$('#choice_flyer_poster').fadeOut(200);
				$('#choice_other').fadeOut(200);
				
			});
			
			$('#radio_flyer_poster').click(function() {
				
				$('#choice_search_engine').fadeOut(200);
				$('#search_engine_other').fadeOut(200);
				$('#choice_social_network').fadeOut(200);
				$('#social_network_other').fadeOut(200);
				$('#choice_client').fadeOut(200);
				$('#choice_article').fadeOut(200);
				$('#choice_newsletter').fadeOut(200);
				$('#choice_flyer_poster').delay(200).fadeIn(600);
				$('#choice_other').fadeOut(200);
				
			});
			
			$('#radio_other').click(function() {
				
				$('#choice_search_engine').fadeOut(200);
				$('#search_engine_other').fadeOut(200);
				$('#choice_social_network').fadeOut(200);
				$('#social_network_other').fadeOut(200);
				$('#choice_client').fadeOut(200);
				$('#choice_article').fadeOut(200);
				$('#choice_newsletter').fadeOut(200);
				$('#choice_flyer_poster').fadeOut(200);
				$('#choice_other').delay(200).fadeIn(600);
				
			});
			
		
		/////////////
		///       ///
		/// SHARE ///
		///       ///
		/////////////			
			
			$('#facebook_text').css({ opacity: "0" }).hide();
			$('#twitter_text').css({ opacity: "0" }).hide();
			$('#linkedin_text').css({ opacity: "0" }).hide();
			$('#tumblr_text').css({ opacity: "0" }).hide();
			$('#myspace_text').css({ opacity: "0" }).hide();
			$('#stumbleupon_text').css({ opacity: "0" }).hide();
			$('#digg_text').css({ opacity: "0" }).hide();
			$('#reddit_text').css({ opacity: "0" }).hide();
			$('#googlebuzz_text').css({ opacity: "0" }).hide();
			$('#yahoo_text').css({ opacity: "0" }).hide();
			$('#delicious_text').css({ opacity: "0" }).hide();
	
			$('#facebook')
			
				.css({ backgroundPosition: "0 20px", opacity: "0.4" })
				
				.mouseover(function(){
					$(this).stop().animate({ backgroundPosition: "0 0", opacity: "1" }, { duration: 400, easing: easingShare })
					$('#facebook_text').stop().show().animate({ opacity: "1" }, { duration: 1000, easing: easingShare })
				})
				
				.mouseout(function(){
					$(this).stop().animate({ backgroundPosition: "0 20px", opacity: "0.4" }, { duration: 800, easing: easingShare })
					$('#facebook_text').stop().hide().animate({ opacity: "0" }, { duration: 1000, easing: easingShare })
				})
	
			$('#twitter')
			
				.css({ backgroundPosition: "0 20px", opacity: "0.4" })
				
				.mouseover(function(){
					$(this).stop().animate({ backgroundPosition: "0 0", opacity: "1" }, { duration: 400, easing: easingShare })
					$('#twitter_text').stop().show().animate({ opacity: "1" }, { duration: 1000, easing: easingShare })
				})
				
				.mouseout(function(){
					$(this).stop().animate({ backgroundPosition: "0 20px", opacity: "0.4" }, { duration: 800, easing: easingShare })
					$('#twitter_text').stop().hide().animate({ opacity: "0" }, { duration: 1000, easing: easingShare })
				})
	
			$('#linkedin')
			
				.css({ backgroundPosition: "0 20px", opacity: "0.4" })
				
				.mouseover(function(){
					$(this).stop().animate({ backgroundPosition: "0 0", opacity: "1" }, { duration: 400, easing: easingShare })
					$('#linkedin_text').stop().show().animate({ opacity: "1" }, { duration: 1000, easing: easingShare })
				})
				
				.mouseout(function(){
					$(this).stop().animate({ backgroundPosition: "0 20px", opacity: "0.4" }, { duration: 800, easing: easingShare })
					$('#linkedin_text').stop().hide().animate({ opacity: "0" }, { duration: 1000, easing: easingShare })
				})
	
			$('#tumblr')
			
				.css({ backgroundPosition: "0 20px", opacity: "0.4" })
				
				.mouseover(function(){
					$(this).stop().animate({ backgroundPosition: "0 0", opacity: "1" }, { duration: 400, easing: easingShare })
					$('#tumblr_text').stop().show().animate({ opacity: "1" }, { duration: 1000, easing: easingShare })
				})
				
				.mouseout(function(){
					$(this).stop().animate({ backgroundPosition: "0 20px", opacity: "0.4" }, { duration: 800, easing: easingShare })
					$('#tumblr_text').stop().hide().animate({ opacity: "0" }, { duration: 1000, easing: easingShare })
				})
	
			$('#myspace')
			
				.css({ backgroundPosition: "0 20px", opacity: "0.4" })
				
				.mouseover(function(){
					$(this).stop().animate({ backgroundPosition: "0 0", opacity: "1" }, { duration: 400, easing: easingShare })
					$('#myspace_text').stop().show().animate({ opacity: "1" }, { duration: 1000, easing: easingShare })
				})
				
				.mouseout(function(){
					$(this).stop().animate({ backgroundPosition: "0 20px", opacity: "0.4" }, { duration: 800, easing: easingShare })
					$('#myspace_text').stop().hide().animate({ opacity: "0" }, { duration: 1000, easing: easingShare })
				})
	
			$('#stumbleupon')
			
				.css({ backgroundPosition: "0 20px", opacity: "0.4" })
				
				.mouseover(function(){
					$(this).stop().animate({ backgroundPosition: "0 0", opacity: "1" }, { duration: 400, easing: easingShare })
					$('#stumbleupon_text').stop().show().animate({ opacity: "1" }, { duration: 1000, easing: easingShare })
				})
				
				.mouseout(function(){
					$(this).stop().animate({ backgroundPosition: "0 20px", opacity: "0.4" }, { duration: 800, easing: easingShare })
					$('#stumbleupon_text').stop().hide().animate({ opacity: "0" }, { duration: 1000, easing: easingShare })
				})
	
			$('#digg')
			
				.css({ backgroundPosition: "0 20px", opacity: "0.4" })
				
				.mouseover(function(){
					$(this).stop().animate({ backgroundPosition: "0 0", opacity: "1" }, { duration: 400, easing: easingShare })
					$('#digg_text').stop().show().animate({ opacity: "1" }, { duration: 1000, easing: easingShare })
				})
				
				.mouseout(function(){
					$(this).stop().animate({ backgroundPosition: "0 20px", opacity: "0.4" }, { duration: 800, easing: easingShare })
					$('#digg_text').stop().hide().animate({ opacity: "0" }, { duration: 1000, easing: easingShare })
				})
	
			$('#reddit')
			
				.css({ backgroundPosition: "0 20px", opacity: "0.4" })
				
				.mouseover(function(){
					$(this).stop().animate({ backgroundPosition: "0 0", opacity: "1" }, { duration: 400, easing: easingShare })
					$('#reddit_text').stop().show().animate({ opacity: "1" }, { duration: 1000, easing: easingShare })
				})
				
				.mouseout(function(){
					$(this).stop().animate({ backgroundPosition: "0 20px", opacity: "0.4" }, { duration: 800, easing: easingShare })
					$('#reddit_text').stop().hide().animate({ opacity: "0" }, { duration: 1000, easing: easingShare })
				})
	
			$('#googlebuzz')
			
				.css({ backgroundPosition: "0 20px", opacity: "0.4" })
				
				.mouseover(function(){
					$(this).stop().animate({ backgroundPosition: "0 0", opacity: "1" }, { duration: 400, easing: easingShare })
					$('#googlebuzz_text').stop().show().animate({ opacity: "1" }, { duration: 1000, easing: easingShare })
				})
				
				.mouseout(function(){
					$(this).stop().animate({ backgroundPosition: "0 20px", opacity: "0.4" }, { duration: 800, easing: easingShare})
					$('#googlebuzz_text').stop().hide().animate({ opacity: "0" }, { duration: 1000, easing: easingShare })
				})
	
			$('#yahoo')
			
				.css({ backgroundPosition: "0 20px", opacity: "0.4" })
				
				.mouseover(function(){
					$(this).stop().animate({ backgroundPosition: "0 0", opacity: "1" }, { duration: 400, easing: easingShare })
					$('#yahoo_text').stop().show().animate({ opacity: "1" }, { duration: 1000, easing: easingShare })
				})
				
				.mouseout(function(){
					$(this).stop().animate({ backgroundPosition: "0 20px", opacity: "0.4" }, { duration: 800, easing: easingShare})
					$('#yahoo_text').stop().hide().animate({ opacity: "0" }, { duration: 1000, easing: easingShare })
				})
	
			$('#delicious')
			
				.css({ backgroundPosition: "0 20px", opacity: "0.4" })
				
				.mouseover(function(){
					$(this).stop().animate({ backgroundPosition: "0 0", opacity: "1" }, { duration: 400, easing: easingShare })
					$('#delicious_text').stop().show().animate({ opacity: "1" }, { duration: 1000, easing: easingShare })
				})
				
				.mouseout(function(){
					$(this).stop().animate({ backgroundPosition: "0 20px", opacity: "0.4" }, { duration: 800, easing: easingShare})
					$('#delicious_text').stop().hide().animate({ opacity: "0" }, { duration: 1000, easing: easingShare })
				})
			
	});
	
	
    $(window).load(function() {
		
		//////////////////
		///            ///
		/// NIVOSLIDER ///
		///            ///
		//////////////////
		
			$('#slider').nivoSlider();
		
    });
	
	
	//////////////
	///        ///
	/// POPUPS ///
	///        ///
	//////////////
			
		function sharePopup(pageURL, title, w, h) {
			var left = (screen.width/2)-(w/2);
			var top = (screen.height/2)-(h/2);
			var targetWin = window.open (pageURL, title, 'toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0, copyhistory=0, width='+w+', height='+h+', top='+top+', left='+left);
		}
