
function Sello_MenuController() {

	this.selected = 0; 
	this.slide = -1;
	
	this.locations = new Array(0);
	this.onMouseOverImages = new Array(0);
	this.onMouseOutImages = new Array(0);
	
	this.slidePictures = new Array(0);
	
	this.nextSlide = function()	{
	 // alert(this.slidePictures[0]);
	  if (this.slide == -1)	{
	    this.preloadSlides();
	    this.slide = 0;
	  }

	  var _span = '<IMG SRC="'+this.slidePictures[this.slide]+'" WIDTH=247 HEIGHT=166 ALT="">';
	  writeSpan(getBaseWindow(),'top_picture_span',_span);
	  
	  this.slide++;

	  if (this.slide >= this.slidePictures.length)	{
	  	this.slide = 0;
	  }

	}
	
	this.preloadSlides = function() {
		if (document.images) {
			for (var i=0;i<this.slidePictures.lenght;i++)	{
			  eval('getBaseWindow().slide_'+i+'_image = newImage("'+this.slidePictures[i]+'");');
			}
		}
	}
	
	this.click = function (location)	{
	
	  if (!this.locations[location])	{
	    return false;
	  }
	
		if (location != this.selected)	{
	  	this.selected = location;
			this.resetMenu();
	  	setWorkLocation(this.locations[location]);
	  }
	}

	this.changeImages = function(location,way) {
		var preloadFlag2 = location != this.selected;
		if (document.images && (preloadFlag2 == true)) {
			var imagearray = (way == 0) ? this.onMouseOutImages[location] : this.onMouseOverImages[location];
			for (var i=0; i<imagearray.length; i+=2) {
				//getBaseWindow().document.getElementById(imagearray[i]).src = imagearray[i+1];
				changeImages(imagearray[i],imagearray[i+1]);
			}
		}
	}
	
	this.resetMenu = function() {
	  for(var i=0; i<this.onMouseOutImages.length; i++)	{
	  	if (i!=this.selected)	{
		    var imagearray = this.onMouseOutImages[i];
				for (var j=0; j<imagearray.length; j+=2) {
					getBaseWindow().document.getElementById(imagearray[j]).src = imagearray[j+1];
				}
			}
	  }
	}
	
	this.setSelected = function(location)	{

	  if (!this.locations[location])	{
	    return false;
	  }
	
		if (location != this.selected)	{
	  	this.selected = location;
			this.resetMenu();
			var way = 1;

			var imagearray = (way == 0) ? this.onMouseOutImages[location] : this.onMouseOverImages[location];
			for (var i=0; i<imagearray.length; i+=2) {
				//getBaseWindow().document.getElementById(imagearray[i]).src = imagearray[i+1];
				changeImages(imagearray[i],imagearray[i+1]);
			}
	  }
	}



}
