
var bannerImage = new Array ( );
var bannerUrl = new Array( );
var bannerAlt = new Array( );

function addBanner( imageName, urlText, altText )
{
	var bannerIndex = 0;
	bannerIndex = bannerImage.length;

	if( imageName != '' ) {
		bannerImage[ bannerIndex ] = imageName;
		bannerUrl[ bannerIndex ] = urlText;
		bannerAlt[ bannerIndex ] = altText;
	}
}

// Parameters:	'second' = new Image will be displayed every refresh
//		   	'hour' = new image will be displayed every hour
//			'day' = new image will be displayed daily
//			'week' = new image will be displayed weekly
//			'month' = new immage will be displayed monthly


function printBanner(timeInterval)
{
	var numBannerImages = bannerImage.length;
	var fakeSeed = new Date();
	var fakeRand = 0;

	switch( timeInterval )
	{
		case 'second' : 
					fakeRand = fakeSeed.getMilliseconds() % numBannerImages ;
				  	break;

		case 'minute' :	
					fakeRand = fakeSeed.getMinutes() % numBannerImages ;
				  	break;
		case 'hour' :
					fakeRand = fakeSeed.getHour() % numBannerImages ;
					break;

		case 'day' :	
					fakeRand = fakeSeed.getDay() % numBannerImages ;
					break;

		case 'week' :	
					// 604800000 is the number of milliseconds in a week
					fakeRand = ( fakeSeed.getTime() % 604800000 ) % numBannerImages;
					break;

		case 'biweek' :	
					// 604800000 is the number of milliseconds in a week
					fakeRand = ( fakeSeed.getTime() % ( 2 * 604800000 ) ) % numBannerImages;
					break;

		case 'month' : 
					fakeRand = fakeSeed.getMonth() % numBannerImages ;
					break;
	}

	if( numBannerImages > 0 ) {

		// If a URL exists make a hyperlink around the image
		if( bannerUrl[ fakeRand ] != '' ) {
			document.write( '<a href="' + bannerUrl[ fakeRand ] + '">' );
		}

		if( bannerImage[ fakeRand ].indexOf('.swf') < 0 ) {
			// Print Image	
			document.write( '<img src="images/' + bannerImage[ fakeRand ] + '" border="0"' );

			// If a ALT text exists print it in the image tag
			if( bannerAlt[ fakeRand ] != '' ) {
				document.write( ' alt="' + bannerAlt[ fakeRand ] + '"' );
			}

			document.write( '/>' );
		} else {
				// Print Flash File

				document.write( '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="425" HEIGHT="148" id="DEbanner" ALIGN="">' );
				document.write( '<PARAM NAME=movie VALUE="images/' + bannerImage[ fakeRand ] + '">' );
				document.write( '<PARAM NAME=quality VALUE=high><PARAM NAME=bgcolor VALUE=#FFFFFF>' );
				document.write( '<EMBED src="images/' + bannerImage[ fakeRand ] + '" quality=high bgcolor=#FFFFFF  WIDTH="425" HEIGHT="148" NAME="DEbanner" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>' );
				document.write( '</OBJECT>' );
		}

		// If a URL exists make a hyperlink around the image
		if( bannerUrl[ fakeRand ] != '' ) {
			document.write( '</a>' );
		}
	}
	return false;	
}


// Parameters:	'second' = new Image will be displayed every refresh
//		   	'hour' = new image will be displayed every hour
//			'day' = new image will be displayed daily
//			'week' = new image will be displayed weekly
//			'month' = new immage will be displayed monthly


function timedRand( timeInterval, maxVal )
{
	var fakeSeed = new Date();
	var fakeRand = 0;

	switch( timeInterval )
	{
		case 'second' : 
					fakeRand = fakeSeed.getMilliseconds() % maxVal ;
				  	break;

		case 'minute' :	
					fakeRand = fakeSeed.getMinutes() % maxVal ;
				  	break;
		case 'hour' :
					fakeRand = fakeSeed.getHour() % maxVal ;
					break;

		case 'day' :	
					fakeRand = fakeSeed.getDay() % maxVal ;
					break;

		case 'week' :	
					// 604800000 is the number of milliseconds in a week
					fakeRand = parseInt(( fakeSeed.getTime() / 604800000 ) % maxVal );
					break;

		case 'biweek' :	
					// 604800000 is the number of milliseconds in a week
					fakeRand = parseInt(( fakeSeed.getTime() / ( 2 * 604800000 ) ) % maxVal);
					break;

		case 'month' : 
					fakeRand = fakeSeed.getMonth() % maxVal ;
					break;

		default: 		
					fakeRand = -1;
					break;
		}

		return fakeRand;
}


