var fl=false;

$(document).ready(function() {
	// hover
	
	$('.images a').each(function(num){
		$(this).data({num:num})						 
	})
	
	var last=0;
	
	$('.images a').hover(function(){
		if (last==$(this).data('num')) {
			$(this).find('> span').css({top:-217}).stop().animate({top:0}, 600, 'easeOutCirc')
		} else {
			if (last==$(this).data('num')+4) {						  
				$(this).find('> span').css({top:217}).stop().animate({top:0}, 600, 'easeOutCirc')	
				$('.images a').eq(last).find('> span').stop().animate({top:-217}, 600, 'easeOutCirc')	
			} else {
				$(this).find('> span').css({top:-217}).stop().animate({top:0}, 600, 'easeOutCirc')
				$('.images a').eq(last).find('> span').stop().animate({top:217}, 600, 'easeOutCirc')	
			}
			last=$(this).data('num');
		}
	}, function(){
			
	})
	
	$('.images').mouseleave(function(){
		if (last==$(this).data('num')+4) {						  
			$('.images a').eq(last).find('> span').stop().animate({top:-217}, 600, 'easeOutCirc')	
		} else {
			$('.images a').eq(last).find('> span').stop().animate({top:217}, 600, 'easeOutCirc')	
		}
		last=0
	})
	
	
	
	$('.menu_trigger span').css({left:-61})
	
	$('.menu_trigger').hover(function(){
		$(this).find('span').stop().animate({left:0}, function(){
			$(this).parent().find('strong').css({left:-2})
		})					  
	}, function(){
		$(this).find('strong').css({left:0})
		$(this).find('span').stop().animate({left:-61}, 600, 'easeOutCirc')					  
	})
	
	$('.menu_trigger').click(function(){
		if (fl) {
			$('header').stop().animate({left:-313}, 600, 'easeOutCirc')
			fl=false
		} else {
			$('header').stop().animate({left:0}, 600, 'easeOutCirc')
			fl=true
		}
		return false
	})
	
	$('.button1 strong').css({opacity:0})
	
	$('.button1').hover(function(){
		$(this).find('strong').stop().animate({opacity:1}) 
	}, function(){
		$(this).find('strong').stop().animate({opacity:0}) 
	})
	
	$('.close span, .prev span, .next span').css({opacity:0})
	
	$('.close, .prev, .next').hover(function(){
		$(this).find('span').stop().animate({opacity:1})					   
	}, function(){
		$(this).find('span').stop().animate({opacity:0})					   
	})
	
	$('ul#menu').superfish({
      delay:       600,
      animation:   {height:'show'},
      speed:       600,
      autoArrows:  false,
      dropShadows: false
    });
	
	//gallery 
	$("#gallery_blind").jCarouselLite({
			btnNext: ".next",
		 	btnPrev: ".prev",
       		mouseWheel: true,
			visible: 2,
			speed: 600,
			easing: 'easeOutCirc'
	});
	
	$('#gallery_blind a').hover(function(){
		$(this).find('img').stop().animate({opacity:0.8})							
	}, function(){
		$(this).find('img').stop().animate({opacity:1})							
	})
	
	$("#gallery_curtain").jCarouselLite({
			btnNext: ".next",
		 	btnPrev: ".prev",
       		mouseWheel: true,
			visible: 2,
			speed: 600,
			easing: 'easeOutCirc'
	});
	
	$('#gallery_curtain a').hover(function(){
		$(this).find('img').stop().animate({opacity:0.8})							
	}, function(){
		$(this).find('img').stop().animate({opacity:1})							
	})
	
		$("#gallery_wallpaper").jCarouselLite({
			btnNext: ".next",
		 	btnPrev: ".prev",
       		mouseWheel: true,
			visible: 2,
			speed: 600,
			easing: 'easeOutCirc'
	});
	
	$('#gallery_wallpaper a').hover(function(){
		$(this).find('img').stop().animate({opacity:0.8})							
	}, function(){
		$(this).find('img').stop().animate({opacity:1})							
	})
	
			$("#gallery_sofasets").jCarouselLite({
			btnNext: ".next",
		 	btnPrev: ".prev",
       		mouseWheel: true,
			visible: 2,
			speed: 600,
			easing: 'easeOutCirc'
	});
	
	$('#gallery_sofasets a').hover(function(){
		$(this).find('img').stop().animate({opacity:0.8})							
	}, function(){
		$(this).find('img').stop().animate({opacity:1})							
	})
	
			$("#gallery_rugs").jCarouselLite({
			btnNext: ".next",
		 	btnPrev: ".prev",
       		mouseWheel: true,
			visible: 2,
			speed: 600,
			easing: 'easeOutCirc'
	});
	
	$('#gallery_rugs a').hover(function(){
		$(this).find('img').stop().animate({opacity:0.8})							
	}, function(){
		$(this).find('img').stop().animate({opacity:1})							
	})
	
			$("#gallery_accessories").jCarouselLite({
			btnNext: ".next",
		 	btnPrev: ".prev",
       		mouseWheel: true,
			visible: 2,
			speed: 600,
			easing: 'easeOutCirc'
	});
	
	$('#gallery_accessories a').hover(function(){
		$(this).find('img').stop().animate({opacity:0.8})							
	}, function(){
		$(this).find('img').stop().animate({opacity:1})							
	})
	
	$("#gallery_hotels").jCarouselLite({
			btnNext: ".next",
		 	btnPrev: ".prev",
       		mouseWheel: true,
			visible: 2,
			speed: 600,
			easing: 'easeOutCirc'
	});
	
	$('#gallery_hotels a').hover(function(){
		$(this).find('img').stop().animate({opacity:0.8})							
	}, function(){
		$(this).find('img').stop().animate({opacity:1})							
	})
	
	$("#gallery_commercial").jCarouselLite({
			btnNext: ".next",
		 	btnPrev: ".prev",
       		mouseWheel: true,
			visible: 2,
			speed: 600,
			easing: 'easeOutCirc'
	});
	
	$('#gallery_commercial a').hover(function(){
		$(this).find('img').stop().animate({opacity:0.8})							
	}, function(){
		$(this).find('img').stop().animate({opacity:1})							
	})
	
		
 });
$(window).load(function() {	
	// scroll
	$('.scroll').cScroll({
		duration:700,
		step:72,
		trackCl:'track',
		shuttleCl:'shuttle'
	})	
	//content switch
	var content=$('#content'),
		nav=$('.menu'),
		footer_nav=$('#footer_menu');
	nav.navs({
		useHash:true						   
	})	
	nav.navs(function(n, _){
		content.cont_sw(n);
	})
	footer_nav.navs({
		useHash:true						   
	})	
	footer_nav.navs(function(n, _){
		content.cont_sw(n);
	})
	content.cont_sw({
		showFu:function(){
			var _=this
			if (_.next.attr('id')=='page_Locations') {
				$('#map').html('<iframe width="400" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=dolson+interiors&amp;aq=&amp;sll=-10.660608,50.273438&amp;sspn=46.719472,86.572266&amp;ie=UTF8&amp;hq=dolson+interiors&amp;hnear=&amp;t=m&amp;cid=17387042270066902460&amp;ll=-6.817055,39.287324&amp;spn=0.007457,0.00912&amp;z=16&amp;output=embed"></iframe>');
			}
			$.when(_.li).then(function(){
				_.next.css({display:'block'}).stop().animate({width:531, paddingLeft:48, paddingRight :48}, 600);
			});
			$('#content').stop().animate({width:627})			
			$('header').stop().animate({left:0})
			fl=true
		},
		hideFu:function(){
			var _=this	
			_.li.stop().animate({width:0, paddingLeft:0, paddingRight:0},600, function(){
				_.li.css({display:'none'});
			})
			$('#content').stop().animate({width:0})
		},
		preFu:function(){
			var _=this
			_.li.css({position:'absolute', display:'none'});
			$('#content').css({width:0})
			$('header').css({left:-313})
		}
	})
	
	var m_top=0,
		h_cont=925;
	function centre() {
		var h=$(window).height();
		if (h>h_cont) {
			m_top=(h-h_cont)/2;
		} else {
			m_top=0
		}
		$('.main').stop().animate({marginTop:m_top})
		
	}
	centre();
	$(window).resize(centre);
})