
var oc = 100;
var currentPic = 0;
var pics = new Array();
var velocity = 4;



//pics[0] = "images/screenshots/bild1.png";
//pics[1] = "images/screenshots/bild2.png";
//pics[2] = "images/screenshots/bild3.png";

function addPic(newPic) {
	pics[pics.length] = newPic;
}

function fadeOut() {
	
	oc -= velocity;
	
	if(oc > (velocity * 3)) {
		
		if(document.getElementById("scrBig").style.visibility != "visible" ){
			document.getElementById("iScreenshot").style.opacity= '.'+oc;
			document.getElementById("iScreenshot").style.filter = 'alpha(opacity = '+oc+');';
		}
		
		document.getElementById("iScreenshotMax").style.opacity= '.'+oc;
		document.getElementById("iScreenshotMax").style.filter = 'alpha(opacity = '+oc+');';
		
		setTimeout(fadeOut, 1);
		
	} else {
		
		if(document.getElementById("scrBig").style.visibility == "visible" ){
			document.getElementById("iScreenshotMax").setAttribute("src", getBigPic(pics[currentPic]));
			
			if((currentPic+1) < pics.length ) {
				document.getElementById("scrPreload").setAttribute("src", getBigPic(pics[currentPic+1]));
			}
		} else {
			document.getElementById("iScreenshot").setAttribute("src", pics[currentPic]);
			if((currentPic+1) < pics.length ) {
				document.getElementById("scrPreload").setAttribute("src", pics[currentPic+1]);
			}
		}
		
		updateScreenshotCount();
		fadeIn();
		
	}
	
}


function fadeIn(){
	
	oc += velocity;
	
	
	if(document.getElementById("scrBig").style.visibility != "visible" ){
		document.getElementById("iScreenshot").style.opacity= '.'+oc;
		document.getElementById("iScreenshot").style.filter = 'alpha(opacity = '+oc+');';
	}
	
	document.getElementById("iScreenshotMax").style.opacity= '.'+oc;
	document.getElementById("iScreenshotMax").style.filter = 'alpha(opacity = '+oc+');';
	if(oc < 100) {
		setTimeout(fadeIn, 1);
	} else {
		document.getElementById("iScreenshot").style.opacity= '';
		document.getElementById("iScreenshot").filter = '';
		document.getElementById("iScreenshotMax").style.opacity= '';
		document.getElementById("iScreenshotMax").filter = '';
	} 
	
}

function fade(){
	
	oc = 100;
	fadeOut();
}

function nextPic() {
	
	currentPic += 1;
	
	if(currentPic >= pics.length){
		currentPic = 0;
	}
	
	oc = 100;

	fade();
}

function updateScreenshotCount(){
	$("#dScrCount").html(getCurrentPic() + "/" + getPicCount());
	$("#dScrBigCount").html(getCurrentPic());
	
}

function prevPic() {
	
	currentPic -= 1;
	
	if(currentPic < 0){
		currentPic = pics.length -1;
	}
	
	fade();
}

function getBigPic(smallpic) {
	
	return bigSrc = smallpic.substring(0, smallpic.length -4) + "_big."+ smallpic.substring(smallpic.length -3, smallpic.length);
}

function maximize(){
	
	
	
	var smallSrc = document.getElementById("iScreenshot").getAttribute("src");
	
	var bigSrc = smallSrc.substring(0, smallSrc.length -4) + "_big."+ smallSrc.substring(smallSrc.length -3, smallSrc.length);

	document.getElementById("iScreenshotMax").setAttribute("src", bigSrc);

	if((currentPic+1) < pics.length ) {
		document.getElementById("scrPreload").setAttribute("src", getBigPic(pics[currentPic+1]));
	}
	
	show('scrBig');
	
}

function getPicCount(){
	return pics.length;
}

function getCurrentPic(){
	return currentPic + 1;
}

