/* FadeShow 1.0
 * Author: Daniel Kovalev (http://dan-online.net)
 * Last Change: 2009-10-30 01:10
 * jQuery 1.3.2+ is required (http://jquery.com/)
 */

/* --------- CONFIGURATION --------- */
var firstPic = 0;
var lastPic = 13;
var picName = "http://www.heimschiesskino.de/wp-content/themes/laserschuss/images/fadeshow/";
var picFormat = ".jpg";
var speed = 5000; // in ms
var fadeSpeed = 1000; // in ms
/* --------------------------------- */

var pics = new Array(lastPic + 1);
var currentPic = 0;
var nextPic = 0;

jQuery(document).ready(function() {
	for(var i=0; i<=lastPic; i++) {
		pics[i] = new Image();
		pics[i].src = picName + num2(i) + picFormat;
	}
	swapBg();
	var theShow = window.setInterval("fadeShow()", speed);
});

function num2(a) {
	return (a < 10) ? ("0" + a) : a;
}

function fadeShow() {
	jQuery("#fsimg").animate({opacity: 0}, fadeSpeed, "linear", incPic());
}

function incPic() {
	currentPic = nextPic;
	nextPic = (nextPic == lastPic) ? 0 : (nextPic + 1);
	swapBg();
}

function swapBg() {
	jQuery("#fsimg").attr("src", pics[currentPic].src).css("opacity", 1);
	jQuery("#fsdiv").css("backgroundImage", "url("+pics[nextPic].src+")");
}

/* End of FadeShow */


function windowPopup(url, width, height) {
  videoWindow = window.open(url, "", "width="+width+",height="+height+",scrollbars=yes");
  videoWindow.focus();
}