/* Functions
-------------------------------------------------------------- */
function preloadImages(){
	
	// create div containers
	$('#container img').each(function(index) {
	
		// get width an height of child image
		var w_img = $(this).attr('width');
		var h_img = $(this).attr('height');
	
		// wrap + resize
		if($(this).parent().is('a')){
			$(this).parent().wrap('<div class="preload-image"/>');
			$(this).parent().parent().css({'width':w_img, 'height':h_img});
		}else{
			$(this).wrap('<div class="preload-image"/>');
			$(this).parent().css({'width':w_img, 'height':h_img});
		}
	
	});

	// preload imeages
	var counterDelay = 1;
	$('.preload-image img').imgpreload({
		each: function(){
			// fade in
			$(this).delay(incrementDelayFadePreload*counterDelay).fadeIn(speedFadePreload, function() {
			    // remove black bg color
				if($(this).parent().is('a')){
					$(this).parent().parent().css({'background-color':'#fff'});
				}else{
					$(this).parent().css({'background-color':'#fff'});
				}
			 });
			// counter delay
			counterDelay++;
		},
		all: function(){
			//
		}
	});
	
	// bugfix opera
	if($.client.browser == "Opera"){
		$('.preload-image img').show();
	}
	
}
