// CREDITS:
// Free JavaScript Gum Slideshow
// By Peter Gehrig
// Copyright (c) 2010 Peter Gehrig. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Additional scripts can be found at http://www.fabulant.com

// IMPORTANT:
// If you add this script to a script-library or script-archive
// you have to add a highly visible link to
// http://www.fabulant.com on the webpage
// where this script will be featured

// CONFIGURATION:
// Go to http://www.fabulant.com
// and create your own slideshow
// with our new Slideshow Fayctory.

var slideurl=new Array()
var slidecomment=new Array()
var slidelink=new Array()
var slidetarget=new Array()

///////////////////////////////////////////////////////////////////////////
// EDIT-ZONE STARTS HERE
//////////////////////////////////////////////////////////////////////////

// Set the URLs of your slides (images)
slideurl[0]="img/slide1.png"
slideurl[1]="img/slide2.png"
slideurl[2]="img/slide3.png"

// Add a link for each slide (image)
// If you don't want to link a slide type "#" instead (see sample in the middle below)
slidelink[0]="#"
slidelink[1]="#"
slidelink[2]="#"

// Add a target for each link
// Allowed values are: "_blank", "_top", "_parent", "_self" or the name of a frame
slidetarget[0]="_blank"
slidetarget[1]="_blank"
slidetarget[2]="_top"

// Add a comment for each slide
slidecomment[0]="10'000 miles away from L.A."
slidecomment[1]="Welcome in Switzerland!"
slidecomment[2]="Australia, I'm coming!"

// Set the font for the comments
var slidefont="Arial"

// Set the fontcolor for the comments
var slidefontcolor="#888888"

// Set the fontsize for the comment (pt, CSS-value)
var slidefontsize=87

// Set the width of the pictures (pixels)
var slidewidth=285

// Set the height of the pictures (pixels)
var slideheight=87

// Set the height of the commetnzone below the pictures (pixels)
var messageheight=5


// Set the pause between the pictures (seconds)
var pause=3

///////////////////////////////////////////////////////////////////////////
// EDIT-ZONE ENDS HERE
//////////////////////////////////////////////////////////////////////////

var preloadedimages=new Array()
for (i=0;i<slideurl.length;i++){
	preloadedimages[i]=new Image()
	preloadedimages[i].src=slideurl[i]
}

var ns4=document.layers?1:0
var ns6=document.getElementById&&!document.all?1:0 
var ie=document.all?1:0

var imgpreload=new Array()
for (i=0;i<=slideurl.length-1;i++) {
	imgpreload[i]=new Image()
	imgpreload[i].src=slideurl[i]
}

var pos_left=0
var pos_top=0
var speed=20
var step=10
var i_loop=0
var i_image1=0
var i_image2=1
var i_space=""
var all_space=""
var max_space=20
var content=""
var i_slide=0
pause*=1000

function stretchimage() {
	if (i_loop<=slidewidth) {
		document.getElementById('imgcontainer1').innerHTML="<a href='"+slidelink[i_image1]+"' target='"+slidetarget[i_image1]+"'><img width='"+i_loop+"' height='"+slideheight+"' src='"+slideurl[i_image1]+"' border='0'></a>"
		document.getElementById('imgcontainer2').style.left=parseInt(document.getElementById('imgcontainer1').style.left)+i_loop+"px";	
		document.getElementById('imgcontainer2').innerHTML="<a href='"+slidelink[i_image2]+"' target='"+slidetarget[i_image2]+"'><img width='"+(slidewidth-i_loop)+"' height='"+slideheight+"' src='"+slideurl[i_image2]+"' border='0'></a>"
		i_loop=i_loop+step
		var timer=setTimeout("stretchimage()",speed)
  	}
	else {
		clearTimeout(timer)
		var imgcontent="<img width='"+i_loop+"' height='"+slideheight+"' src='"+slideurl[i_image1]+"' border='0'><br><span style='font-family:"+slidefont+";font-size:"+slidefontsize+"pt;color:"+slidefontcolor+"'>"[i_image1]+"</span>"
		document.getElementById('imgcontainer1').innerHTML=imgcontent
		document.getElementById('imgcontainer2').style.left=parseInt(document.getElementById('imgcontainer1').style.left)+i_loop+"px"	
		document.getElementById('imgcontainer2').innerHTML=""
		changeimage()
	}
}

function changeimage() {
	i_loop=0
	i_image1++
	if (i_image1>slideurl.length-1) {i_image1=0}
	i_image2=i_image1-1
	if (i_image2>slideurl.length-1) {i_image2=0}
	if (i_image2<0) {i_image2=slideurl.length-1}
	document.getElementById('imgcontainer2').style.left=parseInt(document.getElementById('imgcontainer2').style.left)+"px"
   	var timer=setTimeout("stretchimage()",pause)
}


function simpleslideshow() {
	i_slide++
	if (i_slide>=slideurl.length) {i_slide=0}
	document.slideimage.src=preloadedimages[i_slide].src
	simpleslideshowcomment()
	var fadetimer=setTimeout("simpleslideshow()",pause)
}


function simpleslideshowjump() {
	if (slidetarget[i_slide]=="_self") {
		document.location.href=slidelink[i_slide]
	} 
	else if (slidetarget[i_slide]=="_blank") {
		codepopup=window.open(slidelink[i_slide], "code", "status=yes,location=yes,toolbar=yes,menubar=yes,resizable=yes,scrollbars=yes,width=780,height=580,top=10,left=10");
	} 
	else if (slidetarget[i_slide]=="_top") {
		top.location.href=slidelink[i_slide]
	} 
	else if (slidetarget[i_slide]=="_parent") {
		parent.location.href=slidelink[i_slide]
	} 
	else {
		var jumpto=eval("parent."+slidetarget[i_slide])
		jumpto.location.href=slidelink[i_slide]
	}
}

var slideh=slideheight+messageheight
document.write("<div style=\"position:relative;width:"+slidewidth+"px;height:"+slideh+"px;overflow:hidden\">")
document.write("<div id=\"imgcontainer1\" style=\"position:absolute;width:"+slidewidth+"px;height:"+slideh+"px;top:0px;left:0px\"><img src=\""+slideurl[0]+"\"></div>")
document.write("<div id=\"imgcontainer2\" style=\"position:absolute;width:"+slidewidth+"px;height:"+slideh+"px;top:0px;left:0px\"><img src=\""+slideurl[1]+"\"></div>")
document.write("</div>")
window.onload=stretchimage

