// JavaScript Document

function CufonReplace() {
	Cufon.replace('h1', { fontFamily: 'Myriad Pro', hover: true } );
	Cufon.replace('h2', { fontFamily: 'Myriad Pro', hover: true } );
	Cufon.replace('#hoofdmenu a', { fontFamily: 'Myriad Pro', hover: true } );
	Cufon.replace('.kop', { fontFamily: 'Myriad Pro', hover: true } );
	
}

$(document).ready(function(){ 	

	$(document).pngFix(); 

	$("#inp_zoeken").blur();
	$("#inp_zoeken").focus(function(){  
		var input = $(this).attr("title")
		var text = $(this).val();
		if (text==input) { 
			$(this).val("");
		}
	});
	$("#inp_zoeken").blur(function(){ 
		var input = $(this).attr("title")
		var text = $(this).val();
		if (text=="") { 
			$(this).val(input);
		}								 
	});
	$("#inp_zoekenbutton").click(function(){
		var zoekveld 	= $("#inp_zoeken").val();	
		var input 		= $("#inp_zoeken").attr("title")
		if (zoekveld!="" && zoekveld!=input) { 
			$("#frm_zoeken").submit();
		} 
		return false;
    });
	
	$(".resultaat-rij li, .specials li").mouseover(function() {
		$(this).children("a").css("display","block");
	});
	
	$(".resultaat-rij li, .specials li").mouseout(function() {
		$(this).children("a").css("display","none");
	});	
	
	$(".resultaat-rij li, .specials li").click(function() { 
		var url = $(this).find("a").attr("href");
		document.location.href=url;
	});

	$(".hoofdblok").click(function() { 
		var url = $(this).find("a").attr("href");
		document.location.href=url;
	});	
	$(".hoofdblok, .specials li").mouseover(function() {
		$(this).find(".meerinfo").css("visibility","visible");
	});
	
	$(".hoofdblok").mouseout(function() {
		$(this).find(".meerinfo").css("visibility","hidden");
	});		
	
	
	$('ul.resultaat-rij, ul.specials').each(function(index) {
		var hoogte = 0;
		$(this).children().each(function(index2) { 
			if ($(this).height()>hoogte) { 
				hoogte = $(this).height();
			}
		});
		$(this).children().each(function(index2) { 
			$(this).height(hoogte)
		});
	});
	
// Ajax pagina's inladen -------------------------------------------------------------------------------------------------
	$(".filter").click(function() {
		$.post("/views/ajax/productoverzicht.php", $("#frm-filters").serialize(), function(data) {
			  $('#overzicht').html(data);
		});
	});
	$(".sorteer").live('click', function() {
		var filter = $(this).text();
		var cat_id = $("#inp_cat_id").val();
		$.post("/views/ajax/productoverzicht.php", { sorteer: filter, inp_cat_id: cat_id  }, function(data) {
			  $('#overzicht').html(data);
		});
		return false;
	});	
	
	
// Fotofader productdetail ----------------------------------------------------------------------------------------
	function thumbOver() {
		$(".foto-groot").stop(true,true);
		var obj = $(".foto-groot").clone(true);
		obj.addClass("copy");
		var image = $(this).next(".thumb2groot").css("background-image");								
   
		obj.insertAfter(".foto-groot").hide().css({"background-image":image});
		$(".foto-groot").hide();
		obj.fadeIn(200);
	}
	function thumbOut() {
		$(".foto-groot").stop(true,true);
		$(".copy").remove();
		$(".foto-groot").fadeIn(200);
    }
	
	var config = {    
		 sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 0, // number = milliseconds for onMouseOver polling interval    
		 over: thumbOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 0, // number = milliseconds delay before onMouseOut    
		 out: thumbOut // function = onMouseOut callback (REQUIRED)    
	};
		
	$(".thumbnail2").hoverIntent( config )
	
});