//*--------------------------------------------------------
//* Display header image. First pic is random, next pics rotate.
//* Last image filename displayed is saved in a cookie.
//*--------------------------------------------------------                            
	var w 	= "160";
	var h	= "60";
	var pic	= "x-watch.jpg";  //* Default pics
	var hs	= "0";
	var vs	= "0";
	var border = "0";
//*------------------------------------ 
//*  Place images in array. 
//*------------------------------------
	var p=new Array(); //* Picture (banner)
	var a=new Array(); //* Alt tag
	var w=new Array(); //* Website	
	var ix =-1;  
//	p[ix] = "x-watch.jpg"; 	
 
	ix = ix + 1;	
	p[ix] = "x-bennett-160x60.gif"
	a[ix] = "Bennett Power Sports"
	w[ix] = "http://www.bennettpowersports.com"

	ix = ix + 1;	
	p[ix] = "x-cyclewerx-160x60.gif"
	a[ix] = "Cycle Werx"
	w[ix] = "http://www.cyclewerx.ca"

	ix = ix + 1;	
	p[ix] = "x-daymak-160x60.gif"
	a[ix] = "Daymak - Cool Means of Transportation"
	w[ix] = "http://www.daymak.com"
		
	ix = ix + 1;	
	p[ix] = "x-dukes-160x60.gif"
	a[ix] = "The Dukes of Cycle"
	w[ix] = "http://www.thedukesofcycle.com"

	ix = ix + 1;	
	p[ix] = "x-edgeperformance-160x60.gif"
	a[ix] = "Edge Performance"
	w[ix] = "http://edgeperformance.ca"
		
	ix = ix + 1;	
	p[ix] = "x-johnnypag-160x60.gif"
	a[ix] = "Johnny Pag Motorcycles Canada"
	w[ix] = "http://www.johnnypag.ca"	
	
	ix = ix + 1;
	p[ix] = "x-kahuna-160x60.gif"
	a[ix] = "Kahuna Power Sports"
	w[ix] = "http://kahunapowersports.com"	
	
	ix = ix + 1;
	p[ix] = "x-kanes-harley-160x60.gif"
	a[ix] = "Kane's Harley Davidson"
	w[ix] = "http://www.kanesharleydavidson.net"		
	
	ix = ix + 1;	
	p[ix] = "x-kellys-160x60.gif"
	a[ix] = "Kellys Cycle Centre"
	w[ix] = "http://kellyscyclecentre.com"
	ix = ix + 1;
	p[ix] = "x-motolimo-160x60.gif"
	a[ix] = "MotoLimo"
	w[ix] = "http://www.motolimo.com/"	
	ix = ix + 1;	
	p[ix] = "x-motoretta-160x60.gif"
	a[ix] = "Motoretta"
	w[ix] = "http://motoretta.ca"
	ix = ix + 1;		
	p[ix] = "x-motorsports-pickering-160x60.gif"
	a[ix] = "Motorsports Pickering"
	w[ix] = "http://motorsportspickering.com"	
	ix = ix + 1;	
	p[ix] = "x-parkwayhonda-160x60.gif"
	a[ix] = "Parkway Honda"
	w[ix] = "http://www.parkwayhondapowerhouse.com/"
	ix = ix + 1;	
	p[ix] = "x-peak-powersports-160x60.gif"
	a[ix] = "Peak Powersports"
	w[ix] = "http://www.peakpowersports.ca/"		
	ix = ix + 1;	
	p[ix] = "x-peninsula-160x60.gif"
	a[ix] = "Peninsula Imports"
	w[ix] = "http://peninsulaimports.com/store-ducati/"
	
	ix = ix + 1;
	p[ix] = "x-performance-cycle-160x60.gif"
	a[ix] = "Performance Cycle"
	w[ix] = "http://performancecycle.ca"	
		
	ix = ix + 1;
	p[ix] = "x-ready-160x60.gif"
	a[ix] = "Ready Honda"
	w[ix] = "http://www.readyhondapowerhouse.com/"	
	ix = ix + 1;	
	p[ix] = "x-riders-choice.gif"
	a[ix] = "Riders Choice"
	w[ix] = "http://riderschoice.ca"

	ix = ix + 1;	
	p[ix] = "x-snowcity-160x60.gif"
	a[ix] = "Snow City Cycle Marine"
	w[ix] = "http://www.snowcity.com"		
	
	ix = ix + 1;	
	p[ix] = "x-spoiled-sports-160x60.gif"
	a[ix] = "Spoiled Sports"
	w[ix] = "http://www.spoiledsports.com"		
	ix = ix + 1;
	p[ix] = "x-sturgess-160x60.gif"
	a[ix] = "Sturgess Cycle"
	w[ix] = "http://sturgessonline.com"		
	ix = ix + 1;		
	p[ix] = "x-titan-160x60.gif"
	a[ix] = "Titan Motorcycles"
	w[ix] = "http://www.titanmotorcycles.com"		

	ix = ix + 1;
	p[ix] = "x-ultimate-cycle-160x60.gif"
	a[ix] = "Ultimate Cycle"
	w[ix] = "http://ultimate-cycle.com"		

	ix = ix + 1;
	p[ix] = "x-vernon-160x60.gif"
	a[ix] = "Vernon Motor Sports"
	w[ix] = "http://www.vernonmotorsports.com"	
	
	ix = ix + 1;
	p[ix] = "x-vonn-160x60.gif"
	a[ix] = "Vonn Cycle"
	w[ix] = "http://www.vonncycle.ca"														 
 
	//p[ix = ix + 1] = "";
	var pcount =  p.length  // no. of array elments
	

	
	var picindex = getCookie("rowpic");  
  	if (picindex == null) {picindex = get_random(pcount); }  // get random pic the first time
 	picindex = parseInt(picindex);  // Converts string to a number
 	var iy = picindex + 1;

	var theSpace = '<br><img src="../images/spacer.gif" width=4 height=15 border=0><br>';
	var nLimit = 8;  //* no of banners displayed in right column
	// document.write("iy1=" + iy);
	var i=1;
	while (i <= nLimit) 
	{
		iy = iy + 1;
		if (iy >= pcount) {iy = 0}; 	
		sPic = p[iy];
		sAlt = a[iy];
		sWeb = w[iy];	 
		theRow ='<a href="' + sWeb + '" target="_blank" class="img"><img src="../images/' + sPic + '" alt="' + sAlt + '" width="160" height="60" border="0"></a>';
		//alert(theRow);
//		document.write("<br>iy=" + iy);
//		document.write("<br>i=" + i);
		document.write(theRow);
   		document.write(theSpace);
		i++;
	}
	setCookie("rowpic", iy - 1);  

//alert(pic1 + " " + alt1  + " " + web1)	
//alert(theRow)	

function whichPic(count) {
//* Count is the number of itmems in the array - 1.
	count = count - 1;  //* because array is from [0] to [n]
    var ranNum= Math.round(Math.random()*  count );
    return ranNum;
}
	
function get_random(pcount) {
    var ranNum= Math.round(Math.random()* pcount);
    return ranNum;
}	

function setCookie(name, value, expires, path, domain, secure) {
//*******************************************************************************
// Generic rtn to set a cookie.
//*******************************************************************************
       var curCookie = name + "=" + escape(value) +
           ((expires) ? "; expires=" + expires.toGMTString() : "") +
           ((path) ? "; path=" + path : "") +
           ((domain) ? "; domain=" + domain : "") +
           ((secure) ? "; secure" : "");
       document.cookie = curCookie;
}
 
function getCookie(name) {
//*******************************************************************************
// Get a cookie.
//*******************************************************************************	
       var dc = document.cookie;
       var prefix = name + "=";
       var begin = dc.indexOf("; " + prefix);
       if (begin == -1) {
         begin = dc.indexOf(prefix);
         if (begin != 0) return null;
       } else
         begin += 2;
       var end = document.cookie.indexOf(";", begin);
       if (end == -1)
         end = dc.length;
       return unescape(dc.substring(begin + prefix.length, end));
     } 