//SETTINGS
	//BACKGROUND
		var delayed_launch = 0; 		//  [ 0 / 1 ]													//  Enable/disable "screensaver" mode
		var text1 = "Fweibel.com";																		//  Large text (or <IMG>, example: for a logo)
		var text2 = "3d images";																		//  Medium text (or <IMG>)
		var delay = 120.0; 				//  [ s ]														//  Time of inactivity before launching the jincko
		var fade_in = 2.0; 				//  [ s ]														//  Fade in effect duration
		var fade_out = 0.5; 			//  [ s ] 														//  Fade out effect duration
		var fade_type = 1;				//  [ 1 = linear / 2 = cubic ]
		var background_opacity = 90; 	//  [ % ]														//  Amount of opacity
		
	//IMAGES
		var slideshow = 2; 				//  [ 0 = disable / 1 = ordered / 2 = random ]					//  Type of slideshow
		var images_still_time = 0.0; 	//  [ s ] 														//  Time the image stays fully visible
		var images_fading_time = 4.0; 	//  [ s ]														//  Fade in/out effect duration
		var images_spacing_time = 0.5;	//  [ s ]														//  Time between images (to avoid override error due to image change computation time)
		var images_size = 40;			//  [ % ]														//  Size of the images (% of windows height
		var zoom = 0;					//  [ 0 = disable / 1 = linear / 2 = cubic ]					//  Enable/disable the zoom effect of images
			var zoom_factor = 0.3;		//  [ 0 - 1 ]													//  growning amount of the image
		var slide1 = "1"; 				//  [ 0 = disable / 1 = linear / 2 = cubic ]					//  Enable/disable the movement of images
			var direction1 = "1";		//  [ 1 = Left-right / 2 = right-left / 3 = Down / 4 = Up ]		//  Direction of the slide
			var slide_length1 = 1.0; 	//  [ 0 - 10 ]													//  Length factor of the movement
			var pingpong1 = 0;			//  [ 0 / 1 ]													//  Enable/disable the ping-pong effect (ex: left-center-left / left-center-right)
		var slide2 = "0";
			var direction2 = "4";
			var slide_length2 = 0.1;
			var pingpong2 = 1;
		
	//MISC
		var display_clock = 1;			//  [ 0 / 1 ]													//  Display/hide clock

//IMAGES LIST
var imglist = new Array(
"creations/big/anotherdimension.jpg",
"creations/big/atomicbomb.jpg",
"creations/big/caprice.jpg",
"creations/big/castle.jpg",
"creations/big/cataclysmII.jpg",
"creations/big/tentation.jpg",
"creations/big/collision.jpg",
"creations/big/desert.jpg",
"creations/big/fa18.jpg",
"creations/big/fa18-2.jpg",
"creations/big/fusee2.jpg",
"creations/big/fusee.jpg",
"creations/big/lighthouse.jpg",
"creations/big/pingouin.jpg",
"creations/big/psychoh.jpg",
"creations/big/punch1.jpg",
"creations/big/see.jpg",
"creations/big/strangecity.jpg",
"creations/big/train.jpg",
"creations/big/weibeltx1.jpg",
"creations/big/eyes.jpg",
"creations/big/portrait.jpg",
"creations/big/mansia.jpg",
"creations/big/tatjana.jpg",
"creations/big/malea.jpg",
"creations/big/blacktower.jpg",
"creations/big/dreaming.jpg",
"creations/big/landscape.jpg"
);












//##############################     CREDITS     ##############################
//		"jincko" - Version 1.4.1
//		Script created by F.Weibel
//		Please visit Fweibel.com
//
//		ISSUES
//			-IMG vertical centering
//			-X,Y re-initialisation
//#####################################################################

var credits = "<a href='http://fweibel.com/jincko.php'>jincko</a>";
var closer = '<h1 onclick="javascript: background_fadeout()" style="position: absolute; color: white; top: 1px; right: 10px; padding: 0px 5px 0px 5px; font-weight: normal; border: 1px solid white; cursor: pointer; cursor: hand;">X</h1>';
var divclock = '<h1 style="position: absolute; color: #222; top: 70px; right: 70px; margin: 0px;" id="clock"></h1>';
var texts = '<h1 id="jincko_text1" style="font-size: 60px; color: #333;position: absolute; bottom: 80px;left: 70px; margin: 0px;"></h1><h2 id="jincko_text2" style="font-size: 20px;color: #222;position: absolute; bottom: 70px; left: 70px; margin: 0px; letter-spacing: 10px;"></h2>';
var info_area = '<h3 id="info_area" style="position: absolute; color: #333; top: 0px; left: 0px; margin: 5px; font-weight: normal;">'+credits+'</h3>';
var imgelement = '<img id="createdimg" style="border: 1px solid #333; height: 100%; position: relative; opacity: 0; filter: alpha(opacity=0); KhtmlOpacity: 0;" />';

var interval_slideshow = 0;
var a = 0;
var s = 0;
var instance = 0;
var stop_onmousemove = 0;
var info = 0;
var firstimg = -1;

document.onmousemove = mousemov;
document.onscroll = mousemov;
document.onclick = mousemov;
window.onload = init;
document.onscroll = divmov;

function init() {
	if (delayed_launch == 1){
		interval_counter = setInterval("increment()", 1000);
	}
	var backgrounddiv = document.createElement("div");
	backgrounddiv.style.position = "absolute";
	backgrounddiv.style.background = "black";
	backgrounddiv.style.height = "100%";
	backgrounddiv.style.width = "100%";
	backgrounddiv.style.opacity = "0";
	backgrounddiv.style.MozOpacity = "0";
	backgrounddiv.style.KhtmlOpacity = "0";
	backgrounddiv.style.filter = "alpha(opacity=0)";
	backgrounddiv.style.zindex = "999";
	backgrounddiv.style.display = "none";
	backgrounddiv.style.top = "0";
	backgrounddiv.style.left = "0";
	backgrounddiv.style.cursor = "none";
	backgrounddiv.style.textAlign = "center";
	backgrounddiv.style.overflow = "hidden";
	backgrounddiv.id = "background";
	backgrounddiv.innerHTML = divclock+texts;
	document.body.appendChild(backgrounddiv);
	info = document.getElementById("info_area");
	
	var virtualdiv = document.createElement("div");
	virtualdiv.style.position = "absolute";
	virtualdiv.style.background = "transparent";
	virtualdiv.style.height = "100%";
	virtualdiv.style.width = "100%";
	virtualdiv.style.zindex = "999";
	virtualdiv.style.display = "none";
	virtualdiv.style.top = "0";
	virtualdiv.style.left = "0";
	virtualdiv.style.overflow = "hidden";
	virtualdiv.id = "virtualdiv";
	virtualdiv.innerHTML = info_area+closer+'<div id="divcontent" style="position: relative; top: '+(100-images_size)/2+'%; height: '+images_size+'%; width: 100%; margin: auto; text-align: center;">'+imgelement+'</div>';
	document.body.appendChild(virtualdiv);
	
	document.getElementById("jincko_text1").innerHTML = text1;
	document.getElementById("jincko_text2").innerHTML = text2;
}

function divmov(){
	document.getElementById("background").style.top = getScrollY()+"px";
	document.getElementById("virtualdiv").style.top = getScrollY()+"px";
}

function increment(){
	s = s + 1;
	if (s == delay && instance != 1){
		jincko("stop_onmousemove");
	}
}
function jincko(e){
	if (e == "stop_onmousemove"){
		stop_onmousemove = 1;
	}
	instance = 1;
	s = delay + 1
	document.body.style.overflow = "hidden";
	document.getElementById("background").style.top = getScrollY()+"px";
	document.getElementById("background").style.display = "block";
	document.getElementById("virtualdiv").style.top = getScrollY()+"px";
	document.getElementById("virtualdiv").style.display = "block";
	smooth("background", 0, background_opacity, fade_in*1000);
	setTimeout(function changeA(){a = 1;}, fade_in*1000);
	if (display_clock == 1){
		clock();
	}
	if (slideshow != 0){
		preloader()
		launchimg()
	}
}
function launchimg(){
	interval_slideshow = setInterval("changeimg()", (parseInt(images_still_time) + parseInt(images_fading_time*2) + parseInt(images_spacing_time))*1000);
}
function changeimg(){
	switch(slideshow){
		case 1: document.getElementById("createdimg").src = nextimg();
		break;
		case 2: document.getElementById("createdimg").src = randimg();
		break;
	}
	smooth("createdimg", 0, 100, images_fading_time*1000);
	smooth("createdimg", -100, 0, images_fading_time*1000, "position");
	interval_imageopac = setTimeout("smooth('createdimg', 100, 0, images_fading_time*1000)", (parseInt(images_still_time) + parseInt(images_fading_time))*1000);
	interval_imagemotion = setTimeout("smooth('createdimg', 0, 100, images_fading_time*1000, 'position')", (parseInt(images_still_time) + parseInt(images_fading_time))*1000);
}
function mousemov() {
	s = 0;
	if (stop_onmousemove == 1){
		if (a == 1){
			background_fadeout();
			a = 0;
			stop_onmousemove == 0;
		}
	}
}
function background_fadeout(){
	smooth("background", background_opacity, 0, fade_out*1000);
	setTimeout("stop()", fade_out*1000);
	clearInterval(interval_slideshow);
	document.body.style.overflow = "visible";
}
function stop(){
	instance = 0;
	document.getElementById("background").style.display = "none";
	document.getElementById("virtualdiv").style.display = "none";
}



function preloader(){
	var p = 0;
	for (p = 0; p < imglist.length; p++) {
		imageObj = new Image;
		imageObj.src = imglist[p];
	}
}
function clock() {
	UR_Nu = new Date;
	UR_Indhold = showFilled(UR_Nu.getHours()) + ":" + showFilled(UR_Nu.getMinutes()) + ":" + showFilled(UR_Nu.getSeconds());
	document.getElementById("clock").innerHTML = UR_Indhold;
	setTimeout("clock()",1000);
}
function showFilled(Value) {
	return (Value > 9) ? "" + Value : "0" + Value;
}
function randimg(){
	idimg = Math.round(Math.random()*(imglist.length-1),0);
	var img = imglist[idimg];
	return img;
}
function nextimg(){
	if(firstimg == imglist.length-1){
		firstimg = 0;
	}else{
		firstimg = firstimg + 1;
	}
	var img = imglist[firstimg];
	return img;
}
function getScrollY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == "number" ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && ( document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && ( document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY;
}
function smooth(id, opacStart, opacEnd, millisec, style) {
    var speed = Math.round(millisec / 100);
    var timer = 0;
	if(style == "position"){
		fonction = "changePosition";
	}else{
		fonction = "changeOpacity";
	}
	var i = 0;
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout(fonction+"(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++){
            setTimeout(fonction+"(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}
function changeOpacity(value,id){
    var object = document.getElementById(id).style;
	switch(fade_type){
		case 1:
		var opacity = value;
		break;
		case 2:
		var opacity = Math.sqrt(10000 - Math.pow(value/(-1)+100,2));
		break;
	}
    object.opacity = opacity/100;
    object.MozOpacity = opacity/100;
    object.KhtmlOpacity = opacity/100;
    object.filter = "alpha(opacity=" + opacity + ")";
}
function changePosition(value, id) {
	var object = document.getElementById(id).style;
	var divcontent = document.getElementById("divcontent").style;
	var screenwidth = document.body.clientWidth/4;
	var screenheight = document.body.clientHeight/4
	
	if (zoom != 0){
		var linear = (((Math.sqrt(value*value))/(-100)+1)*100*zoom_factor)+((1-zoom_factor)*100);//special cace-dédi >MAMS< ! 
		var cubic = (Math.sqrt(10000 - Math.pow(value,2))*zoom_factor)+((1-zoom_factor)*100);
		switch(zoom){
			case 1: object.height = linear+"%"; 
			break;
			case 2: object.height = cubic+"%"; 
			break;
		}
	}
	
	if(pingpong1 == "1"){
		var value1 = Math.sqrt(value*value)/100;
	}else{
		var value1 = value/100;
	}
	if (slide1 != "0"){
		var linear1 = value1*screenwidth*slide_length1;
		var cubic1 = linear1*Math.pow(value, 2)/10000;
		switch (direction1){
			case "1":
				if (slide1 == "1"){
					object.left = linear1+"px";
				}else if (slide1 == "2"){
					object.left = cubic1+"px";
				}break;
			case "2":
				if (slide1 == "1"){
					object.right = linear1+"px";
				}else if (slide1 == "2"){
					object.right = cubic1+"px";
				}break;
			
			case "3":
				if (slide1 == "1"){
					object.top = linear1+"px";
				}else if (slide1 == "2"){
					object.top = cubic1+"px";
				}break;
			case "4":
				if (slide1 == "1"){
					object.bottom = linear1+"px";
				}else if (slide1 == "2"){
					object.bottom = cubic1+"px";
				}break;
		}
	}
	
	if(pingpong2 == "1"){
		var value2 = Math.sqrt(value*value)/100;
	}else{
		var value2 = value/100;
	}
	var linear2 = value2*screenwidth*slide_length2;
	var cubic2 = linear2*Math.pow(value, 2)/10000;
	if (slide2 != "0"){
		switch (direction2){
			case "1":
				if (slide2 == "1"){
					divcontent.left = linear2+"px";
				}else if (slide2 == "2"){
					divcontent.left = cubic2+"px";
				}break;
			case "2":
				if (slide2 == "1"){
					divcontent.right = linear2+"px";
				}else if (slide2 == "2"){
					divcontent.right = cubic2+"px";
				}break;
			case "3":
				if (slide2 == "1"){
					divcontent.top = linear2/9.06+(100-images_size)/2+"%";
				}else if (slide2 == "2"){
					divcontent.top = cubic2/9.06+(100-images_size)/2+"%";
				}break;
			case "4":
				if (slide2 == "1"){
					divcontent.top = linear2/9.06*(-1)+(100-images_size)/2+"%";
				}else if (slide2 == "2"){
					divcontent.top = cubic2/9.06*(-1)+(100-images_size)/2+"%";
				}break;
		}
	}
}