function Opacifier(){
	//hack for self-referancing timer
	this.id = "Opacifier" + OpacifierIdNumb++;
	window[this.id] = this;
	//end hack
		
	this.banId;  //id currently banned from operating
	this.timers = []; //array of timers
}// end Opacifier

//will stop any opacity changes to id	
Opacifier.prototype.stop = function(id){
	this.banId = id;
}

//will re-allow opacity changes to continue on id
Opacifier.prototype.start = function(id){
	if(this.banId == id) this.banId = '';
}

//clear timers for id (implies that all current operations will be terminated (timers can't be postponed) )
Opacifier.prototype.clearTimers = function(id){
	this.stop(id);
	//initialize new array for this id if there isn't one
	if(undefined===this.timers[id]) this.timers[id] = [];
	var arr = this.timers[id];
	//run loop in reverse an maybe catch ones that haven't fired yet.
	for(var i = arr.length; i>0; i--)
		clearTimeout(arr[i]);
	this.timers[id] = [];  //clear timers array for id
	this.start(id); //allow operations on id
};

//make id opaque instantly
Opacifier.prototype.opaque = function(id){
	this.transOpacity(id, 100, 100, 1);
};

//make id transparent instantly
Opacifier.prototype.transparent = function(id){
	this.transOpacity(id, 0, 0, 1);
};

Opacifier.prototype.transOpacity = function(id, opacStart, opacEnd, millisec){
	this.clearTimers(id); //clear the timers for this id
	//speed for each frame
  var speed = Math.round(millisec / 100);
  var timer = 0;
  var thisObj = this;
  //determine the direction for the blending, if start and end are the same set to start value
  if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--){
			if(this.banId != id){ //allow another operation on this id to break this operation mid-process
			//this.timers[id].push(setTimeout("changeOpac('" + i + "','" + id + "')",(timer * speed)));
				this.timers[id].push(setTimeout("window."+this.id+".changeOpac('" + i + "','" + id + "')", (timer * speed)));
				timer++;
			}else break;				
  	}
  }else if(opacStart < opacEnd){
  	for(i = opacStart; i <= opacEnd; i++){
  		if(this.banId != id){ //allow another operation on this id to break this operation mid-process
   			//this.timers[id].push(setTimeout("changeOpac('" + i + "','" + id + "')",(timer * speed)));
				this.timers[id].push(setTimeout("window."+this.id+".changeOpac('" + i + "','" + id + "')", (timer * speed)));
				timer++;
			}else break;
  	}
	}else if(opacStart == opacEnd){
		this.changeOpac(opacStart, id); //change transparency with no increments
	}
};

Opacifier.prototype.changeOpac = function(opacity, id){
	if(this.banId != id){  //only apply changes to id if it isn't currently banned
		var object = document.getElementById(id).style;
  	object.MozOpacity = (opacity / 100);								//old Mozilla
  	object.KhtmlOpacity = (opacity / 100);							//older webkit like konqueror for linux
  	object.filter = "alpha(opacity=" + opacity + ")";		//IE 6+ (notice the non-standard syntax...)
  	object.opacity = (opacity / 100);										//most other browsers that support transparency
  }
};

Opacifier.prototype.getOpacity = function(id){
	var opac;
	var object = document.getElementById(id).style;
	if(object.MozOpacity > 0) opac = object.MozOpacity*100;
	else if(object.KhtmlOpacity > 0) opac = object.MozOpacity*100;
	else if(object.opacity > 0) opac = object.opacity*100;
	else opac = 0;
	return opac;
}

var OpacifierIdNumb = 0;

