/*
AGLSW.10
JS FUNCTIONS
13.213.455.0618
All rights reserved (c) 2010
*/

function slideLogin() {
$('#mylogin .login').slideDown('normal');
$('#mylogin h4').addClass('clicked');
}


function slidemenu() {
	
	var easewhat = "easeInOutCubic";
	
	  $("ul#workslist li ul").hide();
	  $("ul#workslist li ul:first").show();
			
	  
		$("ul#workslist li.menuitem h3").click(function() {
		
			var checkElement = $(this).next();
			var parent = this.parentNode.parentNode.id;
			
				if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				$('#' + parent + ' ul:visible').slideUp('normal');
				$('#' + parent + ' ul:visible').removeClass('clicked');
				
				if (!checkElement.hasClass('clicked'))
				checkElement.slideDown('normal');
				checkElement.addClass('clicked');
			
				return false;
					} else {
				checkElement.slideUp('normal');
				checkElement.removeClass('clicked');

					}
				});

		
} //slidemenu


$(document).ready(function() {

	/* SLIDE WORKS */
	slidemenu();

	function muovislide(aa){	
	
		var triggerID = ($active.attr("rel").substr(-1,1)) - 1;
		alunni = new Array(0, 575, 1150);
		var sposta = alunni[triggerID];
		
		$active.addClass('active');

		$(aa+" .image_reel").stop(true,false).animate({ 
			left: -sposta
		}, 600, "easeOutExpo" );
		
	}
		
		
	
	$('.slideshow .paging a.imgitem').mouseover (function(){
	
	$active = $(this);
	muovislide("#"+$(this).parent().attr("rel"));
		
    $(this).find('img').stop(true,true).animate({ 
			opacity: .3
	}, 300);
	});  
	
	$('.slideshow .paging a.imgitem').mouseleave (function(){

     $(this).find('img').stop(true,true).animate({ 
			opacity: 1
	}, 500);
	}); 
		
	
	
	
		
	$('#thegrid').click (function(){
		$('#showmegrid').text('show grid');
		$('#showmegrid').removeClass('clicked');
		$('#showmegrid').css({'background':'url(http://www.lexskywalker.it/wp-content/themes/lexskywalker/jscss/gridbt.png) repeat-y center top','color':'#ddd'});
		$(this).stop(true,true).fadeOut( 1800, "easeOutExpo");
	});
	
	
	
		$('#maincontent').show();
		$('#footer').show();
		$('#preloader').hide();
		
	
  $("#searchform label").inFieldLabels();
  

  

$("a.common-zoom").fancybox({
				'overlayShow':true,
				'overlayColor':'#e8eff1',
				'hideOnOverlayClick':'true',
				'hideOnContentClick':'true',
				'centerOnScroll' :	 'true',
				'overlayOpacity':'.8',
				'titlePosition'	:	'over',
				'margin':'10',
				'padding':'5',
				'enableEscapeButton':'true',
				'transitionIn'	: 'fade',
				'transitionOut'	: 'elastic',
				'showNavArrows' : 'false',
				'showCloseButton' : 'false'
			});	

$("a#image-zoom").fancybox({
				'overlayShow':true,
				'overlayColor':'#e8eff1',
				'hideOnOverlayClick':'true',
				'hideOnContentClick':'true',
				'centerOnScroll' :	 'true',
				'overlayOpacity':'.8',
				'titlePosition'	:	'over',
				'margin':'10',
				'padding':'5',
				'enableEscapeButton':'true',
				'transitionIn'	: 'fade',
				'transitionOut'	: 'elastic'
			});
				
		  
 $('a[href*=#]').click(function() {
	if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
	&& location.hostname == this.hostname) {
	  var $target = $(this.hash);
	  $target = $target.length && $target
	  || $('[name=' + this.hash.slice(1) +']');
	  if ($target.length) {
		var targetOffset = $target.offset().top;
		$('html,body').animate({scrollTop: targetOffset}, 800, "easeInOutExpo" );
	   return false;
	  }
	}
  }); 

 
  $('#mylogin h4').click(function(){
  
 	if ($(this).hasClass('clicked')) {
		$('#mylogin .login').slideUp('normal');
		$(this).removeClass('clicked');
		} else {
		$('#mylogin .login').slideDown('normal');
		$(this).addClass('clicked');	
	}
  });


	$('a img.wp-post-image').mouseover (function(){
     $(this).css('border','5px #5dbfe3 solid');
	});  
	
	$('a img.wp-post-image').mouseleave (function(){
     $(this).css('border','5px #f1f1f1 solid');
	});  

	$('#lastgal ul li').mouseover (function(){
	 $(this).find('img').stop(true,true).animate({ 
			opacity: .3
	}, 300);
	 
	 var titleimg = $(this).find('img').attr('title');
	 
	 if (titleimg.length > 60) {
	 titleimg = titleimg.substring(0, 60) + '..';
	 }
	  
	 $('#lastworks h4').text(titleimg); 
	  
     });
     
	$('#lastgal ul li').mouseout (function(){
     $(this).find('img').stop(true,true).animate({ 
			opacity: 1
	}, 500);
	
	  $('#lastworks h4').html('<strong>Gli ultimi 6 lavori inseriti..</strong>'); 
	 }); 
	 
	 
	 $('#thelogogal').mouseover (function(){
	 $('.thegalimgdue').stop(true,true).fadeIn();
	 $('.thegalimguno').stop(true,true).fadeOut();
	 });    
	
	 $('#thelogogal').mouseout (function(){
	 $('.thegalimgdue').stop(true,true).fadeOut();
	 $('.thegalimguno').stop(true,true).fadeIn();
	 });    
	


			
				


/* FINE DOCUMENT READY */ });


$(document).pngFix();


