//*--------------------------------------------------------
//* Display tool image in left sidebar. First pic is random, next pics rotate.
//* Last image filename displayed is saved in a cookie.
//*--------------------------------------------------------                            
	var w 	= "73";
	var h	= "107";
	var pic	= "y-hammer.gif";  //* Default pics
	var hs	= "0";
	var vs	= "0";
	var border = "0";
//*------------------------------------ 
//*  Place images in array. 
//*------------------------------------
	var p=new Array(); 	
	var ix =-1;  
//	p[ix] = "x-watch.jpg"; 	
 
	p[ix = ix + 1] = "y-hammer.gif"
	p[ix = ix + 1] = "y-gloves.gif"
	p[ix = ix + 1] = "y-screwdrivers.gif" 
//   p[ix = ix + 1] = "y-toolbag.gif"
    p[ix = ix + 1] = "y-toolbag2.gif"
 	p[ix = ix + 1] = "y-drill.gif"
// 	p[ix = ix + 1] = "y-drillbits.gif"
//	p[ix = ix + 1] = ""
 
 
	//p[ix = ix + 1] = "";
	var pcount =  p.length  // no. of array elments

	var picindex = getCookie("toolpic");  
  	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;
 	if (iy >= pcount) {iy = 0}; 
 
 

 	if (thefile.substring(0,"home".length) == "home")	{
	//	iy = 0;
	}	
 //* Always display hammer on Why Us page	
	if (thefile.substring(0,"why".length) == "why" || thefile.substring(0,"0-why".length) == "0-why")	{
	//	iy = 0;
	}	 	
 	
 	pic = p[iy];
 	setCookie("toolpic", iy); 
  
//alert(pic);  
  
if (thefile.substring(0,"home".length) != "home")	{
	  
document.write('<DIV style="position: absolute;left: 50%;top: 500px;width:75px;height:140px;margin-left:-410px;z-index:11;"><img src="../images/' +  pic + '" width="75" height="140" border="0"></DIV>');
} 
 
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));
     } 