<!--
/*************************************************************************
  This code is from Dynamic Web Coding 
  at http://www.dyn-web.com/
  Copyright 2001-3 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  Permission granted to use this code 
  as long as this entire notice is included.
*************************************************************************/

// if you want to open sub-window onclick of images set variables here
var subWin;
var subWinWd = 520;	// width of sub-window
var subWinHt = 350;	// height of sub-window
// add/remove window chrome as needed (no spaces between them!)
// list of common chrome elements: "menubar,location,toolbar,status,scrollbars,resizable"
var subWinChrome = "resizable";
// for centering sub-window on screen
var subWinTop = Math.round( (screen.availHeight - subWinHt)/2 );
var subWinLeft = Math.round( (screen.availWidth - subWinWd)/2 );

function initImgRotation() {
  // create rotating image objects here 
  // arguments: image name, rotation speed (milliseconds)
  var rotator1 = new rotateImgObj('img1',3500);
  // add the images to rotate into that image object
  rotator1.addImages("1.gif","2.gif","3.gif");
	rotator1.addActions(
    "javascript: window.location = 'clients.asp'" // how to open url in same window
    );
  
  var rotator2 = new rotateImgObj('img2', 4500);
  rotator2.addImages("4.gif","5.gif","6.gif");
		rotator2.addActions(
    "javascript: window.location = 'clients.asp'" // how to open url in same window
    );
  
  var rotator3 = new rotateImgObj('img3', 5500);
  rotator3.addImages("7.gif","8.gif","9.gif","10.gif");
	rotator3.addActions(
    "javascript: window.location = 'clients.asp'" // how to open url in same window
    );


  // starts rotation for all defined rotateImgObjs
  for (var i=0; i<rotateImgObjs.length; i++) 
    rotateImgObjs[i].timer = setInterval(rotateImgObjs[i].animString + ".rotate()", rotateImgObjs[i].speed);
}

// for example function call onclick  
var msg1 = "You could call another function onclick of the images, or set" + "\n" + "the window.location property to load another document.";
function doMsg(msg) { alert(msg); }

// If all the images you wish to display are in the same location, you can specify the path here 
rotateImgObj.imagesPath = "clientlogos/";

rotateImgObjs = []; // holds all rotating image objects defined
// constructor 
function rotateImgObj(nm,s) {
  this.speed=s; this.ctr=0; this.timer=0;  
  this.imgObj = document.images[nm]; // get reference to the image object
  this.index = rotateImgObjs.length; rotateImgObjs[this.index] = this;
  this.animString = "rotateImgObjs[" + this.index + "]";

  this.addImages = addRotatingImages; this.addActions = addClickActions;
  this.rotate = rotateImg;
}

function addRotatingImages() {
  this.imgObj.imgs = [];
  for (var i=0; i<arguments.length; i++) {
    this.imgObj.imgs[i] = new Image();
    this.imgObj.imgs[i].src = rotateImgObj.imagesPath + arguments[i];
  }
}

function addClickActions() {
  this.actions = [];
  for (var i=0; i<arguments.length; i++) { this.actions[i] = arguments[i]; }
}

// called onclick of images
function doImgClick(n) {
	if ( document.images && rotateImgObjs[n] ) {
    var obj = rotateImgObjs[n]; // shorten reference 
    if ( obj.actions && obj.actions[obj.ctr] ) {
  		if ( obj.actions[obj.ctr].indexOf('javascript:') != -1 ) eval( obj.actions[obj.ctr] );
  		else {
  			if ( subWin && !subWin.closed ) subWin.focus();
  			subWin = window.open( obj.actions[obj.ctr], "subWin",
           subWinChrome+",height="+subWinHt+",width="+subWinWd+",top="+subWinTop+",left="+subWinLeft); 
  		}
    } 
	}
}

// automatically closes sub-window when document unloads
function closeWin() {	if (subWin && !subWin.closed) subWin.close(); }
window.onunload = closeWin;


// controls rotation
function rotateImg() {
  if (this.ctr < this.imgObj.imgs.length-1) this.ctr++;
  else this.ctr = 0;
  this.imgObj.src = this.imgObj.imgs[this.ctr].src;
}

// for stopping/starting onmouseover/out
function stopRotation(n) {	
  if (rotateImgObjs[n]) clearInterval(rotateImgObjs[n].timer); 
}

function restartRotation(n) {
  if ( rotateImgObjs[n] ) {
    var obj = rotateImgObjs[n]; // shorten reference 
    obj.rotate(); // rotate now and resume repeated calls
    obj.timer = setInterval( obj.animString + ".rotate()", obj.speed );
  }
}
//-->
