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



$(document).ready(function(){
if ($('body').is('.home')){
theloops();
}; //if
if ($('ul.gallery').length){
initializefancybox();
}; //if
});




/*==( Fancybox )======================================================*/

function initializefancybox() {
$("ul.gallery li a").fancybox({
	'transitionIn'		: 'elastic',
	'transitionOut'		: 'elastic',
	'titlePosition' 	: 'over',
	'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
		return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
	}
});
$("a.viewlarger").fancybox({
	'transitionIn'		: 'elastic',
	'transitionOut'		: 'elastic',
	'titlePosition' 	: 'over',
	'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
		return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
	}
});
}; //initializefancybox










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

function theloops() {
   heroloop = setInterval(function(){
      theheroloop();
   }, 10000); //heroloop
   subheroloop = setInterval(function(){
      thesubheroloop();
   }, 10000); //subheroloop
   
   setshadow();
}; //thumbnailhover

function setshadow(){
$('body').append('<div class="slidershadow"></div>');
}; //setshadow


function theheroloop() {


      if ($('.images').children('img.active').is(':last-child')) {
         $('.images').children('img.active').hide(1000).removeClass('active').siblings('img:first').show(1000).addClass('active');
      } else {
         $('.images').children('img.active').hide(1000).removeClass('active').next('img').show(1000).addClass('active');
      }; //if last



//$('.images').children('img.active').hide(1000).removeClass('active').siblings('img:first').show(1000).addClass('active');
}; //theheroloop

function thesubheroloop() {

$('.lowerhero').animate({'top': '50px'}, {duration: 800, easing: 'easeOut'}).animate({'top': '50px'}, 50).animate({'top': '275px'}, {duration: 800, easing: 'easeOut'});
      if ($('.lowerhero').children('img.active').is(':last-child')) {

   setTimeout(function(){
      $('.lowerhero').children('img.active').hide(50).removeClass('active').siblings('img:first').show(50).addClass('active');
   }, 800); //heroloop

      } else {

   setTimeout(function(){
      $('.lowerhero').children('img.active').hide(50).removeClass('active').next('img').show(50).addClass('active');
   }, 800); //heroloop
      }; //if last


}; //theheroloop

