
/*---------------------------------------------------------------------------------------------------------------------

Written by Tom Sayers - SQUAREZONE Ltd +44 (0)1252 517611
Copyright © 2001 - 2010 Squarezone Ltd.  All rights reserved.
This software may not be copied by any method in part or whole
without the express written consent of the copyright holder.
squarezone.co.uk & speedEweb.co.uk & club-sites.co.uk

-----------------------------------------------------------------------------------------------------------------------
Slide show
Uses the following html
	echo '<div id="mainpic">' . "\n";
	echo '  <p><img id="mainpic0" src="/images/girl.jpg" width="100%" alt="" style="position:absolute;top:0;left:0;visibility:visible" /></p>' . "\n";
	echo '  <p><img id="mainpic1" src="/images/dress.jpg" width="100%" alt="" style="position:absolute;top:0;left:0;visibility:hidden" /></p>' . "\n";
	echo '  <p><img id="mainpic2" src="/images/830.jpg" width="100%" alt="" style="position:absolute;top:0;left:0;visibility:hidden" /></p>' . "\n";
	echo '</div>' . "\n";

-----------------------------------------------------------------------------------------------------------------------
Change log

---------------------------------------------------------------------------------------------------------------------*/
var timeout = 100;
var uagent = window.navigator.userAgent.toLowerCase();
if(uagent.indexOf('msie') < 0){
	uagent = false;
	timeout = 100;
}

var counter = 0;
var current = 0;
var step = 1;
var images = new Array();
while(document.images[counter]){
	if(document.images[counter].id.indexOf('mainpic') == 0) images[current++] = document.images[counter];
	counter++;
}

var marquee = document.getElementById('scroll');
var scroll = eval(marquee.style.left.replace('%',''));
current = 0;
var tt;
var ii;
var timer_is_on = 0;
if(images.length > 1 || marquee != ''){
	next = 1;
	setTimeout(function(){eSlide()},2000);	// wait 2 secs
}

function eSlide(){
	if(images.length > 1){
		if(uagent){
			images[next].style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=' + 0 + ')';
			images[next].style.filter = 'alpha(opacity=0)';
		} else {
			images[next].style.opacity = 0;
		}
		images[next].style.visibility = 'visible';
		ii = 100;
	}
	if(!timer_is_on){
	  timer_is_on = 1;
	  eFadeLoop(ii);
	}
}

function eFadeLoop(ii){
	if(images.length > 1){
		ii = eFade(ii);
		if(ii <= 0){
			images[current].style.visibility = 'hidden';
			current++;
			next++;
			if(current >= images.length) current = 0;
			if(next >= images.length)	next = 0;
			if(uagent){
				images[next].style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=' + 0 + ')';
				images[next].style.filter = 'alpha(opacity=0)';
			} else {
				images[next].style.opacity = 0;
			}
			images[next].style.visibility = 'visible';
			ii = 100;
		}
		ii = ii - step;
	}
	scroll = scroll - 1;
	marquee.style.left = scroll + '%';
	if(scroll < -100) scroll = 100;
	if(timer_is_on == 1) tt = setTimeout(function(){eFadeLoop(ii)},timeout);
}

function eFade(ii){
	if(uagent){
		images[current].style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=' + ii + ')';
		images[next].style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=' + (100 - ii) + ')';
		images[current].style.filter = 'alpha(opacity=' + ii + ')';
		images[next].style.filter = 'alpha(opacity=' + (100 - ii) + ')';
	} else {
		images[current].style.opacity = ii / 100;
		images[next].style.opacity = (100 - ii) / 100;
	}
	return(ii);
}

function eStopFade(tt){
	clearTimeout(tt);
	timer_is_on = 0;
}

function eRestartFade(tt){
	timer_is_on = 1;
  eFadeLoop(ii);
}


