// CREDITS:
// Image Scroller 2.03 with double-fade effect
// By Peter Gehrig
// Copyright (c) 2003 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.24fun.com
// info@24fun.com
// 9/6/2002

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

// URLs of slides
var slideurl=new Array(
	"jewelryduplex.jpg",
	"mysticalcoralsduplex.jpg",
	"arrowsduplex.jpg",
	"cuddlybearsduplex.jpg",
	"studioduplex.jpg")

// comments displayed below the slides
var slidecomment=new Array("","","","","")

// links for each slide
var slidelink=new Array("gallery.htm","gallery.htm","gallery.htm","gallery.htm","gallery.htm")

// targets of the links. Allowed values: "_parent", "_top", "_blank", "_self"
var slidetarget=new Array("top.mainFrame","top.mainFrame","top.mainFrame","top.mainFrame","top.mainFrame")

// the width of the slideshow (pixels)
//var scrollerwidth=160
var scrollerwidth=800

// the height of the slideshow (pixels)
//var scrollerheight=100
var scrollerheight=300

// width of the transparent zones (pixels)
//var translayerszone=40
var translayerszone=100

// font-attributes for the comments
var slidefont="Arial"
var slidefontcolor="white"
var slidefontsize="2"

// background-color of webpage
var pagebgcolor="#042A5C"

// do not edit below this line
var translayerswidth=1
var translayersmax=Math.floor(translayerszone/translayerswidth)
var translayersleftpos=0
var translayersopacity=100
var translayersfactor=100/translayersmax
var translayerswidthall=translayersmax*translayerswidth
var allpicturewidth
var distancepictopic=0
var scrollerleft=0
var scrollertop=0
var pause=20
var step=2
var newstep=step
var clipleft,clipright,cliptop,clipbottom
var i_picture=0
var timer
var picturecontent=""
var ns4=document.layers?1:0
var ns6=document.getElementById&&!document.all?1:0
var ie=document.all?1:0
var browserinfos=navigator.userAgent
var opera=browserinfos.match(/Opera/)

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

var sHtmlScroller = "";

function init() {
	document.getElementById("divticker").innerHTML = sHtmlTicker;
	initscroller();

	document.getElementById("divscroller").innerHTML = sHtmlScroller;

    if (ie) {
		allpicturewidth=document.all.picturediv.offsetWidth
		document.all.picturediv.style.posTop=scrollertop
        document.all.picturediv.style.posLeft=scrollerleft+scrollerwidth
		clipleft=0
		clipright=0
		cliptop=0
		clipbottom=scrollerheight
		document.all.picturediv.style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
		document.all.picturediv.style.visibility="visible"
		scrollpicture()

    }
	if (ns6) {
		allpicturewidth=document.getElementById('emptypicturediv').offsetWidth
		document.getElementById('picturediv').style.top=scrollertop
        document.getElementById('picturediv').style.left=scrollerleft+scrollerwidth
		clipleft=0
		clipright=0
		cliptop=0
		clipbottom=scrollerheight
		document.getElementById('picturediv').style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
		document.getElementById('picturediv').style.visibility="visible"
		scrollpicture()
    }
	if (ns4) {
		allpicturewidth=document.roof.document.picturediv.document.width
		document.roof.document.picturediv.top=scrollertop
		document.roof.document.picturediv.left=scrollerleft+scrollerwidth
		document.roof.document.picturediv.clip.left=0
		document.roof.document.picturediv.clip.right=0
		document.roof.document.picturediv.clip.top=0
		document.roof.document.picturediv.clip.bottom=scrollerheight
		document.roof.document.picturediv.visibility="visible"
        scrollpicture()
    }
}

function scrollpicture() {
    if (ie) {
		if (document.all.picturediv.style.posLeft>=scrollerleft-allpicturewidth) {
			document.all.picturediv.style.posLeft-=step
			clipright+=step
			if (clipright>scrollerwidth) {
				clipleft+=step
			}
			document.all.picturediv.style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
			var timer=setTimeout("scrollpicture()",pause)
		}
		else {
			resetposition()
		}
	}
	if (ns6) {
		if (parseInt(document.getElementById('picturediv').style.left)>=scrollerleft-allpicturewidth) {
	document.getElementById('picturediv').style.left=parseInt(document.getElementById('picturediv').style.left)-step
			clipright+=step
			if (clipright>scrollerwidth) {
				clipleft+=step
			}
			document.getElementById('picturediv').style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
			var timer=setTimeout("scrollpicture()",pause)
		}
		else {
			resetposition()
		}
	}
   if (ns4) {
		if (document.roof.document.picturediv.left>=scrollerleft-allpicturewidth) {
			document.roof.document.picturediv.left-=step
			document.roof.document.picturediv.clip.right+=step
			if (document.roof.document.picturediv.clip.right>scrollerwidth) {
				document.roof.document.picturediv.clip.left+=step
			}
			var timer=setTimeout("scrollpicture()",pause)
		}
		else {
			resetposition()
		}
	}
}

function onmsover(o) {
	changer(o)
	step=0
}
function onmsout(o) {
	initial(o)
	step=newstep
}

function resetposition() {
	if (ie) {
        document.all.picturediv.style.posLeft=scrollerleft+scrollerwidth
		clipleft=0
		clipright=0
		document.all.picturediv.style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
        scrollpicture()
	}
	if (ns6) {
		allpicturewidth=document.getElementById('emptypicturediv').offsetWidth
        document.getElementById('picturediv').style.left=scrollerleft+scrollerwidth
		clipleft=0
		clipright=0
		document.getElementById('picturediv').style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
        scrollpicture()
	}
	if (ns4) {
		document.roof.document.picturediv.left=scrollerleft+scrollerwidth
		document.roof.document.picturediv.clip.left=0
		document.roof.document.picturediv.clip.right=0
        scrollpicture()
	}
}

picturecontent=""
picturecontent+="<table cellpadding=2 cellspacing=0>"
picturecontent+="<tr>"
for (i=0;i<=slideurl.length-1;i++) {
	picturecontent+="<td>"
	//picturecontent+="<a href=\""+slidelink[i]+"\" target=\""+slidetarget[i]+"\" onMouseOver=\"javascript:onmsover(this)\" onMouseOut=\"javascript:onmsout(this)\">"
	//picturecontent+="<a href=\""+slidelink[i]+"\" target=\""+slidetarget[i]+"\">"
	picturecontent+="<a href=\"javascript:"+slidetarget[i]+".location.href='"+slidelink[i]+"'\">"
	//picturecontent+="<div class=\"img-shadow\">"
	picturecontent+="<img src=\"images/main/scroller/"+slideurl[i]+"\" border=0>"
	//picturecontent+="</div>"
	picturecontent+="</a>"
	picturecontent+="</td>"
}
picturecontent+="</tr>"
picturecontent+="<tr>"
for (i=0;i<=slideurl.length-1;i++) {
	picturecontent+="<td><center>"
	picturecontent+="<font face=\""+slidefont+"\" color=\""+slidefontcolor+"\" size="+slidefontsize+">"
	picturecontent+=slidecomment[i]
	picturecontent+="</font>"
	picturecontent+="</center></td>"
}
picturecontent+="</tr>"
picturecontent+="</tr></table>"

if (ie || ns6) {
	sHtmlScroller += '<center>';
	sHtmlScroller += '<div style="position:relative;width:'+scrollerwidth+'px;height:'+scrollerheight+'px;overflow:hidden">';
	sHtmlScroller += '<div id="picturediv" style="position:absolute;top:0px;left:0px;height:'+scrollerheight+'px;visibility:hidden">'+picturecontent+'</div>';
	if (ie && !opera) {
		for (i=0;i<=translayersmax;i++) {
		sHtmlScroller += '<span ID="trans'+i+'" style="position:absolute;top:0px;left:'+translayersleftpos+'px;width:'+translayerswidth+'px;height:'+scrollerheight+'px;background-color:'+pagebgcolor+';filter:alpha(opacity='+translayersopacity+');overflow:hidden"> </span>';
		translayersleftpos+=translayerswidth
		translayersopacity-=translayersfactor
		}
		translayersleftpos=scrollerwidth-translayersleftpos
		for (ii=0;ii<=translayersmax;ii++) {
		sHtmlScroller += '<span ID="trans'+ii+'" style="position:absolute;top:0px;left:'+translayersleftpos+'px;width:'+translayerswidth+'px;height:'+scrollerheight+'px;background-color:'+pagebgcolor+';filter:alpha(opacity='+translayersopacity+');overflow:hidden"> </span>';
		translayersleftpos+=translayerswidth
		translayersopacity+=translayersfactor
		}
	}
	if (ns6 && !opera) {
		for (i=0;i<=translayersmax-1;i++) {
		sHtmlScroller += '<span ID="transleft'+i+'" style="position:absolute;top:0px;left:'+translayersleftpos+'px;width:'+translayerswidth+'px;height:'+scrollerheight+'px;background-color:'+pagebgcolor+';-moz-opacity:'+translayersopacity/100+';overflow:hidden"> </span>';
		translayersleftpos+=translayerswidth
		translayersopacity-=translayersfactor
		if (translayersopacity<0) {translayersopacity=0.001}
		}
		translayersleftpos=scrollerwidth-translayersleftpos
		translayersopacity=0.001
		for (i=0;i<=translayersmax-1;i++) {
		sHtmlScroller += '<span ID="transright'+i+'" style="position:absolute;top:0px;left:'+translayersleftpos+'px;width:'+translayerswidth+'px;height:'+scrollerheight+'px;background-color:'+pagebgcolor+';-moz-opacity:'+translayersopacity/100+';"> </span>';
		translayersleftpos+=translayerswidth
		translayersopacity+=translayersfactor
		}
	}
	sHtmlScroller += '</div>';
	sHtmlScroller += '<div id="emptypicturediv" style="position:absolute;top:0px;left:0px;height:'+scrollerheight+'px;visibility:hidden">'+picturecontent+'</div>';
	sHtmlScroller += '</center>';

	window.onload=init
}

if (ns4) {
	sHtmlScroller += '<ilayer name="roof" width='+scrollerwidth+' height='+scrollerheight+'>';
	sHtmlScroller += '<layer name="picturediv" width='+scrollerwidth+' height='+scrollerheight+' visibility=hide>'+picturecontent+'</layer>';
	sHtmlScroller += '</ilayer>';

	document.getElementById("scroller").innerHTML = sHtmlScroller;

	window.onload=init
}

//PLF-http://www.jejavascript.net/
var coeff=2;//Coefficient de reduction
var larg=320;//largeur maxi de l'image
var haut=320;//hauteur maxi de l'image
var coeffinit=coeff;
var oTop;

function changer() {
	var o = changer.arguments.length > 0 ? changer.arguments[0] : oTop;

	oTop = o;
	if (o.getElementsByTagName("img")[0].width < larg) {
		coeff = coeff-0.2;
		o.getElementsByTagName("img")[0].width = Math.round(larg/coeff);
		o.getElementsByTagName("img")[0].height = Math.round(haut/coeff);
		chang=window.setTimeout('changer();',60);
	}
	else {window.clearTimeout(chang);}
}

function initial() {
	var o = initial.arguments.length > 0 ? initial.arguments[0] : oTop;

	oTop = o;
	if (o.getElementsByTagName("img")[0].width > larg/coeffinit) {
		window.clearTimeout(chang);
		coeff = coeff+0.2;
		o.getElementsByTagName("img")[0].width = Math.round(larg/coeff);
		o.getElementsByTagName("img")[0].height = Math.round(haut/coeff);

		initi=window.setTimeout('initial();',60);//vitesse de l'effet
	}
	else {window.clearTimeout(initi);}
}

