$(document).ready(function() {
		var panel = $("#toggle");
		var button = $("#toggle_button");
		var initialState = "expanded";
		var activeClass = "toggle_show";
		var inactiveClass = "toggle_hide";
       //Carousel
       $(function(){
    	    $(".recent-works").carousel( { 
    	    	autoSlide: true, 
    	    	autoSlideInterval: 10000,
    	    	loop: true
    	     } );
		} );
		//Lightbox
		$(function() {
			$('.recent_content a.li-boxim').lightBox();
			$('.recent_content a.li-boxa').lightBox();
		});
		$(function() {
			$('.work_box a.work_link_img').lightBox();
			$('.work_box a.lightbox_title').lightBox();
		});

       
		if($.cookie("panelState") == undefined) {
			$.cookie("panelState", initialState);
		}
		var state = $.cookie("panelState");
		if(state == "collapsed") {
			panel.hide();
			button.addClass(activeClass);
		}
		else{
			panel.show();
			button.addClass(inactiveClass);
		}
		button.click(function(){
			if($.cookie("panelState") == "expanded") {
				$.cookie("panelState", "collapsed");
				button.addClass(activeClass);
			} else {
				$.cookie("panelState", "expanded");
				button.removeClass(activeClass);
				button.addClass(inactiveClass);
			}
			panel.slideToggle("slow");
			return false;
		});	
		
		//Accordion
		$(".acc_container").hide();
		$(".acc_toggler").toggle(function(){
			$(this).addClass("active"); 
			}, function () {
			$(this).removeClass("active");
		});
		$(".acc_toggler").click(function(){
			$(this).next(".acc_container").slideToggle("normal");
		});
		
		//FADEIN FADEOUT
		$(function () {
			$('h1#logo a, .map_point, #send').hover(function() {
				$(this).stop().fadeTo("normal", 0.6);
			}, function() {
				$(this).stop().fadeTo("normal", 1);
			});
		});

		$(function () {
			$('.work_link_img img').hover(function() {
				$(this).stop().fadeTo("normal", 0.8);
			}, function() {
				$(this).stop().fadeTo("normal", 1);
			});
		});
		
		$(".cat_title").fadeTo("slow", 0);
		$(function () {
			$('.category').hover(function() {
				$(this).find(".cat_title").stop().fadeTo("normal", 1);
			}, function() {
				$(this).find(".cat_title").stop().fadeTo("normal", 0);
			});
		});
		
		//Toggle description
		$(function () {
			$('.recent_image').hover(function() {
				$(this).find(".descr").stop().animate({
												opacity: 1,
											    bottom: '0'
											  }, 300, function() {
											    // Animation complete.
											  });
			}, function() {
				$(this).find(".descr").stop().animate({
												opacity: 0,
											    bottom: '-55'
											  }, 300, function() {
											    // Animation complete.
											  });
			});
		});
		
		
		//FOCUS & BLUR
		$(".field").focus(function () {
         $(this).addClass("focused");
    	});
    	$(".field").blur(function () {
         $(this).removeClass("focused");
    	});

});
