
	
$(document).ready(function(){	
		
	//set the link
	$('#top-link').topLink({
		min: 180,
		fadeSpeed: 500
	});
	//smoothscroll jquery 1.3
	$('#top-link').click(function(e) {
		e.preventDefault();
		$.scrollTo(0,300);
	});
	
	// jquery sIFR (Flash Text-Replacement) voor jquery 1.2.6, niet voor 1.3
	$('h1').sifr({
		path: 'http://www.hoefnagels.com/_Fonts',
		font: 'tradegothic.swf',
		textAlign: 'left'
	});
	$('h2').sifr({
		path: 'http://www.hoefnagels.com/_Fonts',
		font: 'tradegothic.swf',
		textAlign: 'left'
	});
	$('h1.impact').sifr({
		path: 'http://www.hoefnagels.com/_Fonts',
		font: 'impact2.swf',
		textAlign: 'left'
	});
	
	//De gebruikte sIFR plugin is nog niet 100%. indien er geen flash is geinstalleerd dan ging het niet helemaal lekker.
	//vandaar onderstaande extra code om er nog iets van te maken.
	if ( $(".sIFR-jquery").length > 0 ) { 
		$('.sIFR-replaced').css('height','36px');
	}
	
	mainmenu();
	$('#main').equalHeights(true);
	$('.equalHeightsParent').equalHeights(true);
	
	$('img').fixImageUrl();  
	
	//homepage sliding boxes
	$('.boxgrid').hover(function(){
		$(".cover", this).stop().animate({top:'13px'},{queue:false,duration:160});
	}, function() {
		$(".cover", this).stop().animate({top:'112px'},{queue:false,duration:160});
	});
	
	// uitvoeren als pagina is geladen
	$(window).load(function() {
		$('#main').equalHeights(true);
		$('#footer').equalHeights(true);
    });
	$(window).resize(function() {
		$('#main').equalHeights(true);
    });
	
});

/*-------------------------------------------------------------------- 
 * JQuery Plugin: "EqualHeights" (http://www.filamentgroup.com)
 * Description: Compares the heights or widths of the top-level children of a provided element 
 		and sets their min-height to the tallest height (or width to widest width). Sets in em units by default if pxToEm() method is available.
 * Dependencies: jQuery library, pxToEm method	(article: 
		http://www.filamentgroup.com/lab/retaining_scalable_interfaces_with_pixel_to_em_conversion/)							  
 * Usage Example: $(element).equalHeights();
  		Optional: to set min-height in px, pass a true argument: $(element).equalHeights(true);
--------------------------------------------------------------------*/
$.fn.equalHeights = function(px) {
	$(this).each(function(){
		var currentTallest = 0;
		$(this).children().each(function(i){
			if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
		});
		if (!px || !Number.prototype.pxToEm) currentTallest = currentTallest.pxToEm(); //use ems unless px is specified
		// for ie6, set height since min-height isn't supported
		if ($.browser.msie && $.browser.version == 6.0) { $(this).children().css({'height': currentTallest}); }
		$(this).children().css({'min-height': currentTallest}); 
	});
	return this;
};
	
	
// Back to top link
jQuery.fn.topLink = function(settings) {
	settings = jQuery.extend({
		min: 1,
		fadeSpeed: 200,
		ieOffset: 50
	}, settings);
	return this.each(function() {
		//listen for scroll
		var el = $(this);
		el.css('display','none'); //in case the user forgot
		$(window).scroll(function() {
			//stupid IE hack
			//if(!jQuery.support.hrefNormalized) {
			//	el.css({
			//		'position': 'absolute',
			//		'top': $(window).scrollTop() + $(window).height() - settings.ieOffset
			//	});
			//}
			if($(window).scrollTop() >= settings.min)
			{
				el.fadeIn(settings.fadeSpeed);
			}
			else
			{
				el.fadeOut(settings.fadeSpeed);
			}
		});
	});
};

	
function mainmenu(){
	$(" #nav ul ul ").css({display: "none"}); // Opera Fix
	$(" #nav li").hover(function(){
		$("#nav li a").removeAttr("title");
		//$("embed").hide();
		$(this).addClass("hover");
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).slideDown(200);
	},function(){
		//$("embed").show();
		$(this).removeClass("hover");
		$(this).find('ul:first').css({visibility: "hidden"});
	});
}
 

	
$.fn.fixImageUrl = function(){   
	return this.each(function(){   
		var tag = $(this);   
		var src = tag.attr("src");
		var firstCharacter = src.substr(0,1);
	
		if (firstCharacter == "/"){
			$(this).hide();
			 this.src = 'http://www.hoefnagels.com/' + src;
			 $(this).load(function(){
				 $(this).fadeIn();
			 })
          //  $('#loader').removeClass('loading').append(this);		
		}
		if (firstCharacter == "I"){
			$(this).hide();
			 this.src = 'http://www.hoefnagels.com/' + src;
			 $(this).load(function(){
				 $(this).fadeIn();
			 })
		}
	});   
};   

	
