/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/

function slideSwitch() {
    var $active = $('#photos img.active');

    if ( $active.length == 0 ) $active = $('#photos img:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#photos 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');
        });
}

// Popup window.
function openWindow(path, name, width, height){
	width = width == null ? 800 : width;
	height = height == null ? 600 : height;
	wleft = (screen.width - width) / 2;
	wtop = (screen.height - height) / 2;
	// IE5 and other old browsers might allow a window that is partially offscreen or wider than the screen. Fix that. (Newer browsers fix this for us, but let's be thorough.)
	if (wleft < 0) {
		width = screen.width;
		wleft = 20;
	}
	if (wtop < 0) {
		height = screen.height;
		wtop = 20;
	}
	var win = window.open(path, name, "width=" + width + ", height=" + height + ", " + "left=" + wleft + ", top=" + wtop + ", location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes");
	// Just in case 'width' and 'height' are ignored
	win.resizeTo(width, height);
	// Just in case 'left' and 'top' are ignored
	win.moveTo(wleft, wtop);
	win.focus();
}

