
jQuery(document).ready(function(){
	if (jQuery('#bg img').length > 0) {				
	var nrOfImages = jQuery('#bg img').length;		
	var counter = nrOfImages;				
	var imgs = [];				
	jQuery('#bg img').each(function (index) {						
		var i = new Image();			
		i.onload = function () {				
			var h = i.height;				
			var w = i.width;				
			imgs[index] = [w, h];				
			jQuery(window).trigger('resize');			
		}			
		i.src = jQuery(this).attr('src');				
		});						
		
		jQuery(window).resize(function () {						
			var height = jQuery(window).height();			
			var width = jQuery(window).width();						
			jQuery('#bg').height(height);						
			jQuery('#bg').css({'width': width,'height': height});						
			
			jQuery('#bg img').each(function (index) {				
				var self = this;								
				if (imgs[index] && imgs[index].length === 2) {					
					var w = imgs[index][0];					
					var h = imgs[index][1];										
					if ((height/width) > (h/w)) {						
						jQuery(self).css({'width': (w/h) * height,	'height': height});											
					} else {						
						jQuery(self).css({'width': width,	'height': (h/w) * width	});					
					}				
				}			
			});
		}).trigger('resize');	
	}	
	
	// Height on puffovic		
	var puff1Height = jQuery("#puff1").innerHeight();	
	var puff2Height = jQuery("#puff2").innerHeight();	
	var puff3Height = jQuery("#puff3").innerHeight();		
	var biggestPuff = 0;	
	jQuery("#cntPuffar div.puff").each(function(index){		
		if(jQuery(this).innerHeight() > biggestPuff)			
			biggestPuff = jQuery(this).innerHeight();	
	});	
	jQuery("#cntPuffar div.puff").css({"height":biggestPuff + "px"});	
});


