var ImageLoad = 
[
['services.html', 	'images/frontimage_1.jpg', 	'Smartmicros'	],		//  ['URL to linked page', 'URL to image', 'Caption under picture']	//
['solutions.html', 	'images/frontimage_2.jpg', 	'Smartmicros'	]];
/*,		//  The caption is not required and may be left blank like this:		//
['services.html', 	'images/frontimage_3.jpg', 	'Smartmicros'	],		//  ['URL to linked page', 'URL to image', '']							//
['solutions.html', 	'images/frontimage_4.jpg', 	'Smartmicros'	],		//  Add as many images as you like seperated by commmas					//
['services.html', 	'images/frontimage_5.jpg', 	'Smartmicros'	],		//  Almost ALL errors are caused by the url or path being wrong 		//
['solutions.html', 	'images/frontimage_6.jpg', 	'Smartmicros'	]		//  The LAST image declaration does NOT have a comma after it			//
];
*/
var ImageCount		= ImageLoad.length;			//  *****  Change this to the total number of images loaded above  ***** 		//	
var ImageDelay		= 20000;		//  *****  Set this to the delay interval desired.  	// 
var FirstDelay		= 8000;			//  *****  Set this to the delay first/ start interval desired. // 

//////////////
var serverPath 		= "http://www.smartmicros.com/";
//var serverPath 		= "http://192.168.0.40/smartmicros/site3/";
///////////////

//global object for Transition
var isf = { 'clock' : null, 'fade' : true, 'count' : 1 }

isf.imgs = [serverPath + ImageLoad[0][1], serverPath + ImageLoad[1][1]];

//
//, serverPath + ImageLoad[2][1],
//	serverPath + ImageLoad[3][1], serverPath + ImageLoad[4][1], serverPath + ImageLoad[5][1]
//	];

/*****************************************************************************
*****************************************************************************/

//cache the images
isf.imgsLen = isf.imgs.length;
isf.cache = [];
for(var i=0; i<isf.imgsLen; i++)
{
	isf.cache[i] = new Image;
	isf.cache[i].src = isf.imgs[i];
}
///////////////

var LinkTarget		= "_self"		//  *****  Defines where you want linked page to open. _self, _blank, _top, etc	//
var img_width 		= "800";
var img_height 		= "194";
var ImageIndex		= 0;			//  DO NOT ALTER	//
var FirstLoad 		= 0;			//  DO NOT ALTER	//
var QuickStartID 	= 0;  			//  DO NOT ALTER	//
var htmlString 		= ""			//  DO NOT ALTER 	//

//  This function rotates the banner  //
function ImageChange()

{		
/*htmlString = '<a target="';
htmlString = htmlString + LinkTarget;
htmlString = htmlString + '" href="';
htmlString = htmlString + ImageLoad[ImageIndex][0];
htmlString = htmlString + '"><img id="r_img" border="0" src=""';
htmlString = htmlString + ' width="' + img_width +'" height="' + img_height +'" alt="' + ImageLoad[ImageIndex][2] +'"></a>';
*/
//document.getElementById('RotateImage').innerHTML = htmlString; 				

swapfade(document.getElementById('RotateImage'), serverPath + ImageLoad[ImageIndex][1], '2', ImageLoad[ImageIndex][2]);

if(ImageIndex == ImageCount - 1)		//  This statement increments image displayed and resets if displaying last image  //
{										
ImageIndex= 0;																				
}																								
else																							
{																								
ImageIndex++;																					
}																										

if(FirstLoad == 0)						//  Determins if this is the first time function has run.   // 
{
SlowFinish();
}

}
//  End Funtion  //

//  This function ensures first banner is displayted without a delay  //
function  QuickStart()
{
QuickStartID=setInterval("ImageChange()", 1000);
}
//  End Funtion  //																		

//  This function sets display rate to user defined speed  //
function SlowFinish()
{
clearInterval(QuickStartID);
FirstLoad = 1;
setInterval("ImageChange()", ImageDelay);	 
}
//  End Funtion  //

Start();
///////////////For Transitions

function Start() {
	timer = setTimeout("QuickStart()",FirstDelay);
	return false;
}

//swapfade setup function
function swapfade()
{
	//if the timer is not already going
	if(isf.clock == null)
	{
		//copy the image object 
		isf.obj = arguments[0];
		
		//copy the image src argument 
		isf.src = arguments[1];
		
		//store the supported form of opacity
		if(typeof isf.obj.style.opacity != 'undefined')
		{
			isf.type = 'w3c';
		}
		else if(typeof isf.obj.style.MozOpacity != 'undefined')
		{
			isf.type = 'moz';
		}
		else if(typeof isf.obj.style.KhtmlOpacity != 'undefined')
		{
			isf.type = 'khtml';
		}
		else if(typeof isf.obj.filters == 'object')
		{
			//weed out win/ie5.0 by testing the length of the filters collection (where filters is an object with no data)
			//then weed out mac/ie5 by testing first the existence of the alpha object (to prevent errors in win/ie5.0)
			//then the returned value type, which should be a number, but in mac/ie5 is an empty string
			isf.type = (isf.obj.filters.length > 0 && typeof isf.obj.filters.alpha == 'object' && typeof isf.obj.filters.alpha.opacity == 'number') ? 'ie' : 'none';
		}
		else
		{
			isf.type = 'none';
		}
		//change the image alt text if defined
		if(typeof arguments[3] != 'undefined' && arguments[3] != '')
		{
			isf.obj.alt = arguments[3];
		}
		
		//if any kind of opacity is supported
		if(isf.type != 'none')
		{
			//copy and convert fade duration argument 
			//the duration specifies the whole transition
			//but the swapfade is two distinct transitions
			isf.length = parseInt(arguments[2], 10) * 200;
			
			//create fade resolution argument as 20 steps per transition
			//again, split for the two distrinct transitions
			isf.resolution = parseInt(arguments[2], 10) * 10;
			//alert(isf.length+ ' / ' + isf.resolution + ' = ' + isf.length/isf.resolution);
			//start the timer
			isf.clock = setInterval('isf.swapfade()', isf.length/isf.resolution);
		}
		
		//otherwise if opacity is not supported
		else
		{
			//just do the image swap
			isf.obj.src = isf.src;
		}
		
	}
};


//swapfade timer function
isf.swapfade = function()
{
	//increase or reduce the counter on an exponential scale
	isf.count = (isf.fade) ? isf.count * 0.9 : (isf.count * (1/0.9)); 
	
	//if the counter has reached the bottom
	if(isf.count < (1 / isf.resolution))
	{
		//clear the timer
		clearInterval(isf.clock);
		isf.clock = null;

		//do the image swap
		isf.obj.src = isf.src;

		//reverse the fade direction flag
		isf.fade = false;
		
		//restart the timer
		isf.clock = setInterval('isf.swapfade()', isf.length/isf.resolution);

	}
	
	//if the counter has reached the top
	if(isf.count > (1 - (1 / isf.resolution)))
	{
		//clear the timer
		clearInterval(isf.clock);
		isf.clock = null;

		//reset the fade direction flag
		isf.fade = true;
		
		//reset the counter
		isf.count = 1;
	}

	//set new opacity value on element
	//using whatever method is supported
	switch(isf.type)
	{
		case 'ie' :
			isf.obj.filters.alpha.opacity = isf.count * 100;
			break;
			
		case 'khtml' :
			isf.obj.style.KhtmlOpacity = isf.count;
			break;
			
		case 'moz' : 
			//restrict max opacity to prevent a visual popping effect in firefox
			isf.obj.style.MozOpacity = (isf.count == 1 ? 0.9999999 : isf.count);
			break;
			
		default : 
			//restrict max opacity to prevent a visual popping effect in firefox
			isf.obj.style.opacity = (isf.count == 1 ? 0.9999999 : isf.count);
	}
};

//////////////////////////////
