/*   
Theme Name: Warface
Author: Rob Cleaton
Author URI: http://www.warface.co.uk
*/

// Expand Panel




// Next Project Hover Slider
$(function(){

//To switch directions up/down and left/right just place a "-" in front of the top/left attribute

	//Full Caption Sliding (Hidden to Visible) NEXT PROJECT
		$('.boxgrid.captionfull.right').hover(function(){
			$(".cover", this).stop().animate({right:'0px'},{queue:false,duration:400}); //Position on rollover
		},function() {
			$(".cover", this).stop().animate({right:'-380px'},{queue:false,duration:400}); //Position on rollout
		});
	
	//Full Caption Sliding (Hidden to Visible) PREVIOUS PROJECT
		$('.boxgrid.captionfull.left').hover(function(){
			$(".cover", this).stop().animate({left:'0px'},{queue:false,duration:400}); //Position on rollover
		},function() {
			$(".cover", this).stop().animate({left:'-380px'},{queue:false,duration:400}); //Position on rollout
		});
		
		
	//Full Caption Sliding (Hidden to Visible) SLIDING TWITTER
		$('.slidingtwitter').hover(function(){
    		$(this).stop().animate({right:'0px'},{queue:false,duration:400});
		},function(){
    		$(this).stop().animate({right:'-150px'},{queue:false,duration:400});
		});
	
		//Full Caption Sliding (Hidden to Visible) NEXT PROJECT
		$('.project-thumb.caption').hover(function(){
			$(".cover", this).stop().animate({left:'0%'},{queue:false,duration:0}); //Position on rollover
		},function() {
			$(".cover", this).stop().animate({left:'100%'},{queue:false,duration:0}); //Position on rollout
		});
		
	//Full Caption Sliding (Hidden to Visible) NEXT PROJECT
		$('.client.caption').hover(function(){
			$(".cover", this).stop().animate({left:'0%'},{queue:false,duration:0}); //Position on rollover
		},function() {
			$(".cover", this).stop().animate({left:'100%'},{queue:false,duration:0}); //Position on rollout
		});


	//Fade Client List logos
    	$('.clients img').hover(function(){
 			$(this).parents('.logos').find('img').not(this).animate({"opacity": "0.3"}, 200);
			$(this).animate({"opacity": "1"}, 200);
        },function(){
			$(this).animate({"opacity": "1"}, 200);
        });
        $('.logos').bind('mouseleave',function(){$(this).find('img').animate({"opacity": "1"}, 100);});
		
	});



// Scroll to top
$(function(){
  $('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}, 1000);
       return false;}
    }
  });
// Scroll to top END
    
});



/*** Slideshow - Released by Jon Raasch (jonraasch.com) ***/

function slideSwitch() {
    var $active = $('#slideshow li.active');

    if ( $active.length == 0 ) $active = $('#slideshow li:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow li:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
	}

	$(function() {
    	setInterval( "slideSwitch()", 4000 );
});


