		$(document).ready(function() {
			
			var fTop=0;
			
			setupPostAjax();


			$('#main_content').infinitescroll({
				navSelector : "div.navigation",
				nextSelector : "div.navigation a:first",
				itemSelector : "#content div.content_post",
				animate : false,
				bufferPx : 1000,
				loadingImg : window.templateDir + "/graphic/loading.gif",
				loadingText : "",
				doneText : "",
				errorCallback: function(){fTop=0;}
			},function(){
				setupPostAjax();
			});


			$('a.close_client').bind('click', function() {
				$("#work_clients .all_works").addClass('hide');
				$("#additional_content").css("padding-top", "250px");
			});
			


			$('.nav_search').bind('click', function() {
				$("#search").css("display","block").css("opacity",0).fadeTo("slow", 1);
			});


			$('#header_contact').bind('click', function() {
				//$('#contact_container_over').stop().animate({height:'0'},{ duration: 'slow', easing: 'easeOutSine'});
				Contact.show();
				return false;
			});
			$('#header_contact').bind('mouseover', function() {
				if(window.contactOpen == 0){
					$('#contact_container_over').stop().animate({height:'6px'},{ duration: 'fast', easing: 'easeOutSine'});
				}
			});
			$('#header_contact').bind('mouseout', function() {
				if(window.contactOpen == 0){
					$('#contact_container_over').stop().animate({height:'0'},{ duration: 'fast', easing: 'easeOutSine'});
				}
			});


			$("#header h1 a").bind('mouseover', function() {
				var randomHover = "0 -" + (1 + Math.floor(Math.random()*5)) * 106 + "px";
				$(this).css('backgroundPosition', randomHover);
			});
			$('#header h1 a').bind('mouseout', function() {
				$(this).css('backgroundPosition', "0 0");
			});


			$('#scroll_up').bind('click', function() {
				$("html:not(:animated),body:not(:animated)").animate({ scrollTop: 0}, 1000 );
			});
			


			$(window).scroll(function() {
				var sTop = $(window).scrollTop();

				if(sTop>45 & sTop<110){
					var logoheight=65 + (45-sTop);
				} else if ( sTop>=110){
					var logoheight=0;
				} else {
					var logoheight=65;
				}
				$("#header h1 a").css("height", logoheight);

				if(sTop>25){
					$("#header h1 a").css("background-position-x", "right");
				} else {
					$("#header h1 a").css("background-position-x", "left");
				}

				var tmTop=65+logoheight;
				$('#nav_tm').stop().animate({top: tmTop},{ duration: 'fast', easing: 'easeOutSine'});
				$('#nav_main').stop().animate({top: tmTop},{ duration: 'fast', easing: 'easeOutSine'});
				//$("#nav_tm").css("top", tmTop);
				//$("#nav_main").css("top", tmTop);

				/*if($(window).scrollTop() + $(window).height() > $(document).height() - 470) {
					$("#nav_tm").css("top", -300);
					$("#nav_main").css("top", -150);
				} else {
					//$("#nav_tm").css("top", 130);
					//$("#nav_main").css("top", 130);
				}*/
				
				if ( sTop>=600){
					$("#scroll_up").stop().fadeTo("slow", 1, function() {$(this).css("display","block")});
				} else {
					$("#scroll_up").stop().fadeTo("slow", 0, function() {$(this).css("display","none")});
				}
			});


			jQuery(function($){
				$(".attachment-featured_sidebar").each(function() {
					var $newthis = $(this);
					var $cloned = $newthis.clone();
					$cloned.insertAfter($newthis).addClass("color").hide();
					$newthis.desaturate({
						onswitch: function() {
						}
					});
					$cloned.closest("li").bind("mouseenter mouseleave", featuredEffect);
				});
			});
			function featuredEffect(event){
				if (event.type == 'mouseenter')
					$(".attachment-featured_sidebar.color", this).fadeIn(300);
				if (event.type == 'mouseleave')
					$(".attachment-featured_sidebar.color", this).fadeOut(300);
			}
			
			
			/*if (swfobject.hasFlashPlayerVersion("6.0.0")) {
				var fn = function() {
					var att = { data:"http://yslandia.com/blog_ysl/wp-content/themes/yslander/player/yslPlayer.swf", width:"217", height:"122" };
					var par = { base:"." };
					var id = "yslPlayer";
					var myObject = swfobject.createSWF(att, par, id);
				};
			swfobject.addDomLoadEvent(fn);
			}*/

		});
