
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.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.wait = wait;
    
}

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){
    this.featureimage[this.imagecount] = new Image(this.imagewidth,this.imageheight);
	this.featureimage[this.imagecount].src = imgdir+src;
	this.linklist[this.imagecount] = page;
	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(){
	this.changePicture(this.pic);
	this.pic == (this.numbercount - 1) ? this.pic = 1 : this.pic++;
	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;
        this.changePromo(" ");
	}
	document.images["number"+pic_on].src = this.numberimage[pic_on][0].src;
	document.images["feature"].src = this.featureimage[pic_on].src;
    this.changePromo(this.promos[pic_on-1]);
	return;
}

/*********************************************
Method starts and restarts auto switching of
the images.
*********************************************/
function start() {
	myad.getPicture();
	this.pace = setInterval("myad.getPicture()",5000);
	return;
}

/*********************************************
Method stops auto switching and change moused 
over image.
*********************************************/
function stop(mypic) {
	clearInterval(this.pace);
	this.changePicture(mypic);
	return;
}

/*********************************************
Method stops auto switching and waits to
start rotating again
*********************************************/
function wait(mypic) {
	clearInterval(this.pace);
	this.pic = mypic;
	this.pace = setInterval("myad.getPicture()",5000);
	return;
}

/*********************************************
Method determines which image is highlighted
and goes to the correct page.
*********************************************/
function gotoPage(){
	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[linknumber];
	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;
        }
                       
}
