function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $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()", 5000 );
});

$(document).ready(function() {
    $("a[rel=images]").fancybox({
        'transitionIn'		: 'none',
        'transitionOut'		: 'none',
        'titlePosition' 	: 'over',
        'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
            return '<span id="fancybox-title-over">Photo ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; <br /><b> ' + title : '') + '</span>';
            }   
    });
	
	$(".over img").hover(
	 function()
	 {
	  this.src = this.src.replace("_normal","_hover");
	 },
	 function()
	 {
	  this.src = this.src.replace("_hover","_normal");
	 }
	);
    
});

function add_flash(file, width, height, title) {
    param = width+height;
    document.write('<div id="flash_'+param+'" style="width:'+width+';height:'+height+'px; padding-bottom: 20px; margin-top:20px;"></div>');
 	document.getElementById('flash_'+param).innerHTML = ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + width + '" height="' + height + '" id="txt_title" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="wmode" value="transparent"><param name="movie" value="' + file + '?txt_title=' + title + '" /><param name="quality" value="high" /><embed wmode="transparent" src="' + file + '?txt_title=' + title + '" quality="high" bgcolor="#ffffff" width="' + width + '" height="' + height + '" name="txt_title" align="middle" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
}
