$(document).ready(function(){
	/*MENU*/
	$("#menu > ul > li:has(a.selected)").children("ul:first").fadeTo("0", 0.2);
	$("#menu > ul > li:has(a.selected)").children("ul:last").show();	
	$("#menu > ul > li:has(ul)").hover(function(){
		if($(this).find("a").hasClass("selected")){
			$(this).find("ul").show();
		}else{
			$(this).children("ul:first").stop(true, true).fadeTo("500", 0.2);
			$(this).children("ul:last").stop(true, true).fadeIn("500");
			$("#menu > ul > li:has(a.selected)").children("ul:first").stop(false, true).fadeOut("500");
			$("#menu > ul > li:has(a.selected)").children("ul:last").stop(false, true).fadeOut("500");
			$("#menu > ul > li > a.selected").eq(0).removeClass("hover");
		}
		$(this).children("a").eq(0).addClass("hover");
	},function(){
		if($(this).find("a").hasClass("selected")){
			$(this).find("ul").show();
		}else{
			$(this).children("ul:first").eq(0).stop(true, true).fadeOut("500");
			$(this).children("ul:last").stop(true, true).fadeOut("500");
			$("#menu > ul > li:has(a.selected)").children("ul:first").stop(false, true).fadeTo("500", 0.2);
			$("#menu > ul > li:has(a.selected)").children("ul:last").stop(false, true).fadeIn("500");

			
		}
		$(this).children("a").eq(0).removeClass("hover");
		$("#menu > ul > li:has(ul) > a.selected").eq(0).addClass("hover");
	});
	$("#menu > ul > li:has(ul) > a.selected").addClass("hover");
	/*EINDE MENU*/
	
	
	/*PRODUCTENOVERZICHT*/
	$(".prod img").css({ "margin-top" : "12px", "margin-right" : "14px", "margin-left" : "14px",  "width" : "77px",  "height" : "158px" });
	$(".prod:first img").css({ "margin-top" : "0px", "margin-right" : "0px", "margin-left" : "0px",  "width" : "105px",  "height" : "216px" });

	$(".prod:not(.prod:first)").hover(function(){
		$(this).find("img").eq(0).stop(true, true).animate({
			marginTop: "0px",
			marginRight: "0px",
			marginLeft: "0px",
			"width": "105px",
			"height": "216px"
			}, 250);
		$(".prod:first img").stop().animate({
			marginTop: "12px",
			marginRight: "14px",
			marginLeft: "14px",
			"width": "77px",
			"height": "158px"
			}, 500);
	},function(){
		$(this).find("img").eq(0).stop(true, true).animate({
			marginTop: "12px",
			marginRight: "14px",
			marginLeft: "14px",
			"width": "77px",
			"height": "158px"
			}, 500);
		$(".prod:first img").stop().animate({
			marginTop: "0px",
			marginRight: "0px",
			marginLeft: "0px",
			"width": "105px",
			"height": "216px"
			}, 250);
	});
	/*EINDE PRODUCTENOVERZICHT*/
	

	/*PRODUCTOMSCHRIJVING*/
	$(".omschr").css("display","none");
	$(".omschr:first").css("display","block");
	$(".prod:not(.prod:first)").hover(function(){
		$(this).children("div").css("display","block");
		$(".omschr:first").css("display","none");
	},function(){
		$(this).children("div").css("display","none");
		$(".omschr:first").css("display","block");
	});
	/*EINDE PRODUCTOMSCHRIJVING*/
	
	
	/*TOOLTIP*/	
	$(".linktooltip").click(function(){
		return false;
	});
	$(".linktooltip").hover(function(){
		var position = $(this).position();
		$(".tooltip").css( { "left" : + position.left , "top" : + position.top } );
	});
	$(".linktooltip").mouseenter(function(){
		hoeveelste = $(this).closest('div').find(".linktooltip").index(this);
		$(this).closest('div').find(".tooltip").eq(hoeveelste).stop(true, true).fadeIn("fast");	
	});
	$(".linktooltip").mouseleave(function(){
		hoeveelste = $(this).closest('div').find(".linktooltip").index(this);
		$(this).closest('div').find(".tooltip").eq(hoeveelste).stop(true, true).fadeOut("fast");	
	});	
	/*EINDE TOOLTIP*/
	
	
	/*TABS*/	
	$('#tabs h4').each(function()
	{
		$(this).html("<span class=\"lft\">&nbsp;</span><span class=\"cntr\">"+$(this).html()+"</span><span class=\"rght\">&nbsp;</span>");
	}).click(function()
	{
		$('#tabs h4').removeClass("active");
		$(this).addClass("active");
		var hoeveelste = $(this).parent().children("h4").index(this);
		$('#tabs_inhoud div').hide().eq(hoeveelste).show();
	});
	$('#tabs h4').eq(0).addClass("active");
	$('#tabs_inhoud div').hide().eq(0).show();

	/*EINDE TABS*/	 	

	
	/*TARGET BLANK*/
	$("a[href^='http://'],a[href^='www.'],a[rel='external']").not("a[href^='http://www.ntree.nl'],a[href^='http://ntree.nl'],a[href^='http://www.n-tree.nl'],a[href^='http://n-tree.nl']").attr('target','_blank');
	/*EINDE TARGET BLANK*/
	
	
    
	
	schalen();
});

$(window).load(function(){
	
	/*MARGIN THUMBS*/	
	$(".thickbox img").each(function(){
		var imghoogte = $(this).attr('height');
		$(this).css('margin-top',(110 - imghoogte) /2 + 'px');	
	});
});


$(window).resize(function(){
	schalen();
});

function schalen()
{
	$("#middle").css("min-height",$(window).height() - $("#top").height() - 75);
}

