// CREDITS:
// Slideshow with with lamellar effect
// 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

// CONFIGURATION:
// Go to http://www.fabulant.com and get the original code
// with step-by-step instructions and copy-and-paste installation.

var picture= [

/////////////////////////////////////////////////////////////////////////
// START OF SCRIPT-CONFIGURATION
/////////////////////////////////////////////////////////////////////////

// Configure the URL (path) of the pictures, the corresponding messages and links below
// Add as many pictures a you like.
// You may embed simple HTML-Tags into the message
  {src : "banner/imprenta1.jpg"},
  {src : "banner/rapida105.jpg"},
  {src : "banner/colores.jpg"},
  {src : "banner/imprenta2.jpg"},
  {src : "banner/bordado.jpg"},
  {src : "banner/lapices.jpg"},
  {src : "banner/imprenta3.jpg"}
]

// target of the picture-links ("_blank", "_top", "_self", "_parent" or "nameOfYourFrame")
var target_url="_blank"

// number of lamellas.
var x_slices=10

// width of slideshow (pixels)
var slideshow_width=765

// height of slideshow (pixels)
var slideshow_height=150

// pause beween the pictures (seconds)
var pause=5

/////////////////////////////////////////////////////////////////////////
// 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].src
}

var picturewidth
var pictureheight
var i_loop=0
var i_picture = Math.floor((Math.random() * picture.length));
var width_slice
var cliptop=0
var clipbottom
var i_clipright=1
var contentimg=""
var contentmes=""
pause=pause*1000


function initiate() {
	getcontent()
	for (i=0;i<=x_slices;i++) {
    var thisinnersimg=eval("document.getElementById('s"+i+"')")
		var thisinnersmes=eval("document.getElementById('t"+i+"')")
		thisinnersimg.innerHTML=contentimg
		thisinnersmes.innerHTML=contentmes
		var thissimg=eval("document.getElementById('s"+i+"').style")
		thissimg.left=0+"px"
		thissimg.top=0+"px"
		var thissmes=eval("document.getElementById('t"+i+"').style")
		thissmes.left=0+"px"
		thissmes.top=0+"px"
  	}

	width_slice=Math.ceil(slideshow_width/x_slices)
	clipbottom=slideshow_height
	document.getElementById("whole").style.left=0+"px"
	document.getElementById("whole").style.top=0+"px"
	i_picture++
	openlamellar()
}

function openlamellar() {
	clipleft=-width_slice
	clipright=0
    if (i_clipright<=width_slice) {
        for (i=0;i<=x_slices;i++) {
            var thissimg=eval("document.getElementById('s"+i+"').style")
			var thissmes=eval("document.getElementById('t"+i+"').style")
            thissimg.clip ="rect("+cliptop+"px "+clipright+"px "+clipbottom+"px "+clipleft+"px)"
			thissmes.clip ="rect("+cliptop+"px "+clipright+"px "+clipbottom+"px "+clipleft+"px)"
            clipleft+=width_slice
            clipright=clipleft+i_clipright
		}
    i_clipright++
    var timer=setTimeout("openlamellar()",20)
   	}
   	else {
		clearTimeout(timer)
		document.getElementById("whole").innerHTML="<span style='position:absolute;top:0px;left:0px'>"+contentimg+"</span><span style='position:absolute;top:0px;left:0px'>"+contentmes+"</span>"
		var timer=setTimeout("changepicture()",pause)
	}
}

function getcontent() {
	contentimg="<table cellpadding=0 cellspacing=0 border=0 width="+slideshow_width+" height="+slideshow_height+"><tr><td width="+slideshow_width+" height="+slideshow_height+"'><img src="+picture[i_picture].src+" border=0 width="+slideshow_width+" height="+slideshow_height+"></td></tr></table>"
	//contentmes="<table cellpadding=0 cellspacing=0 border=0 width="+slideshow_width+" height="+slideshow_height+"><tr valign=top><td class='messagealignstyle'><div class='messageboxstyle' style='width:"+slideshow_width+"px;'><a class='messagefontstyle' href='"+picture[i_picture].url+"' target='"+target_url+"'>"+picture[i_picture].mes+"</a></div></td></tr></table>"
}

function changepicture() {
	i_clipright=0
	clipleft=0
	clipright=0
	for (i=0;i<=x_slices;i++) {
       	var thiss=eval("document.getElementById('s"+i+"').style")
    	thiss.clip ="rect("+cliptop+"px "+clipright+"px "+clipbottom+"px "+clipleft+"px)"
	}
	if (i_picture>picture.length-1) {i_picture=0}
	getcontent()

	for (i=0;i<=x_slices;i++) {
    var thisinnersimg=eval("document.getElementById('s"+i+"')")
		var thisinnersmes=eval("document.getElementById('t"+i+"')")
        thisinnersimg.innerHTML=contentimg
		thisinnersmes.innerHTML=contentmes
    }
	i_picture++
	openlamellar()
}

document.write("<div class='borderandshadowstyle' style='position:relative;width:"+slideshow_width+"px;height:"+slideshow_height+"px;overflow:hidden'>")
document.write("<span id='whole' style='position:absolute;top:0px;left:0px;width:"+slideshow_width+"px;height:"+slideshow_height+"px;'></span>")
for (i=0;i<=x_slices;i++) {
 	document.write("<span id='s"+i+"' style='position:absolute;top:0px;left:0px;width:"+slideshow_width+"px;height:"+slideshow_height+"px;'></span>")
document.write("<span id='t"+i+"' style='position:absolute;top:0px;left:0px;width:"+slideshow_width+"px;height:"+slideshow_height+"px;'></span>")
}
document.write("</div>")
document.close()
window.onload=initiate

