﻿var globalScope = new Array();
var i=0;
//Color rain
var crain = "074EB7", bgrain ="8BACBA";
//Time
var train = 4000;

function Rainbow(elementName){
	this.Element = elementName;
	this.Color1 = bgrain;
	this.tempclass ='';
	this.uniqueId =  "el"+i;
	this.Time = train;
	i++;
	if( document.all ){		
		this.tempclass = this.Element.className;
		this.Element.className = 'bgchange';
		globalScope[ this.uniqueId ] = this;		
		this.Timer= setTimeout( 'ieIntervalHandler("'+this.uniqueId+'","change")', this.Time );
	}
	else{		
		this.Element.setAttribute('style', 'color:#' + crain + '; background-color:#' + this.Color1);
		this.Timer = setTimeout ( function(o) { o.change(); }, this.Time, this );
	}
};
Rainbow.prototype.change =function(){	
	obj = this.Element;	
	if(document.all){
		obj.className = this.tempclass;
	}else{
		obj.setAttribute('style', '');	
	}
};
var obj;
function ieIntervalHandler(id, strFunc )
{
	var scope = globalScope[id];
	eval( "scope." + strFunc + "()" );
};

