$(document).ready(function(){

// Menu
$(".menu_wrapper .menu ul li span").mouseover(function(){
$(this).next().animate({
        opacity: "show"
      }, 600 );
$(this).parent().mouseleave(function(){
$(this).find('span').next().animate({
        opacity: "hide"
      }, 200 );
});
});

$(".menu_wrapper .menu ul li ul li a").mouseover(function(){
$(this).next().animate({
        opacity: "show"
      }, 600 );
$(this).parent().mouseleave(function(){
$(this).find('a').next().animate({
        opacity: "hide"
      }, 200 );
});
});



// Slider (Слайдер на главной)
$('#slider').nivoSlider({
	effect:'fade',
	directionNav:false,
	keyboardNav:false,
	startSlide:0,
	'scroll': 1
});


// Carousel
  $(document).ready(function(){
    $('#slider1').bxSlider({
            auto: true,
        });
  });
  



// Galery
$(".galery_wrapper ul li img").click(function(){
		$(".galery_wrapper ul li").removeClass("active");
		$(this).parent().addClass("active");
        var largePath = $(this).attr("alt");
        $("#largeImg").attr({ src: largePath});
		$("#largeImg").parent().attr({ href: largePath});
    });
	
// ShadowBox
Shadowbox.init({
    handleOversize: "drag",
    modal: true
});


// Position
var window_height = $(window).height();
pos_top = (window_height - 500 ) / 2 ;
pos_top = pos_top + 'px';
$(".main_wrapper").css("top", pos_top);

$(window).resize(function(){ 
var window_height = $(window).height();
pos_top = (window_height - 500 ) / 2 ;
pos_top = pos_top + 'px';
$(".main_wrapper").css("top", pos_top);
});



// Activity slider
if ($("div").hasClass("activity_wrapper"))
		$(function(){
			$('#slides').slides({
				preload: true,
				preloadImage: 'img/loading.gif',
				play: 5000,
				pause: 2500,
				hoverPause: true
			});
		});

	
// if ($("div").hasClass("index_page")) {
// $(".lang_wrapper").css("opacity","0");
// $(".sound").css("opacity","0");
// $(".content_wrapper").css("opacity","0");
// $(".menu_wrapper").css("opacity","0");
// $(".footer").css("opacity","0");

// $(".content_wrapper").delay(600).animate({opacity: '1'}, 800);
// $(".menu_wrapper").delay(1200).animate({opacity: '1'}, 800);
// $(".lang_wrapper").delay(1600).animate({opacity: '1'}, 800);
// $(".sound").delay(1600).animate({opacity: '1'}, 800);
// $(".footer").delay(1600).animate({opacity: '1'}, 800);

//	}



// Scroll
if ($("div").hasClass("customScrollBox")) {
$(window).load(function() {
	mCustomScrollbars();
});

function mCustomScrollbars(){

	$("#mcs_container").mCustomScrollbar("vertical",300,"easeOutCirc",1.05,"auto","yes","yes",15); 
}

/* function to fix the -10000 pixel limit of jquery.animate */
$.fx.prototype.cur = function(){
    if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
      return this.elem[ this.prop ];
    }
    var r = parseFloat( jQuery.css( this.elem, this.prop ) );
    return typeof r == 'undefined' ? 0 : r;
}

/* function to load new content dynamically */
function LoadNewContent(id,file){
	$("#"+id+" .customScrollBox .content").load(file,function(){
		mCustomScrollbars();
	});
}
}


// Fancybox
$("a#example1").fancybox();






});
