﻿function ImageEffects() {
	imgs = new Array();
	dirFiles = new Array(new String());
	image = null;
	activeImageId = 0;
	imagesCount = 0;
	
	timeOut = 4000; // Refresh rate
	
	function preInit()	{
        dirFiles = [
                    'img/slideBanner/img1.jpg',
                    'img/slideBanner/img2.jpg',
                    'img/slideBanner/img3.jpg'
                   ]; // images for the slideshow
                   
        imagesCount = dirFiles.length-1;
	}
	
	function construct()	{

        dirFilesLength = dirFiles.length;
        
		for (i=0; i<dirFilesLength; i++) {
		
		    imgs[i] = new Image();
		    imgs[i].src = dirFiles[i];
		}
	}
	
	function configure(imgId)	{
		image = document.getElementById(imgId);
	}
	
	function repaint() {
	    if (activeImageId < imagesCount) {
	        activeImageId++;
	    } else {
	        activeImageId = 0;
	    }
	    
	    if (BrowserDetect.browser == 'Explorer') {
	        image.src = imgs[activeImageId].src;
	    } else {
	        crossfade(image, imgs[activeImageId].src, timeOut/1000, '');
	    }
	}
	
	this.preInit = preInit;
	this.init = construct;
	this.configure = configure;
	this.repaint = repaint;
	
	this.timeOut = timeOut;
}

myEffects = new ImageEffects();

function imageEffects(imgId, page) {
	myEffects.preInit();
	myEffects.init();
	myEffects.configure(imgId);
	
	if ((location.href.indexOf(page) != -1) || (location.href.indexOf(".aspx") == -1)) {
	    refresh();
	}
}

function refresh() {
    myEffects.repaint();

    setTimeout("refresh()", myEffects.timeOut);
}