/*
Phil Renaud the mad scientist behind this.
phil@rhinointernet.com
http://rhinointernet.com
*/



$(document).ready(function(){

   if ($('body').is('.home')) {
      slider();
   }
	
});






/*==( Homepage Animated Slider )======================================================*/

function slider() {

   $('#hero').append('<div class="panelnav"></div>');
   $('.panelnav').append('<a href="#" class="goleft" title="Previous">Previous</a><a href="#" class="goright" title="Next">Next</a>');
   
   $('.panel').each(function(){
   $(this).css({'display': 'none'});
   }); //each panel
   
   $('.panelcontainer').children('li:first-child').addClass('active').css({'display': 'block'});
   
   
   
   looper = setInterval (function(){
      $('.goright').click();
   }, 5000); //bigpromotionloop
   
   
   
   
   gofunctions();      
   };//slider
   function gofunctions(){
   $('.goright').live('click', function(){
   $('.goright').die();
	$('.goleft').die();
	setTimeout(function(){
	gofunctions();
	}, 1000);
   if ($('.panelcontainer').children('li').is(':animated')){
   } else {
      if ($('.panelcontainer').children('li:last-child').is('.active')) {
         setTimeout (function(){
            $('.panelcontainer').children('.active').fadeOut(1000).removeClass('active').siblings('li:first-child').addClass('active').fadeIn(1000);
         }, 500);
         
      } else {
         setTimeout (function(){
            $('.panelcontainer').children('.active').fadeOut(1000).removeClass('active').next('li').addClass('active').fadeIn(1000);
         }, 500);
         
      }; //if active
   }; //if animated
   	clearInterval(looper);
			looper = setInterval (function(){
				$('.goright').click();
		}, 5000); //bigpromotionloop
      return false;
   }); //click
   
   
   $('.goleft').live('click', function(){
   $('.goright').die();
	$('.goleft').die();
	setTimeout(function(){
	gofunctions();
	}, 1000);
   if ($('.panelcontainer').children().children('div').is(':animated')) {
   } else {
      if ($('.panelcontainer').children('li:first-child').is('.active')) {
         setTimeout (function(){
            $('.panelcontainer').children('.active').fadeOut(1000).removeClass('active').siblings('li:last-child').addClass('active').fadeIn(1000);
         }, 500);
         
      } else {
         setTimeout (function(){
            $('.panelcontainer').children('.active').fadeOut(1000).removeClass('active').prev('li').addClass('active').fadeIn(1000);
         }, 500);
         
      }; //if active
   }; //if animated
		clearInterval(looper);
			looper = setInterval (function(){
				$('.goright').click();
		}, 5000); //bigpromotionloop
      return false;
   }); //click


}; //gofunctions
