
function AdRotator(){
	this.imagecount = 1;
	this.numbercount = 1;
	this.setImagesize= setImagesize;
	this.imagewidth;
	this.imageheight;
	this.setNumbersize= setNumbersize;
	this.numberwidth;
	this.numberheight;
	this.setImagesrc = setImagesrc;
	this.setNumbersrc = setNumbersrc;
	this.featureimage = new Array();
	this.numberimage = new Array();
	this.linklist = new Array();
	this.altlist = new Array();
	this.getPicture = getPicture;
	this.changePicture = changePicture;
	this.pic = 1;
	this.resumepic = 1;
	this.pace;
	this.auto = true;
	this.gotoPage = gotoPage;
	this.start = start;
	this.stop = stop;
    this.changePromo = changePromo;
    this.promos = new Array(5);
    this.picnum = 1;
    this.nextPic = nextPic;
    this.prevPic = prevPic;  
}

function setImagesize(width,height){
	this.imagewidth = width;
	this.imageheight = height;
	return;
}

function setNumbersize(width,height){
	this.numberwidth = width;
	this.numberheight = height;
	return;
}
/*********************************************
param@ String image src
param@ String page link
Preloads main image and set links 
*********************************************/
function setImagesrc(src,page,alt){
    this.featureimage[this.imagecount] = new Image(this.imagewidth,this.imageheight);
	this.featureimage[this.imagecount].src = imgdir+src;
	this.linklist[this.imagecount] = page;
	this.altlist[this.imagecount] = alt;
	this.imagecount++;
	return;
}

/*********************************************
param@ String image src on
param@ String image src off
Preloads promotional images (should be like
the numbers)
*********************************************/
function setNumbersrc(src_on,src_off){
	this.numberimage[this.numbercount] = new Array(2);
	this.numberimage[this.numbercount][0] = new Image(this.numberwidth,this.numberheight);
	this.numberimage[this.numbercount][0].src = imgdir+src_on;
	this.numberimage[this.numbercount][1] = new Image(this.numberwidth,this.numberheight);
	this.numberimage[this.numbercount][1].src = imgdir+src_off;
	this.numbercount++;
	return;
}

/*********************************************
Method calls changePicture method and increments
picture iterator.
*********************************************/
function getPicture(){
//alert(this.pic);

if (this.pic < (this.imagecount))
{
    this.changePicture(this.pic);
    this.pic++;
}
else
{
    this.pic = 2;
    this.changePicture(1);
}

	
	//this.pic == (this.numbercount - 1) ? this.pic = 1 : this.pic++;
    picnum = this.pic; 
    picnum--;
	return;
}
/*********************************************
param@ int picture number
Method sets all number images off then gets the
on image for the selected picture and retrieves
the main image.
*********************************************/
function changePicture(pic_on){
	for(var i = 1; i < this.numbercount; i++){
		document.images["number"+ i].src = this.numberimage[i][1].src;
		document.images["number"+ i].alt = this.altlist[pic_on];
        this.changePromo(" ");
	}
//	document.images["number"+pic_on].src = this.numberimage[pic_on][0].src;
	document.images["feature"].src = this.featureimage[pic_on].src;
	document.images["feature"].alt = this.altlist[pic_on];
	document.images["feature"].title = this.altlist[pic_on];
  //  this.changePromo(this.promos[pic_on-1]);
  picnum=pic_on;
  
	return;
}

/*********************************************
Method starts and restarts auto switching of
the images.
*********************************************/
function start() {
	myad.getPicture();
	this.pace = setInterval("myad.getPicture()",6000);
	return;
}

/*********************************************
Method stops auto switching and change moused 
over image.
*********************************************/
function stop(mypic) {
	clearInterval(this.pace);
	this.changePicture(mypic);
	return;
}

/*********************************************
Method determines which image is highlighted
and goes to the correct page.
*********************************************/
function gotoPage(){
//alert(picnum);
	/*var linknumber = 1;
	for(var i = 1; i < this.numbercount; i++){
		if(document.images["number"+ i].src == this.numberimage[i][0].src){
			linknumber = i;
		}
	}*/
	self.location.href = this.linklist[picnum];
	return;
}
/*********************************************
Method for changing html text
*********************************************/
function changePromo(whichcontent){
return;
    if (document.getElementById)
    	{
        	document.getElementById(["descriptions"]).innerHTML = whichcontent;
    	}
    else if (document.layers)
    	{
        
        	document.d1.document.d2.document.write(whichcontent);
        	document.d1.document.d2.document.close();
    	}
    else
        {   
           descriptions.innerHTML = whichcontent;
        }
                       
}

function nextPic()
{
//alert("count "+this.imagecount);
clearInterval(this.pace);
//alert("picnum "+ picnum);

if (picnum < (this.imagecount-1))
{
    this.changePicture(picnum+1);
    this.pic = picnum-1;
}
else
{
    this.changePicture(1);
    this.pic = 1;
}

//alert("pic1 "+this.pic);
this.pace = setInterval("myad.getPicture()",6000);
}

function prevPic()
{
//alert("picnum "+ picnum);
clearInterval(this.pace);
if (picnum > 1)
{
    this.changePicture(picnum-1);
    this.pic = picnum+1;
    
}
else
{
    this.changePicture(this.imagecount-1);
    this.pic = this.imagecount-1;
}

this.pace = setInterval("myad.getPicture()",6000);
}
