// Variables (Time Intervals)
var timer,
    showtime=200,
    banner_animate_time=8000,
    hidetime=500;	
var images = {
	weddings : {
		images: [{ src: '/templates/images/weddings/head_image1.jpg' }
				,{ src: '/templates/images/weddings/head_image2.jpg' }
				,{ src: '/templates/images/weddings/head_image3.jpg' }],
		position1: {backgroundPosition: '0 -202px'},
		position2: {backgroundPosition: '-179px 0'},
		position3: {backgroundPosition: '0 -154px'}
	},
	catering : {
		images: [{ src: '/templates/images/catering/head_image1.jpg' }
				,{ src: '/templates/images/catering/head_image2.jpg' }
				,{ src: '/templates/images/catering/head_image3.jpg' }],
		position1: {backgroundPosition: '0 -158px'},
		position2: {backgroundPosition: '-293px 0'},
		position3: {backgroundPosition: '0 -212px'}
	},
		corporate : {
		images: [{ src: '/templates/images/corporate/head_image1.jpg' }
				,{ src: '/templates/images/corporate/head_image2.jpg' }
				,{ src: '/templates/images/corporate/head_image3.jpg' }],
		position1: {backgroundPosition: '0 -103px'},
		position2: {backgroundPosition: '-327px 0'},
		position3: {backgroundPosition: '-207px 0'}
	}
	}

$(document).ready(function() {
// **************** JS Menu *******************					   
    $('#content-block .content-block-menu li').hover(function() {
        if ($(this).find('.submenu').hasClass('submenu')) {
            var _this = $(this);
            $(this).parent().find('a').removeClass('an_active');
            $(this).parent().find('.submenu').each(function() {
                if ($(this)[0]!= _this.find('.submenu')[0]) {
                    $(this).hide(showtime);
                }
            });
            $(this).find('a').eq(0).addClass('an_active');
            clearInterval(timer);
            $(this).find('ul.submenu').stop(true, true);
            $(this).find('ul.submenu').show(showtime);
        }
    }, function () {
        var _this = $(this);
        if (_this.find('ul.submenu').css('display')=="block") {
            timer = setTimeout(function () {
                _this.find('a').eq(0).removeClass('an_active');
                _this.find('ul.submenu').hide(showtime);
            },hidetime);
		}
    });
// **************** JS Menu END *******************

    if ($('#paging')) {
		$('#paging').css('margin-left',879/2 - Number($('#paging').width()/2));
	}
	
	
	$('#content-block .content-block-content .block.dresses .dress').hover(function() {
		$('.dress1, .dress2, .dress3, .dress4, .dress5').hide();
		$('.dress'+$(this).attr('num')).show();
	});
	
	$('#footer-menu .up').click(function(e) {
		$(document).scrollTop(0);
		return false;
	});
	
	$('#fly_block .big_img').click(function() {
		document.location.href=$(this).attr('href');
	});
	
	if ($(".content-block-photoblock").hasClass('content-block-photoblock')) {
			$(".content-block-photoblock").imageLoader({
				images : images[$('#wrapper').attr('class')].images,
				endableSplashScreen:false });
		photo_change ();
	}	
	
});
var animation_time=10000,
	fade_time=3000;

function photo_change () {
			$('#content-block .content-block-photoblock .image1').animate(images[$('#wrapper').attr('class')].position1,{queue:false, duration: animation_time, easing:"linear"});
			setTimeout ( function () {
 			    $('#content-block .content-block-photoblock .image2').animate(images[$('#wrapper').attr('class')].position2,{queue:false, duration: animation_time, easing:"linear"});
				$('#content-block .content-block-photoblock .image2').fadeIn(fade_time, function() {
					$('#content-block .content-block-photoblock .image3').css(images[$('#wrapper').attr('class')].position3);					
				});
				setTimeout ( function () {
					$('#content-block .content-block-photoblock .image3').animate({backgroundPosition: '0 0'},{queue:false, duration: animation_time, easing:"linear"});
					$('#content-block .content-block-photoblock .image3').fadeIn(fade_time, function() {
						$('#content-block .content-block-photoblock .image1').css({backgroundPosition: '0 0'});	
						$('#content-block .content-block-photoblock .image2').css({backgroundPosition: '0 0', 'display' : 'none'});						
					});
					setTimeout ( function () {
						photo_change();
						$('#content-block .content-block-photoblock .image3').fadeOut(fade_time, function () {
							$('#content-block .content-block-photoblock .image2').css({backgroundPosition: '0 0', 'display' : 'none'});
						});
					}, animation_time - fade_time);	
				}, animation_time - fade_time);
			}, animation_time - fade_time);
}
