
$(document).ready(function() {
		
		// uitklapmenu
		//$(".dropmenuTrigger span").click(function () {
		$(".dropmenuTrigger").click(function () {
				if (!$(this).hasClass("active")) {
					// alle triggers op inactief zetten
					//$(".dropmenuTrigger span").removeClass("active");
					$(".dropmenuTrigger").removeClass("active");
					// alle uitklap menu's verbergen
					$(".dropmenuContent").removeClass("show");
					// alle uitklap menu's de focus nemen
					$(".dropmenuContent").blur();
				}
				// trigger actief maken
				$(this).toggleClass("active");
				// uitklap menu tonen
				$(this).next().toggleClass("show");
				//$(this).parent("div").next().toggleClass("show");
				return false;
		});
		
		$(".selectElement").mouseover(function () {
			activeElem = $(this).attr("class");
			$("#temp").attr("value", activeElem);
		});
		$(".selectElement").mouseout(function () {
			activeElem = "";
			$("#temp").attr("value", activeElem); 
		});
	
	
	  $("body").click(function(){
		  if (activeElem == "") {
				//$(".dropmenuTrigger span").removeClass("active");
				$(".dropmenuTrigger").removeClass("active");
				$(".dropmenuContent").removeClass("show");
			}
	   });
	 
	   
	activeElem = "";
	// uitklapmenu
	
	$(".dropmenuContent ul").each(function() {
		var widest = 30;
		$(this).children().each(function(i){
			if($(this).children('a').html() != null){
				//alert($(this).children('a').html())
				var wide = $(this).children('a').html().length;
			}else{
				var wide = $(this).children('div').html().length;
			}
			//var wide =0;
			if (wide > widest) { widest = wide; }
		});
		if (widest > 30) {
			// aantal karakters x 5. 5pixel per karakter 
			var newWidth = (widest*5);
			$(this).children('li').css({'width': (newWidth+40)});
			$(this).children().children('a').css({'width': newWidth});
		}
		
	});
	
	
	$('.listAsGrid li').biggerlink({hoverclass:'hover'});
	$('.productsGrid li').biggerlink({hoverclass:'hover'});
	
	$('.dropmenuContent li').biggerlink({hoverclass:'hover'});

	//$('.table3col td').biggerlink({hoverclass:'hover'});
	
	
	$("table.data-table tbody tr:nth-child(odd)").addClass("odd");
	$("table.data-table tbody tr:nth-child(even)").addClass("even");
	
	
	$("table.styled-table tbody tr:nth-child(odd)").addClass("odd");
	$("table.styled-table tbody tr:nth-child(even)").addClass("even");
	
	
	
	$('.NOTtruncate').jTruncate({  
		length: 550,  
		minTrail: 100,  
		moreText: "Toon meer tekst",  
		lessText: "Verberg",  
		ellipsisText: "...",  
		moreAni: "fast",  
		lessAni: "fast"  
	}); 
	
	// .last toevoegen aan laatste li
	$(".breadCrumbs li:last-child").addClass("last");
	
	// automatisch toevoegen van popup voor verschaalde afbeeldingen
	/**/
	$("img[src*=.ashx]").each(function() {  
		//als de verschaalde afbeelding al een link bevat, dan GEEN fancy-box toepassen.
		if ($(this).parent().attr("href")){
			return;
		}
		if ($(this).hasClass("notFancy")){
			return;
		}
		if ($(this).attr('src').indexOf('no-image') > 0){
			return;
		}
		
		var imgTitle	= $(this).attr('title');
		var imgSrc		= $(this).attr('src');
		var maxW		= '800';
		var maxH		= '800';
		
		var vars = imgSrc.split(/[;&]/);
 		for (var i = 0; i < vars.length; i++) {
			var pair = vars[i].split('=');
			if (pair[0] == 'w'){
				pair[1] = maxW;
			}
			if (pair[0] == 'h'){
				pair[1] = maxH;
			}
			if (pair[0] == 'crop'){
				pair[1] = "false";
			}
			vars[i] = pair.join('=');
		}
		var newImgSrc = vars.join('&');
		$(this).wrap('<a class="zoom" title="'+ imgTitle +'" href="'+ newImgSrc +'"></a>');
		//$(this).parent().append('<span class="zoomIcon">zoom</span>');	
	});
	
	$(".zoom").fancybox({
		'zoomOpacity'			: false,
		'overlayShow'			: true,
		'zoomSpeedIn'			: 500,
		'zoomSpeedOut'			: 500,
		'imageScale'			: true,
		'hideOnContentClick'	: true
	});
	
	$(".zoom").append("<span style='display:none;'></span>");
    $(".zoom").hover(function(){
        $(this).children("span").show();
    },function(){
        $(this).children("span").hide();
    });
	/**/
	
	
	$(".fancybox").fancybox({
		'zoomOpacity'			: false,
		'overlayShow'			: true,
		'zoomSpeedIn'			: 100,
		'zoomSpeedOut'			: 100,
		'frameWidth'			: 400,
		'frameHeight'			: 250,
		'easingIn'				: 'swing',
		'hideOnContentClick'	: false
	});
	
	$(".quicklook").fancybox({
		'zoomOpacity'			: false,
		'overlayShow'			: false,
		'zoomSpeedIn'			: 100,
		'zoomSpeedOut'			: 100,
		'frameWidth'			: 630,
		'frameHeight'			: 250,
		'easingIn'				: 'swing',
		'hideOnContentClick'	: true
	});
});




