
// CREDITS:
// Slideshow with thumbnail gallery and zoom-effects
// by Peter Gehrig 
// Copyright (c) 2011 Peter Gehrig. All rights reserved.

// IMPORTANT: 
// If you add this script to a script-library or script-archive 
// you have to add a link to http://www.fabulant.com on the webpage 
// where this script will be running.

var picture= [

/////////////////////////////////////////////
// START OF SCRIPT CONFIGURATION 
/////////////////////////////////////////////

// Set the URLs of images, the links and comments.
// Add as many pictures a you like
// Each image requires a block, as shown below:
// {
// imgsrc : "http://www.the-url.com/of/your/image.jpg",
// linkto : "http://www.where-you-go-if-you-click-on-the big-image.com",
// comment : "the comment below the image",
// }, each block ends with a comma (exception: the very last block)


{
imgsrc : "../../slide/basen.jpg",
linkto : "http://www.owdelta.pl/index.php?id=kontakt&lang=_pl",
comment : "Posiadamy basen do dyspozycji gości"
}, // comma required

{
imgsrc : "../../slide/domdzien.jpg",
linkto : "http://www.owdelta.pl/index.php?id=kontakt&lang=_pl",
comment : "OW Delta jest to idealne miejsce do wypoczynku"
}, // comma required

{
imgsrc : "../../slide/placzabaw.jpg",
linkto : "http://www.owdelta.pl/index.php?id=kontakt&lang=_pl",
comment : "Posiadamy również plac zabaw dla dzieci"
}, // comma required


{
imgsrc : "../../slide/domwieczorem.jpg",
linkto : "http://www.owdelta.pl/index.php?id=kontakt&lang=_pl",
comment : "Spedzą Państwo u nas piękne wakacje"
}, // comma required

{
imgsrc : "../../slide/domnoca.jpg",
linkto : "http://www.owdelta.pl/index.php?id=kontakt&lang=_pl",
comment : "Zapraszamy, na wspaniały wypoczynek"
}, // comma required


{
imgsrc : "../../slide/pokoje.jpg",
linkto : "http://www.owdelta.pl/index.php?id=kontakt&lang=_pl",
comment : "Posiadamy komfortowe pokoje"
}, // ATTENTION: the last entry requires NO final comma

{
imgsrc : "../../slide/zaproszenie.jpg",
linkto : "http://www.owdelta.pl/index.php?id=kontakt&lang=_pl",
comment : "serdecznie zapraszamy !!!"
} // ATTENTION: the last entry requires NO final comma


]

// pause (seconds)
var stillstand=4

// speed of zooming. Higher value means faster zooming
var zoomspeed=15

// width of slideshow (px). Width of slideshow and width of images should be identical
var slideshowwidth=545

// height of slideshow (px). Height of slideshow and height of images should be identical
var slideshowheight=380

// Shall thumbnails be displayed? Enter "yes" or "no"
var show_thumbnails="yes"

/////////////////////////////////////////////
// END OF SCRIPT CONFIGURATION 
/////////////////////////////////////////////

// Do not edit below this line
var imgpreload=new Array()
for (iii=0;iii<=picture.length-1;iii++) {
	imgpreload[iii]=new Image()
	imgpreload[iii].src=picture[iii].imgsrc
}

var positionleft=0
var positiontop=0
var timer
var marginright=0
var i_fadestrength=0
var i_images=0
var step=1
var content_image
var content_text
var imageboxwidth=0
var imageboxheight=0
var imagebasicwidth=0
var imagebasicheight=0
var moveon=true
var timer
var timerpause
var stopid
stillstand*=1000

function setimage() {
	if (i_images>=picture.length) {i_images=0}
	content_image="<a href='"+picture[i_images].linkto+"'><img border=0 name='newpic' src='"+picture[i_images].imgsrc+"'></a>"
	content_text=picture[i_images].comment
	document.getElementById('imagebox').innerHTML=content_image
	document.getElementById('textbox').innerHTML=content_text
	imagebasicwidth=document.newpic.width
	imagebasicheight=document.newpic.height
	if (show_thumbnails=="yes"){
		if (document.all) {
			for (i=0;i<=picture.length-1;i++) {
				document.getElementById(i).filters.alpha.opacity=30
			}
		}
		else {
			for (i=0;i<=picture.length-1;i++) {
				document.getElementById(i).style.opacity=0.3
			}
		}
	}
	timer=setTimeout("startenlarge()",50)
}

function startenlarge() {
	if (moveon) {
		if (imageboxwidth<imagebasicwidth) {
			content_image="<a href='"+picture[i_images].linkto+"'><img border=0 name='newpic' src='"+picture[i_images].imgsrc+"' width="+imageboxwidth+"></a>"
			document.getElementById('imagebox').innerHTML=content_image
			imageboxwidth=document.newpic.width
			imageboxheight=document.newpic.height
			if (document.all) {
				document.getElementById('imagebox').filters.alpha.opacity=Math.floor(i_fadestrength)
				document.getElementById('textbox').filters.alpha.opacity=Math.floor(i_fadestrength)
				if (show_thumbnails=="yes"){
					document.getElementById(i_images).filters.alpha.opacity=Math.floor(i_fadestrength)
				}
		
			}
			else {
				document.getElementById('imagebox').style.opacity=(i_fadestrength)/100
				document.getElementById('textbox').style.opacity=(i_fadestrength)/100
				if (show_thumbnails=="yes"){
					document.getElementById(i_images).style.opacity=(i_fadestrength)/100
				}
			}
			document.getElementById('imagebox').style.left=(slideshowwidth/2-imageboxwidth/2)+"px"
			document.getElementById('imagebox').style.top=(slideshowheight/2-imageboxheight/2)+"px"
			document.getElementById('imagebox').style.overflowX="hidden"
			document.getElementById('imagebox').style.visibility="visible"
			step+=0.5
			i_fadestrength+=(100/(slideshowwidth/zoomspeed))
			imageboxwidth+=zoomspeed
			timer=setTimeout("startenlarge()",50)
		}
		else {
			clearTimeout(timer)
			pauseimage()
		}
	}
	else {
		clearTimeout(timer)
		stopanimation()
	}
}

function pauseimage() {
	if (moveon) {
		content_image="<a href='"+picture[i_images].linkto+"'><img border=0 name='newpic' src='"+picture[i_images].imgsrc+"' width="+imagebasicwidth+" height="+imagebasicheight+"></a>"

		document.getElementById('imagebox').style.left=0+"px"
		document.getElementById('imagebox').style.top=0+"px"
		document.getElementById('imagebox').innerHTML=content_image
		if (document.all) {
			document.getElementById('imagebox').filters.alpha.opacity=100
			document.getElementById('textbox').filters.alpha.opacity=100
			if (show_thumbnails=="yes"){
				document.getElementById(i_images).filters.alpha.opacity=100
			}
		}
		else {
			document.getElementById('imagebox').style.opacity=1
			document.getElementById('textbox').style.opacity=1
			if (show_thumbnails=="yes"){
				document.getElementById(i_images).style.opacity=1
			}
		}
		i_fadestrength=0
		timer=setTimeout("finishenlarge()",stillstand)
	}
	else {
		clearTimeout(timer)
		stopanimation()
	}
}

function finishenlarge() {
	if (moveon) {
		if (i_fadestrength<=100) {		
			content_image="<a href='"+picture[i_images].linkto+"'><img border=0 name='newpic' src='"+picture[i_images].imgsrc+"' width="+imageboxwidth+"></a>"
			document.getElementById('imagebox').innerHTML=content_image
			imageboxwidth=document.newpic.width
			imageboxheight=document.newpic.height
			if (document.all) {
				document.getElementById('imagebox').filters.alpha.opacity=Math.floor(100-i_fadestrength)
				document.getElementById('textbox').filters.alpha.opacity=Math.floor(100-i_fadestrength)
			}
			else {
				document.getElementById('imagebox').style.opacity=(100-i_fadestrength)/100
				document.getElementById('textbox').style.opacity=(100-i_fadestrength)/100
			}
			document.getElementById('imagebox').style.left=(slideshowwidth/2-imageboxwidth/2)+"px"
			document.getElementById('imagebox').style.top=(slideshowheight/2-imageboxheight/2)+"px"
			document.getElementById('imagebox').style.overflow="hidden"
			document.getElementById('imagebox').style.visibility="visible"
			i_fadestrength+=5
			imageboxwidth+=zoomspeed
			timer=setTimeout("finishenlarge()",20)
		}
		else {
			clearTimeout(timer)
			i_fadestrength=0;
			step=1;
			i_images++
			if (i_images>=picture.length) {i_images=0}
			imageboxwidth=0
			timer=setTimeout("setimage()",50)
		}
	}
	else {
		clearTimeout(timer)
		stopanimation()
	}
}

function onmsover(thisimg) {
	stopid=thisimg.id
	if (show_thumbnails=="yes"){
		if (document.all) {
			for (i=0;i<=picture.length-1;i++) {
				document.getElementById(i).filters.alpha.opacity=30
			}
			document.getElementById(stopid).filters.alpha.opacity=100
		}
		else {
			for (i=0;i<=picture.length-1;i++) {
				document.getElementById(i).style.opacity=0.3
			}
			document.getElementById(stopid).style.opacity=1
		}
	}
	moveon=false
}

function onmsout(thisimg) {
	moveon=true
	i_images=thisimg.id
	clearTimeout(timer)
	setimage()
}

function stopanimation() {
	content_image="<a href='"+picture[stopid].linkto+"'><img border=0 name='newpic' src='"+picture[stopid].imgsrc+"' width="+imagebasicwidth+" height="+imagebasicheight+"></a>"
	document.getElementById('imagebox').style.left=0+"px"
	document.getElementById('imagebox').style.top=0+"px"
	document.getElementById('imagebox').innerHTML=content_image
	content_text=picture[stopid].comment
	document.getElementById('textbox').innerHTML=content_text
	if (document.all) {
		document.getElementById('imagebox').filters.alpha.opacity=100
		document.getElementById('textbox').filters.alpha.opacity=100
	}
	else {
		document.getElementById('imagebox').style.opacity=1
		document.getElementById('textbox').style.opacity=1
	}
	i_fadestrength=0
}

if (show_thumbnails=="yes") {
	document.write("<DIV id='roofthumbnails'  style='position:relative;width:"+slideshowwidth+"px;'>")
	for (i=0;i<=picture.length-1;i++) {
		document.write("<img class='thumbnailstyle' onmouseover='onmsover(this)' onmouseout='onmsout(this)' id='"+i+"' style='filter:alpha(opacity=50') src='"+picture[i].imgsrc+"'>")
	}
	document.write("</DIV>")
}

document.write("<DIV id='roofimages' class='slideshowstyle' style='position:relative;width:"+slideshowwidth+"px;height:"+slideshowheight+"px;overflow:hidden'>")
if (document.all) {
	document.write("<DIV id='imagebox' style='position:absolute;left:0px;top:0px;filter:alpha(opacity=0);'></DIV>")
}
else {
	document.write("<DIV id='imagebox' style='position:absolute;opacity:1;'></DIV>")
}

document.write("</DIV>")

document.write("<DIV style='position:relative;width:"+slideshowwidth+"px;'>")

document.write("<DIV><table style='width:"+slideshowwidth+"px;'><tr><td class='commentstyle' id='textbox' style='filter:alpha(opacity=0);'></td></tr></table></DIV>")

document.write("<DIV><table style='width:"+slideshowwidth+"px;'><tr><td class='commentstyle' id='textbox' style='filter:alpha(opacity=0);'></td></tr></table></DIV>")

document.write("</DIV>")


onload=setimage

