$(document).ready(function() {
// Здесь прописываем анимацию появления иконок при первой загрузке страницы
     var k_d=1000; // Время выполнения анимации
     $('#menu2 div').each(function(){
                    $(this).stop().animate({
                        'top':'-31px'   // Конечная позиция иконок
                    },k_d+=250);   // Задержка при выполнении функции для следующего li
     });
		// Эта функция отвечает за анимацию появления иконок при наведении курсора
     $('#menu2 > li').hover(
                function () {
                    var $this = $(this);
                    $('a',$this).addClass('hover');
                    $('div',$this).stop().animate({'top':'40px'},300).css({'zIndex':'10'});
                },
	// Эта функция отвечает за анимацию исчезания иконок при последующем уходе курсора
                function () {
                    var $this = $(this);
                    $('a',$this).removeClass('hover');
                    $('div',$this).stop().animate({'top':'-31px'},800).css({'zIndex':'-1'});
                }
     );

	$("a[rel=foto1]").fancybox({
			'width'				:	'100%',
			'height'			:	'100%',
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'titlePosition' 	: 'inside',
			'speedIn'		:1000,
			'speedOut'		:1000,
			'changeSpeed'	:100,
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">სურათი ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; <b>' + title : '') + '</b></span>';
			}
	});
	$('ul#navmenu_v ul').each(function(i) { // Check each submenu:
		if ($.cookie('submenuMark-' + i)) {  // If index of submenu is marked in cookies:
			$(this).show().prev().removeClass('collapsed').addClass('expanded'); // Show it (add apropriate classes)
		}else {
			$(this).hide().prev().removeClass('expanded').addClass('collapsed'); // Hide it
		}
		$(this).prev().addClass('collapsible').click(function() { // Attach an event listener
			var this_i = $('ul#navmenu_v ul').index($(this).next()); // The index of the submenu of the clicked link
			if ($(this).next().css('display') == 'none') {
				$(this).next().slideDown(1000, function () { // Show submenu:
					$(this).prev().removeClass('collapsed').addClass('expanded');
					cookieSet(this_i);
				});
			}else {
				$(this).next().slideUp(700, function () { // Hide submenu:
					$(this).prev().removeClass('expanded').addClass('collapsed');
					cookieDel(this_i);
					$(this).find('ul').each(function() {
						$(this).hide(0, cookieDel($('ul#navmenu_v ul').index($(this)))).prev().removeClass('expanded').addClass('collapsed');
					});
				});
			}
		return false; // Prohibit the browser to follow the link address
		});
	});
	
	$('#mybook').booklet({
				auto: true,
				delay: 5000,
				width:  560,
	       		height: 400,
	        		closed: true,
	        		autoCenter: true,
	        		covers: true,
	       		pagePadding: 0
	});

    	$('div.thumb1 img').hoverpulse({size: 10});

	$('.slideshow').cycle({
		//fx: 'fade',            // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		fx:      'custom', 
    		cssBefore: {  left: 275,  top:  175,  width: 0,  height: 0,  opacity: 1, zIndex: 1 }, 
    		animOut: {  opacity: 0.2  }, 
    		animIn: {   left: 0,  top: 0,  width: 530,  height: 350   }, 
    		cssAfter: {  zIndex: 0 }, 
    		delay: -3000,
		width: 550,
		height: 350
	});
	$('#slideshow20').fancybox({
			'padding'		:	10,
			'margin'		:	10,
			'width'			:	'750px',
			'height'			:	'550px',
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic',
			'titlePosition' 	: false,
			'speedIn'		:1000,
			'speedOut'		:1000
	});
	$('#slideshow2').cycle({
		//fx: 'fade',            
		// choose your transition type, ex: all, custom, fade, scrollUp, shuffle, zoom, turnDown, curtainX, 
		// blindX, blindY, blindZ, cover. curtainX, curtainY, fade, fadeZoom, growX, growY, none, 
		// scrollUp, scrollDown, scrollLeft, scrollRight, scrollHorz, scrollVert, shuffle, slideX, slideY, toss, 
		// turnUp, turnDown, turnLeft, turnRight, uncover, wipe, zoometc...
		fx:      'growX', 
    		cssBefore: {  left: 275,  top:  175,  opacity: 1, zIndex: 1 }, 
    		animOut: {  opacity: 0.2  }, 
    		animIn: {   left: 0,  top: 0,  width: 700,  height: 550   }, 
    		cssAfter: {  zIndex: 0 }, 
    		delay: 1000
	});

	$("#faq_id1").click(function () {$("#faq_id10").toggle("slow");});    
	$("#faq_id11").click(function () {$("#faq_id10").toggle(1500);});    
	$("#faq_id2").click(function () {$("#faq_id20").toggle("slow");});    
	$("#faq_id21").click(function () {$("#faq_id20").toggle(1500);});    
	$("#faq_id3").click(function () {$("#faq_id30").toggle("slow");});    
	$("#faq_id31").click(function () {$("#faq_id30").toggle(1500);});    

	$(".garmon .gtext").eq(2).addClass("active");
	$(".garmon .gdiv").eq(2).show();
/*	$(".garmon .gtext").click(function(){
		$(this).next(".gdiv").slideToggle("slow")
		.siblings(".gdiv:visible").slideUp("slow");
		flowplayer("a.clip1", "fancybox/flowplayer-3.2.7.swf").unload();
		$(this).toggleClass("active");
		$(this).siblings(".gtext").removeClass("active");
	});  */

		flowplayer("a.clip", "fancybox/flowplayer-3.2.7.swf",
		{
 			clip: {
				// these two configuration variables does the trick
				autoPlay: true,
				scaling: 'fit',
				autoBuffering: true // <- do not place a comma here
			},
			plugins: {
				content: {
					BackgroundColor: '#0000ff'
				},
				controls: {
			//		url: 'fancybox/flowplayer.controls-air-3.2.5.swf',
			//		top: 50,
			//		left: 0,
			//		sliderBorder: '2px solid rgba(3, 3, 3, 1)',
					BackgroundColor: '#0000ff',
					background: '#7b7c00',
					sliderBorderWidth: 0,
					durationColor: '#ffff00',
					progressColor: '#ffff00',
					sliderColor: '#ff0000',
			//		timeBgColor: '#0000ff',
					sliderBorderColor: '#ffffff',
					height: 35,
					scrubber: true,
			//		timeBorder: 4,
					timeFontSize: 16,
					timeColor: '#ffffff',
					timeSeparator: ' / ',
			//		playlist: true,
			//		bottom: 0,
					stop: true,
					autoHide: 'fullscreen'
			//		scrubber: true
			//		fastBackward: true,
			//		fastForward: true,
			//		slowBackward: true,
			//		slowForward: true
				} 
			}, 
			screen: {
				width: 500,
				height: 376, 
				top: 0
			}
		}
	).controls("appleControls");

	$("#airline").show(2000)
		.animate({left: "-200",top: "+=70"}, 2000)
		.animate({left: "30%",top: "+=-100"}, 2000)
		.animate({left: "60%",top: "+=50"}, 2000)
		.animate({left: "130%",top: "20"}, 2000)
		.hide("slow");
});

function k_clip(nameclip) {
		var so = new SWFObject('fancybox/player.swf','mpl','500','390','8');
 		so.addParam('allowfullscreen','true');
 		so.addParam('flashvars','file=../images/custom/'+nameclip+'.flv&image=images/custom/'+nameclip+'.jpg&backcolor=fbf203&frontcolor=990000&lightcolor=0000FF');
 		so.write(nameclip);
}

function cookieSet(index) {
	$.cookie('submenuMark-' + index, 'opened', {expires: null, path: '/'}); // Set mark to cookie (submenu is shown):
}
function cookieDel(index) {
	$.cookie('submenuMark-' + index, null, {expires: null, path: '/'}); // Delete mark from cookie (submenu is hidden):
}
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
(function($){$.fn.hoverpulse=function(options){if(this.length==0){if(!$.isReady&&this.selector){var s=this.selector,c=this.context;$(function(){$(s,c).hoverpulse(options)})}return this}var opts=$.extend({},$.fn.hoverpulse.defaults,options);this.parent().css({position:'relative'});this.css({position:'absolute',top:0,left:0});this.each(function(){var $this=$(this);var w=$this.width(),h=$this.height();$this.data('hoverpulse.size',{w:parseInt(w),h:parseInt(h)})});return this.hover(function(){var $this=$(this);$this.parent().css('z-index',opts.zIndexActive);var size=$this.data('hoverpulse.size');var w=size.w,h=size.h;$this.stop().animate({top:('-'+opts.size+'px'),left:('-'+opts.size-5+'px'),height:(h+2*opts.size)+'px',width:(w+2*opts.size)+'px'},opts.speed)},function(){var $this=$(this);var size=$this.data('hoverpulse.size');var w=size.w,h=size.h;$this.stop().animate({top:0,left:0,height:(h+'px'),width:(w+'px')},opts.speed,function(){$this.parent().css('z-index',opts.zIndexNormal)})})};$.fn.hoverpulse.defaults={size:20,speed:200,zIndexActive:100,zIndexNormal:1}})(jQuery);

