var Timer = 2000;
var IntervalCode = '';

var ImageIDs = new Array();
var FileNames = new Array();
var Websites = new Array();
var AlternateTexts = new Array();

var CurrentLogo = 0;
var PreviousLogo = 0;


var Counter = 0;
var LogosCount = 0;

var LogoID = new Array();

var ImagesArray = new Array();

var LeftPos = new Array();
LeftPos[1] = 0;
LeftPos[2] = 115;
LeftPos[3] = 230;


var PositionCounter = 0;
var LogoCounter = 0;

var ContinueRotating = true;

var ImagesURL = 'http://www.kingstonpaint.com/images/logos';


LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'chemcraft.gif';
Websites[LogosCount] = 'http://www.chemcraft.com';
AlternateTexts[LogosCount] = 'Chemcraft';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'zinsser.gif';
Websites[LogosCount] = 'http://www.zinsser.com';
AlternateTexts[LogosCount] = 'Zinsser';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'flood.gif';
Websites[LogosCount] = 'http://www.floodco.com';
AlternateTexts[LogosCount] = 'Flood';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'deft.gif';
Websites[LogosCount] = 'http://www.deftfinishes.com';
AlternateTexts[LogosCount] = 'Deft Finishes';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'dickies.gif';
Websites[LogosCount] = 'http://www.dickies.com';
AlternateTexts[LogosCount] = 'Dickies Work Wear';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'dynamic.gif';
Websites[LogosCount] = 'http://www.getpainting.com';
AlternateTexts[LogosCount] = 'Dynamic';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'kilz.gif';
Websites[LogosCount] = 'http://www.masterchem.com';
AlternateTexts[LogosCount] = 'Kilz';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'corona.gif';
Websites[LogosCount] = 'http://www.coronabrushes.com';
AlternateTexts[LogosCount] = 'Corona Brushes';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'ace.gif';
Websites[LogosCount] = 'http://www.acedropcloth.com';
AlternateTexts[LogosCount] = 'ACE Drop Cloths';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'dap.gif';
Websites[LogosCount] = 'http://www.dap.com';
AlternateTexts[LogosCount] = 'DAP';

//LogosCount++;
//ImageIDs[LogosCount] = LogosCount;
//FileNames[LogosCount] = 'hero.gif';
//Websites[LogosCount] = 'http://www.hero.ca';
//AlternateTexts[LogosCount] = 'HERO';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'plastikote.gif';
Websites[LogosCount] = 'http://www.plastikote.com';
AlternateTexts[LogosCount] = 'Plastikote';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'ralston.gif';
Websites[LogosCount] = 'http://www.ralston.ca';
AlternateTexts[LogosCount] = 'Ralston';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'reddevil.gif';
Websites[LogosCount] = 'http://www.reddevil.com';
AlternateTexts[LogosCount] = 'Red Devil';

//LogosCount++;
//ImageIDs[LogosCount] = LogosCount;
//FileNames[LogosCount] = 'richard.gif';
//Websites[LogosCount] = 'http://www.richardtools.com';
//AlternateTexts[LogosCount] = 'Richard Tools';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'roman.gif';
Websites[LogosCount] = 'http://www.romanadhesives.com';
AlternateTexts[LogosCount] = 'Roman Decorating Products';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'greentape.gif';
Websites[LogosCount] = 'http://www.thegreentape.com';
AlternateTexts[LogosCount] = 'Painters Mate Green Tape';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'backtonature.gif';
Websites[LogosCount] = 'http://www.ibacktonature.com';
AlternateTexts[LogosCount] = 'Back To Nature';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'falcon.gif';
Websites[LogosCount] = 'http://www.falconladder.com';
AlternateTexts[LogosCount] = 'Falcon Ladders';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'duralee.gif';
Websites[LogosCount] = 'http://www.duralee.com';
AlternateTexts[LogosCount] = 'Duralee Fabrics';

//LogosCount++;
//ImageIDs[LogosCount] = LogosCount;
//FileNames[LogosCount] = 'metro.gif';
//Websites[LogosCount] = 'http://www.metrowallcoverings.com';
//AlternateTexts[LogosCount] = 'Metro Wallcoverings';

//LogosCount++;
//ImageIDs[LogosCount] = LogosCount;
//FileNames[LogosCount] = 'norwall.gif';
//Websites[LogosCount] = 'http://www.norwallgroup.com';
//AlternateTexts[LogosCount] = 'Norwall';

//LogosCount++;
//ImageIDs[LogosCount] = LogosCount;
//FileNames[LogosCount] = 'brewster.gif';
//Websites[LogosCount] = 'http://www.brewp.com';
//AlternateTexts[LogosCount] = 'Brewster';

//LogosCount++;
//ImageIDs[LogosCount] = LogosCount;
//FileNames[LogosCount] = 'elite.gif';
//Websites[LogosCount] = 'http://www.elitewindowfashions.com';
//AlternateTexts[LogosCount] = 'Elite Window Fashions';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'jackson.gif';
Websites[LogosCount] = 'http://www.jackson.ca';
AlternateTexts[LogosCount] = 'Jackson';

//LogosCount++;
//ImageIDs[LogosCount] = LogosCount;
//FileNames[LogosCount] = 'titan.gif';
//Websites[LogosCount] = 'http://www.titantool.com';
//AlternateTexts[LogosCount] = 'Titan';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'mrlongarm.gif';
Websites[LogosCount] = 'http://www.mrlongarm.com';
AlternateTexts[LogosCount] = 'Mr. Long Arm';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'woodplus.gif';
Websites[LogosCount] = 'http://www.woodpluscoatings.com';
AlternateTexts[LogosCount] = 'WoodPlus';


LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = '3m.gif';
Websites[LogosCount] = 'http://www.3m.ca';
AlternateTexts[LogosCount] = '3M';


LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'consolidated.gif';
Websites[LogosCount] = 'http://www.consolidatedcoatings.com';
AlternateTexts[LogosCount] = 'Consolidated Coatings';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'ea.gif';
Websites[LogosCount] = 'http://www.eacanada.ca';
AlternateTexts[LogosCount] = 'Engineered Abrasives';

//LogosCount++;
//ImageIDs[LogosCount] = LogosCount;
//FileNames[LogosCount] = 'bluemountain.gif';
//Websites[LogosCount] = 'http://www.ihdg.com';
//AlternateTexts[LogosCount] = 'Blue Mountain Wallcoverings';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'picquic.gif';
Websites[LogosCount] = 'http://www.picquic.com';
AlternateTexts[LogosCount] = 'Picquic Tool Company';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'strome.gif';
Websites[LogosCount] = 'http://www.stromesales.com';
AlternateTexts[LogosCount] = 'Strome Sales';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'swing.gif';
Websites[LogosCount] = 'http://www.swingpaints.com';
AlternateTexts[LogosCount] = 'Swing Paints';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'simms.gif';
Websites[LogosCount] = 'http://www.simms.ca';
AlternateTexts[LogosCount] = 'Simms';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'bercom.gif';
Websites[LogosCount] = 'http://www.bercomincorporated.com';
AlternateTexts[LogosCount] = 'Bercom';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'colorputty.gif';
Websites[LogosCount] = 'http://www.colorputty.com';
AlternateTexts[LogosCount] = 'Color Putty';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'dripless.gif';
Websites[LogosCount] = 'http://www.dripless.com';
AlternateTexts[LogosCount] = 'Dripless';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'flamecontrol.gif';
Websites[LogosCount] = 'http://www.flamecontrol.com';
AlternateTexts[LogosCount] = 'Flame Control Coatings';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'homax.gif';
Websites[LogosCount] = 'http://www.homaxproducts.com';
AlternateTexts[LogosCount] = 'Homax Products';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'oldmasters.gif';
Websites[LogosCount] = 'http://www.oldmastrs.com';
AlternateTexts[LogosCount] = 'Old Masters';

LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'psg.gif';
Websites[LogosCount] = 'http://www.prevalspraygun.com';
AlternateTexts[LogosCount] = 'Preval Spray Gun';

//LogosCount++;
//ImageIDs[LogosCount] = LogosCount;
//FileNames[LogosCount] = 'york.gif';
//Websites[LogosCount] = 'http://www.yorkwall.com';
//AlternateTexts[LogosCount] = 'York Wallcoverings';


LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'superdeck.gif';
Websites[LogosCount] = 'http://www.superdeck.com';
AlternateTexts[LogosCount] = 'SuperDeck';


LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = 'olympic.gif';
Websites[LogosCount] = 'http://www.olympic.com';
AlternateTexts[LogosCount] = 'Olympic';




/*
LogosCount++;
ImageIDs[LogosCount] = LogosCount;
FileNames[LogosCount] = '';
Websites[LogosCount] = '';
AlternateTexts[LogosCount] = '';
*/


/*
// pre-load the images

for (Counter = 1; Counter <= LogosCount; ++ Counter) {
	ImagesArray[Counter] = new Image;
	ImagesArray[Counter].src = ImagesURL+'/'+FileNames[Counter];
}
*/


// create the divs

for (Counter = 1; Counter <= LogosCount; ++ Counter) {
	if (Websites[Counter] != '') {
		document.write('<div id="Logo'+Counter+'" STYLE="position: absolute; left: -300px; top: 0px; width: 110px; height: 47px; z-index: 2; visibilty: hide; visibility: hidden;"><table width="110" height="47" border="0" cellpadding="0" cellspacing="0"><tr><td width="110" height="47" align="center" valign="middle"><a href="'+Websites[Counter]+'" target="_blank" onMouseOver="StopRotation();" onMouseOut="StartRotation();"><img id="LogoImage'+Counter+'" src="'+ImagesURL+'/'+FileNames[Counter]+'" alt="'+AlternateTexts[Counter]+'" border="0"></a></td></tr></table></div>');
	}
	else {
		document.write('<div id="Logo'+Counter+'" STYLE="position: absolute; left: -300px; top: 0px; width: 110px; height: 47px; z-index: 2; visibilty: hide; visibility: hidden;"><table width="110" height="47" border="0" cellpadding="0" cellspacing="0"><tr><td width="110" height="47" align="center" valign="middle"><a href="javascript:NoWebsite();" onMouseOver="StopRotation();" onMouseOut="StartRotation();"><img id="LogoImage'+Counter+'" src="'+ImagesURL+'/'+FileNames[Counter]+'" alt="'+AlternateTexts[Counter]+'" border="0"></td></tr></table></div>');
	}
}



// shuffle the logos array

for (Counter = 1; Counter <= 35; ++ Counter) {

	var Random1 = parseInt(Math.random() * LogosCount)+1;
	var Random2 = parseInt(Math.random() * LogosCount)+1;
	
	var Temp = ImageIDs[Random1];
	
	ImageIDs[Random1] = ImageIDs[Random2];
	
	ImageIDs[Random2] = Temp;

}





function StopRotation() {
	ContinueRotating = false;
}
function StartRotation() {
	ContinueRotating = true;
}

function NextLogo() {

	if (ContinueRotating == true) {
	
		PositionCounter++;
		if (PositionCounter > 3) {
			PositionCounter = 1;
		}
		
		LogoCounter++;
		if (LogoCounter > LogosCount) {
			LogoCounter = 1;
		}

		/*
		if (PositionCounter == 1) {
			LogoID[PositionCounter] = ImageIDs[LogoCounter];
			//document.images['LogoImage1'].src = ImagesURL+'/'+FileNames[ImageIDs[LogoCounter]];
			document.images['LogoImage1'].src = ImagesArray[ImageIDs[LogoCounter]].src;
			document.images['LogoImage1'].alt = AlternateTexts[ImageIDs[LogoCounter]];
		}	
		else if (PositionCounter == 2) {
			LogoID[PositionCounter] = ImageIDs[LogoCounter];
			document.images['LogoImage2'].src = ImagesURL+'/'+FileNames[ImageIDs[LogoCounter]];
			document.images['LogoImage2'].alt = AlternateTexts[ImageIDs[LogoCounter]];
		}
		else {
			LogoID[PositionCounter] = ImageIDs[LogoCounter];
			document.images['LogoImage3'].src = ImagesURL+'/'+FileNames[ImageIDs[LogoCounter]];
			document.images['LogoImage3'].alt = AlternateTexts[ImageIDs[LogoCounter]];
		}
		*/
		
		// keep track of what was there before
		var OldID = LogoID[PositionCounter];
				
		// move the new one into position
		MoveDiv(LeftPos[PositionCounter],'Logo'+ImageIDs[LogoCounter]);
		
		// display the new image
		ShowHideDiv(1,'Logo'+ImageIDs[LogoCounter]);
		
		// hide the previous one
		if (OldID > 0) {
			ShowHideDiv(0,'Logo'+OldID);
		}
		
		// keep track of the current image
		LogoID[PositionCounter] = ImageIDs[LogoCounter];
			
				
	
	}
}


function ShowHideDiv(LayerVisible,DivID) {
	if(document.layers) {
		// netscape 4
		document.layers[DivID].visibility = LayerVisible ? "show" : "hide";
    }
	else if(document.getElementById) {
		// netscape 6 and IE 5+
        var obj = document.getElementById(DivID);
    	obj.style.visibility = LayerVisible ? "visible" : "hidden";
	}
	else if(document.all) {
    	// IE 4
        document.all[DivID].style.visibility = LayerVisible ? "visible" : "hidden";
	}
}


function MoveDiv(LeftPos,DivID) {
	if(document.layers) {
		// netscape 4
		document.layers[DivID].left = LeftPos;
    }
	else if(document.getElementById) {
		// netscape 6 and IE 5+
        var obj = document.getElementById(DivID);
    	obj.style.left = LeftPos;
	}
	else if(document.all) {
    	// IE 4
        document.all[DivID].style.left = LeftPos;
	}
}


function NoWebsite() {
	// do nothing 
}


// initialize the first three logos
NextLogo();
NextLogo();
NextLogo();


IntervalCode = setInterval('NextLogo()',Timer);
