$(function() {

	setInterval( "slideSwitch()", 7000 );


	//opens link in a new window
	$('a[rel=ext]').click(function(){
		window.open(this.href);
	 	return false;
	});
	
	$('div.gallery a').lightBox({
    	//fixedNavigation: true,
		imageLoading: '/images/lightbox/lightbox-ico-loading.gif',
		imageBtnClose: '/images/lightbox/lightbox-btn-close.gif',
		imageBtnPrev: '/images/lightbox/lightbox-btn-prev.gif',
		imageBtnNext: '/images/lightbox/lightbox-btn-next.gif',
		imageBlank: '/images/lightbox/lightbox-blank.gif'
    });
    
    if ($.browser.msie && $.browser.version < 7)
    	{return;}
    else
    	{
			$('div.nav ul li').css('opacity',0);
		    $('div.nav ul li').hover(function(){
		    	$(this).stop().animate({opacity:1},400).addClass('hover');
		    }, function() {
				$(this).stop().animate({opacity:0},400);
		    });
		}

});

//-----------------------------------
//Functions
//-----------------------------------

function slideSwitch() {
    var $active = $('div.slideshow img.active');

    if ( $active.length == 0 ) $active = $('div.slideshow img:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('div.slideshow img: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}, 1500, function() {
            $active.removeClass('active last-active');
        });
}
