$(document).ready(function () {
    //Examples of how to assign the ColorBox event to elements
    $("a[rel='example1']").colorbox({ height: "85%" });
    $(".example5").colorbox();
    $(".example6").colorbox({ iframe: true, innerWidth: 760, innerHeight: 435 });
    $(".example7").colorbox({ width: "655", height: "480", iframe: true });
    $(".example8").colorbox({ width: "525", height: "500", inline: true, href: "#harita" });
    $(".example9").colorbox({
        onOpen: function () { alert('onOpen: colorbox is about to open'); },
        onLoad: function () { alert('onLoad: colorbox has started to load the targeted content'); },
        onComplete: function () { alert('onComplete: colorbox has displayed the loaded content'); },
        onCleanup: function () { alert('onCleanup: colorbox has begun the close process'); },
        onClosed: function () { alert('onClosed: colorbox has completely closed'); }
    });
    //Example of preserving a JavaScript event for inline calls.
    $("#click").click(function () {
        $('#click').css({ "background-color": "#f00", "color": "#fff", "cursor": "inherit" }).text("Open this window again and this message will still be here.");
        return false;
    });
});
$(document).ready(function() {
	
	// hover
	
	$('#menu > li > a > span').css({ opacity:'0.2'})
	
	$('#menu > li > a').hover(function(){
		if (!$(this).parent().hasClass('active')) {
			$(this).parent().find('> span').css({display:'block'}).find('img').stop().animate({marginTop:'0', marginLeft:'0', width:'100%', height:'100%'}, 600, 'easeOutCirc')							 
		}
	}, function(){
		if (!$(this).parent().hasClass('sfHover')) {
			$(this).parent().find('> span img').stop().animate({marginTop:'212', marginLeft:'208', width:'0', height:'0'},600, 'easeInCirc', function(){$(this).parent().css({display:'none'})})							 
		}
	})
	
	$('.prev span, .next span, .button1 span').css({opacity:'0'})
	
	$('.prev, .next, .button1').hover(function(){
		$(this).find('span').stop().animate({opacity:'1'})							 
	}, function(){
		$(this).find('span').stop().animate({opacity:'0'})							 
	})
	
	
	//gallery 
	$(".gallery1").jCarouselLite({
			btnNext: ".next",
		 	btnPrev: ".prev",
       		mouseWheel: true,
			visible: 1,
        	vertical: false,
			speed: 600,
			easing: 'easeOutCirc'
	});
	$(".gallery2").jCarouselLite({
			btnNext: ".next",
		 	btnPrev: ".prev",
       		mouseWheel: true,
			visible: 1,
        	vertical: false,
			speed: 600,
			easing: 'easeOutCirc'
	});
	
	$('.gallery3 a .bg').css({opacity:'0.02'})
	$('.gallery3 a .img_act').css({opacity:'0'})
	
	$('.gallery3 a').hover(function(){
		$(this).find('.bg').stop().animate({opacity:'0.1'})
		$(this).find('.img_act').stop().animate({opacity:'1'})
	}, function(){
		$(this).find('.bg').stop().animate({opacity:'0.02'})
		$(this).find('.img_act').stop().animate({opacity:'0'})
	})
	
	//menu
	$('#menu').superfish({
      delay:       600,
      animation:   {opacity:'show', height:'show'},
      speed:       600,
      autoArrows:  false,
      dropShadows: false
    });
	
	
	//content switch
	
	var content=$('#content'),
		nav=$('.menu');
	nav.navs({
		useHash:true,
		hover:true
	})	
	nav.navs(function(n, _){
			$('#menu > li').find('> a strong').stop().animate({height:'100%'}, function(){
				$('#menu > .active').find('> a strong').stop().animate({height:'0'})																		
			});
			content.cont_sw(n);
			Cufon.replace($('#menu > li').eq(_.n).siblings().find('a'), { fontFamily: 'Bebas', color:'#fff'  });
			if (_.n>=0) {
				$('#menu > li').eq(_.n).find('> span img').stop().animate({marginTop:'212', marginLeft:'208', width:'0', height:'0'},600, 'easeInCirc', function(){
					$('#menu > li').eq(_.n).find('> a strong').stop().animate({height:'0'})
					Cufon.replace($('#menu > li').eq(_.n).find('a'), { fontFamily: 'Bebas', color:'#414141' });
				})
			} else {
				$('#menu > li').find('> a strong').stop().animate({height:'100%'});
				Cufon.replace($('#menu > li').find('a'), { fontFamily: 'Bebas', color:'#fff'  });
			}
	})	
	content.cont_sw({
		showFu:function(){
			var _=this
			$.when(_.li.find('.box')).then(function(){				  
				_.next.css({display:'block', position:'relative'}).find('.box').stop().animate({opacity:'1'},600, function(){$(this).css({opacity:'none'})})	
			});	
				var height_cont=_.next.height();
				$('#content').stop().animate({height:height_cont},1000)
			$('.menu').stop().animate({marginTop:'0'},1000, 'easeOutCirc');
		},
		hideFu:function(){
			var _=this
			_.li.find('.box').stop().animate({opacity:'0'},600,function(){
				_.li.css({display:'none', position:'absolute'})													
			})
			$('#content').stop().animate({height:'0'},1000)
		},
		preFu:function(){
			var _=this
			_.li.css({position:'absolute', display:'none'});
			$('#content').css({height:'0'})
		}
	})
	setHeight();
	h=new_h;
	center_box();
	var h_cont=857;
	function setHeight(){
		new_h=$(window).height();
		if ($('#content').css('height')!='0px') {h_cont=9999} else {h_cont=577}
	}
	setInterval(setNew,60);
	function setNew(){
		setHeight();
		if ((h!=new_h)) {
			h=new_h;
			center_box();
		}
	}
	function center_box(){
		if (h>h_cont) {
			m_top=~~((h-h_cont)/2);
		} else m_top=0
		$('.menu').stop().animate({marginTop:m_top},1000, 'easeOutCirc');
	}	
	
})

