var time_preloaddelay=300
var time_animate=2000
var time_switch= 3000+time_animate

sfHover = function() {
	var bName = navigator.appName;
	if(bName=="Microsoft Internet Explorer")
	{
		if(document.getElementById("nav"))
		{
			var sfEls = document.getElementById("nav").getElementsByTagName("LI");
			for (var i=0; i<sfEls.length; i++) {
				sfEls[i].onmouseover=function() {
					this.className+=" sfhover";
				}
				sfEls[i].onmouseout=function() {
					this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
				}
			}
		}
	}
}
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}, time_animate, function() {
			$active.removeClass('active last-active');
		});
}

$(document).ready(function(){
	$('.external').attr('target','_blank')
	sfHover()
	$('#slideshow img').css({opacity: 0.0});
	$('#slideshow img:first').css({opacity: 1.0});
	$('#slideshow img:first').addClass('active');

	vCycleImages = setInterval(function() {
		var bImgLoaded = true;
		var images = $("#slideshow img");

		for (var i = 0; i < images.length; i++) {
			var img = images[i];
			if (img.complete == false)
				bImgLoaded = false;
		}

		if (bImgLoaded) {
			setInterval( "slideSwitch()", time_switch);
			clearInterval(vCycleImages);
		}
	}, time_preloaddelay);
});