Array.prototype.remove = function(from, to) {
  var rest = this.slice((to || from) + 1 || this.length);
  this.length = from < 0 ? this.length + from : from;
  return this.push.apply(this, rest);
};

var LogoFade;

function logofadeLoad() {
	if( $('hiddenLogos') )
	{
		var hidLogos = $('hiddenLogos');
		var logoContainer = $('logofadeWrap');
		var logoDisplay = $('logofadeDisplay');
		var logos = hidLogos.getElementsByTagName('div');
		
		var fadeIncrement = 3;
		var fadeDelay = 25;
		var delayTime = 1500;
		
		var maxHeight = 0;
		var logoHeight = [];
		var images = hidLogos.getElementsByTagName('img');
		for( var l = 0; l < images.length; l++ )
		{
			logoHeight.push(images[l].height);
			if( images[l].height > maxHeight ) maxHeight = images[l].height;
		}
		logoDisplay.style.height = maxHeight + 'px';
		hidLogos.style.display = 'none';
		function makeActiveObject(DOMelement) {
			DOMelement.style.filter = "alpha(opacity=0)";			
			DOMelement.style.opacity = 0;

			return {'DOMelement':DOMelement,'currentOpacity':0};
		}
	
		LogoFade = function() {
			
			return {
				hidLogos:hidLogos,
				logoDisplay:logoDisplay,
				logos:logos,
				logoIndex:0,
				fadeIncrement: fadeIncrement,
				active: 0,
				fade: 0,
				delayTime: delayTime,
				fadeDelay: fadeDelay,
				maxHeight: maxHeight,
				logoHeight: logoHeight,
				addLogo: function() {
					var newLogo = document.createElement('div');
					
					newLogo.innerHTML = this.logos[this.logoIndex].innerHTML;
					newLogo.onclick = this.logos[this.logoIndex].onclick;
					newLogo.setAttribute(document.all?'className':'class','activeLogo');
					if( newLogo.onclick )
						newLogo.style.cursor = 'pointer';
					this.active = makeActiveObject(newLogo);

					newLogo.style.paddingTop = parseInt((this.maxHeight - this.logoHeight[this.logoIndex])/2) + 'px';	
					this.logoDisplay.appendChild(newLogo);
					
				
					this.logoIndex = (this.logoIndex + 1) % this.logos.length; 
				},
				fadeLogo: function() {
						var element = this.active['DOMelement'] ;
						var opacity = this.active['currentOpacity'];
						if( this.fadeIncrement > 0 )
						{
							if( (parseInt(opacity*100) + this.fadeIncrement) < 100 )
							{
								this.active['currentOpacity'] = opacity + this.fadeIncrement/100;
							} else {
								this.active['currentOpacity'] = 1;
								element.style.filter = "alpha(opacity=100)";
								element.style.opacity = 1;
								opacity = 1;
								this.fade = 1;
								this.fadeIncrement = this.fadeIncrement*(-1);
							}
						} else if( this.fadeIncrement < 0 ) {
							if( (parseInt(opacity*100) + this.fadeIncrement) > 0)
                                                        {
                                                                this.active['currentOpacity'] = opacity + this.fadeIncrement/100;
                                                        } else {
                                                                this.active['currentOpacity'] = 0;
                                                                element.style.filter = "alpha(opacity=0)";
                                                                element.style.opacity = 0;
								opacity = 0;
                                                                this.fade = 0;
                                                                this.fadeIncrement = this.fadeIncrement*(-1);;
                                                        }

						}

						element.style.filter = "alpha(opacity="+parseInt(100*opacity)+")";
						element.style.opacity = opacity;
				},
				updateLogos: function(){
					if( this.fade == 0 ) 
					{
						if( this.active != 0 )
							this.logoDisplay.removeChild(this.active['DOMelement']);
						this.fade = 'IN';
						this.addLogo();
						setTimeout('LogoFade.updateLogos()',10);
					} else if( this.fade == 1 ) {
						this.fade = 'OUT';
						setTimeout('LogoFade.updateLogos()',this.delayTime);
					} else if( this.fade == 'IN' ) {
						this.fadeLogo();
						setTimeout('LogoFade.updateLogos()',this.fadeDelay);
					} else if( this.fade == 'OUT' ) {
						this.fadeLogo();
						setTimeout('LogoFade.updateLogos()',this.fadeDelay);
					}
		
				}
			};
		}();
	
		LogoFade.updateLogos();
	}	
}