﻿$(document).ready(function(){ 
	/* Menu */
	//включается режим работы меню "по клику"
	$("#menu").removeAttr("class");
	
	// при клике на пункт меню, открывается подменю
	$(".l1").click(function(){
		if($(".l2", this).attr("class") == "l2 opened"){ // если подменю открыто
			$(".l2", this).hide();
			$(".l2").removeClass("opened");
			return;
		}
		$(".opened").hide();			
		$(".l2").removeClass("opened");	
		$(".l2", this).toggle();
		$(".l2", this).addClass("opened");
	});	

	// при клике на любом месте, подменю закрывается
	$(document).click(function(e){
		if ($(e.target).is(".no_ref") || $(e.target).is(".no_ref a")){
			return;
		}
		$(".l2").hide();
		$(".l2").removeClass("opened");
	});
	/* * * * * * * * * * * * * * * * * * * * */
	
	/* Random image */
	var random;
	random = $.randomBetween(1, 12);
	$("#footer_random").css({"background-image" : "url('/pic/random/"+random+".png')"});
	/* * * * * * * * * * * * * * * * * * * * */
	
	/* Fancybox */
	$("a.single_image").fancybox({
		scrolling : 'no',
		hideOnContentClick : true,
		overlayShow : true,
		overlayOpacity : 0,		
		titlePosition : 'outside', // 'float', 'outside', 'inside' or 'over'
		transitionIn : 'elastic', // 'elastic', 'fade' or 'none'
		transitionOut : 'elastic', // 'elastic', 'fade' or 'none'
		speedIn : 150,
		speedOut : 150
	});

	$(".video").click(function(){
		href_video = $(this).attr("href");
	});
	
	$(".video").fancybox({
		scrolling : 'no',
		hideOnContentClick : false,
		overlayShow : true,
		overlayOpacity : 0,		
		titlePosition : 'outside', // 'float', 'outside', 'inside' or 'over'
		transitionIn : 'elastic', // 'elastic', 'fade' or 'none'
		transitionOut : 'elastic', // 'elastic', 'fade' or 'none'
		speedIn : 150,
		speedOut : 150,
		"width" : 500,
		"height" : 375,
		'onStart' : function() {
	    $(href_video).show();
		},
		'onClosed' : function() {
	    $(href_video).hide();
		}
	});	
	/* * * * * * * * * * * * * * * * * * * * */
});

