	$(document).ready(function() {
		setTimeout(
			function(){
				resizeHeight();
			},
			50
		);
		changeZoeken(23);
		doCatalogusKoppelingen();
		$(".truncate, .productomschrijving div.omschrijvings").truncate( 240,{
		        trail: [ " ...<a href='#' class='truncate_show'>lees meer</a>", " ...<a href='#' class='truncate_hide'>minder</a>" ]
		});
		merkenOverzicht();
		personalia();
		showTree();
	});
	
	function showTree(){
		if(typeof(treeId) != "undefined"){
			$("#productgroeplist_"+treeId).parents('ul').show(100);
			$("#productgroeplist_"+treeId).find('ul:first').show(100);
			$("#productgroeplist_"+treeId).show(100);
			$("#productgroeplist_"+treeId).find('a:first').addClass('active');
		}
	}
	
	function changeZoeken(id){
		var liId = "sitemenu_li_"+id;
		var aText = $("#"+liId+" a").html();
		aText = "<img src='http://www.vanspijk.nl/images/verglas.gif' width='12' height='12' border='0' align='absmiddle' /> "+aText;
		$("#"+liId+" a").html(aText).toggle(
			function(){
				$("#zoekscherm").show(400);
				return false;
			},
			function(){
				$("#zoekscherm").hide(400);
				return false;
			}				
		);
		var zoekscherm 	= $("#zoekscherm");
		var liPosition 	= $("#"+liId).position();
		zoekscherm.css({left:liPosition.left+53+"px"});
	}
	function resizeHeight() {
		var	windowHeight = $(window).height();
		var	bodyHeight = $(document).height();
		if(windowHeight > bodyHeight){
			$("#container").css("height","100%");
		}else{
			$("#container").css("height",bodyHeight);
		}
	}
	$(window).resize(function(){
		setTimeout(
			function(){
				resizeHeight();
			},
			50
		);
	});
	
	function doCatalogusKoppelingen(){
		$(".koppelinglink").css("display","none");
		$("#catalogus_productgroepkoppeling li").each(function(){
			$(this).hover(function(){
				$(this).find(".koppelinglink").show();
			},
			function(){
				$(this).find(".koppelinglink").hide();
			});
		});
	}

function showlarge(img){
	var src = img.src;
	src = src.replace("polaroid.","");
	src = src.replace("thumb.","");
	tb_show("",src+"?height=333&width=402");
}

jQuery.fn.center = function() {
	this.css("position","absolute");
	this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop());
	this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft());
	return this;
}

	function personalia(){
		$("img.smoelenboekgegevens").each(function(){
			$(this).css("cursor","pointer");
			$(this).bind("click",
				function(){
					$("div.smoelpopup").hide();
					var id = $(this).attr("rel");
					$("#"+id).center().hide();
					$("#"+id).show('slow');
				});
		});
		$("div.popupclose").bind("click",
			function(){
				$("div.popup").hide();
			});
	}
 
	function merkenOverzicht(){
		$("div.merkImage").each(function(){
			$(this).css("cursor","pointer");
			$(this).bind("click",
				function(){
					$("div.smoelpopup").hide();
					var id = $(this).attr("rel");
					$("#"+id).center().hide();
					$("#"+id).show('slow');
				});
		});
		$("div.popupclose").bind("click",
			function(){
				$("div.popup").hide();
			});
	}
