/*header preload and transition effect*/
$(function(){

	function headerImagesLoaded(){
		if (!$('#carouselCont').hasClass('loaded')) {
			$('#imgEyeCarousel img').css({visibility: "visible"});
			$('#carouselCont').addClass('loaded').cycle({
				fx:     'fade',
				random:	1,
				speed:   1000, 
				timeout: 5000,
				next:   '#nextImage', 
				prev:   '#prevImage' 
			});
		}
	}

	var imagesToLoad = $('#imgEyeCarousel img').size();
	var imagesLoaded = 0;
	$('#imgEyeCarousel img').each(function(){
		$(this).css({visibility: "hidden"});
		eventName =  $.browser.msie ? 'complete' : 'load';
		$(this).bind(eventName, function(){
			imagesLoaded++;
			if (imagesLoaded == imagesToLoad) {
				headerImagesLoaded();
			}
		});
	});
	$(window).bind('load', function() {
		headerImagesLoaded();
	});
});
