$(document).ready(function() {
    var activeBlock = $('#fly_block .block_wedding');
	var _this;
	var block = {
		block_wedding: {
			minimal:359,
			maximal:723
		},
		block_catering: {
			minimal:192,
			maximal:556
		},
		block_corporative: {
			minimal:239,
			maximal:603
		}		
	}
	
	$("#wrapper").imageLoader({
				images: [{ src: '/templates/images/main/small/weddings.png' }
				,{ src: '/templates/images/main/small/catering.png' }
				,{ src: '/templates/images/main/small/corporative.png' }
				,{ src: '/templates/images/main/big/weddings.png' }
				,{ src: '/templates/images/main/big/catering.png' }
				,{ src: '/templates/images/main/big/corporative.png' }],
				endableSplashScreen:false
	});

   
	$('#fly_block .block_wedding, #fly_block .block_catering, #fly_block .block_corporative').mouseenter(function() {
		
		if ($(this)[0]!=activeBlock[0]) {
			$(this).find('.img').hide().attr('style','display:none');
			_this=$(this);
			var _activeBlock=activeBlock;
			 
			activeBlock.stop(true,false).animate({ 
				width: block[activeBlock.attr('class')].minimal
			}, {queue:false, duration: 400, easing:"swing", complete: function() {
			}}).css('overflow','visible');
			
			$(this).stop(true,false).animate({ 
				width: block[$(this).attr('class')].maximal
			}, {queue:false, duration: 400, easing:"swing", complete: function() {
			
				if (/msie/i.test(navigator.userAgent)) {
					_this.find('.menu1').show();
					_this.find('.menu2').show();
					_this.find('.big_img').show();
				} else {
					_this.find('.menu1').show({queue:false, duration: 200});
					_this.find('.menu2').show({queue:false, duration: 200});
					_this.find('.big_img').fadeIn({queue:false, duration: 200});
				}
				
			}}).css('overflow','visible');
			
			if (/msie/i.test(navigator.userAgent)) {
				activeBlock.find('.img').show();
				activeBlock.find('.big_img').hide();
				activeBlock.find('.menu1').hide();
				activeBlock.find('.menu2').hide();
			} else {
				activeBlock.find('.menu1').hide({queue:false, duration: 200});
				activeBlock.find('.menu2').hide({queue:false, duration: 200, complete: function() {
					$(this).parent().find('.menu1').attr('style','display:none');
					$(this).parent().find('.menu2').attr('style','display:none');					
				}}); 				
				activeBlock.find('.img').stop(true,false).fadeIn({queue:false, duration: 200, complete: function() {$(this).css('opacity','1');}});
				activeBlock.find('.big_img').fadeOut({queue:false, duration: 200, complete: function() {
					$(this).attr('style','display:none');
				}});
			}
 			activeBlock = $(this);
		}
	});
	
	$(window).resize(function () {
	   resize($(this));
	});
	
	resize($(window));
});
function resize(_this) {
	if (_this.width()>995) {
		if  (656+_this.width()/2<1285) {
			$('#fly_block').width(656+_this.width()/2);
		} else {
			$('#fly_block').width(1285);
		}
	} else {
		$('#fly_block').width(1154);
	}
}

