$("document").ready(function(){
	$(".blank").attr('target', '_blank');
	$(".content_section").each(function(){
		$(this).find('.specs').first().show();
	});

	$(".block").hide();
	$("#header, #footer").show();
	$(".thumb").slideshow();
	$("#next").hoverClass('hover');
	$("#next").hover(function(){
		$("#next_mo").show();
	},function(){
		$("#next_mo").hide();
	});
	
	$("#slide_toggle").click(function(){
		if(!$(this).hasClass('is_closed'))
		{
			close();
		}
		else
		{
			open();
		}
	});
	var list_height = $("#product_list").height();
	$("#product_list").css("height",0);
	$("#producten").click(function(e){
		e.preventDefault();
		if($(this).hasClass('active')){
			$('#product_list').animate({
				height: 0
			},{
				duration: 400,
				easing: 'easeOutExpo'
			});
			$(this).removeClass('active');
		}else{
			$(this).parent().parent().find('.active').click();
			$("#product_list").animate({
				height: list_height
			},{
				duration: 400,
				easing: 'easeInExpo'
			})
			$(this).addClass('active');
		}
	});
	
	var contact_height = $("#contact_content").height();
	$("#contact_content").css("height",0);
	$("#contact").click(function(e){
		e.preventDefault();
		if($(this).hasClass('active')){
			$('#contact_content').animate({
				height: 0
			},{
				duration: 400,
				easing: 'easeOutExpo'
			});
			$(this).removeClass('active');
		}else{
			$(this).parent().parent().find('.active').click();
			$("#contact_content").animate({
				height: contact_height
			},{
				duration: 400,
				easing: 'easeInExpo'
			})
			$(this).addClass('active');
		}
	});
	
	$("#header ul a").click(function(e){
		e.preventDefault();
		if($(this).hasClass('active')) return;
		$("#header ul a").removeClass('active');
		$(this).addClass('active');
		$(".content_section").removeClass('active_group').slideUp(400);
		var $next_active = $("#section_"+$(this).attr('rel')).addClass('active_group');
		$next_active.find(".specs").first().show();
		$next_active.stop().slideDown();
		setTimeout(function(){ 
			$(".active_group .thumb").first().click();
		},400);
	});
	
});

function open()
{
	$("#next").slideUp(150);
	$("#slide_toggle").removeClass('is_closed').animate({
		left: 490
	},{
		duration: 500,
		easing: 'easeInQuint',
		complete: function(){
			
		}
	});
	$("#inner_container").animate({
		width: 490
	},{
		duration: 500,
		easing: 'easeInQuint',
		complete: function(){
		}
	});
	setTimeout(function(){
		$("#slide_toggle img").animate({
			left: 0
		},{
			duration: 200,
			easing: 'easeOutQuint',
			complete: function(){
			$("#overlay").fadeIn(400);
			}
		});
	},500);
}

function close()
{
	$("#inner_container").animate({
		width: 0,
	}, {
		duration: 500,
		easing: 'easeInQuint',
		complete: function(){
		}
	});
	$("#slide_toggle").animate({
		left: 0
	},{
		duration: 500,
		easing: 'easeInQuint',
		complete: function(){
			$(this).addClass('is_closed');
			$("#slide_toggle img").animate({
				left: -25
			},200);
			$("#next").slideDown(150,function(){
				$("#overlay").fadeOut(400);
			});
			
		}
	});
}
