<!--
/*
+------------------------------------------+
|           (c) Jakub Uhlik, 2005          |
+------------------------------------------+
|     jakub[DOT]uhlik[AT]gmail[DOT]com     |
++----------------------------------------++
| version: 4.0 (studioedita.com optimized) |
+------------------------------------------+
*/

// requires sniffer..

Independent_Fader = function(elm,startval,endval,numofframes,func,rate){
	var o = new Object();
	o.cf = 0; o.interval = ""; o.vis = document.getElementById(elm).style.visibility; o.processing = false; 
	o.elm = elm; o.elmstyle = document.getElementById(elm).style;
	o.sv = startval; if(o.sv == '') { o.sv = 100; } o.ev = endval; o.nof = numofframes; if(o.nof == '') { o.nof = 25; }
	o.rate = rate; if(o.rate == '') { o.rate = 30; } o.f = func; if(o.f == '') { o.f = 'easeInOutQuad'; } o.onendfunction = '';
	o.onendfunctionparams = ''; o.MASTER_OPACITY = '';
	for(var i in o){ 
		eval('this.'+i+' = o.'+i); 
	}
	delete o;
}
Independent_Fader.prototype.startease = function(){
	/*
	if(this.MASTER_OPACITY === ''){
		this.MASTER_OPACITY = this.ADDPROPERTY(this.sv);
	}
	*/
	if(this.processing == false){
		this.cf = 0;
		var objref = this;
		this.interval = setInterval(function() { objref.ease(); },this.rate);
	}else{
		
	}
}
Independent_Fader.prototype.ease = function(){
	this.processing = true;
	if(this.sv == 0) { this.MASTER_OPACITY = 0.1; }
	if(this.MASTER_OPACITY != this.ev) {
		var diffa = "";
		if(this.MASTER_OPACITY > this.ev){ diffa = - 100; this.MASTER_OPACITY = eval('EASE.' + this.f + '(' + this.cf + ',' + this.sv + ',' + diffa + ',' + this.nof + ')'); } 
		if(this.MASTER_OPACITY < this.ev){ diffa = 100; this.MASTER_OPACITY = eval('EASE.' + this.f + '(' + this.cf + ',' + this.sv + ',' + diffa + ',' + this.nof + ')'); }
	}
	this.MASTER_OPACITY = Math.round(this.MASTER_OPACITY);
	this.cf++;
	if(!this.fake) this.setAlpha();
	if(this.cf != this.nof){
		
	}else if(this.cf == this.nof){
		clearInterval(this.interval);
		this.processing = false;
		this.onFadeEnd();
	}else{
		alert("INFINITY LOOP");
	}
}
Independent_Fader.prototype.fadeIn = function(oef,oefp){
	this.onendfunction = oef; this.onendfunctionparams = oefp;
	if(browser._browser == 'IE' && browser._platform == 'Mac' || browser._browser == 'Opera'){
		this.show();
	}else{
		if(this.vis == 'hidden'){
			if(this.processing == false){ this.cf = 0; this.sv = 0; this.ev = 100; }
			this.startease();
		}
	}
}
Independent_Fader.prototype.fadeOut = function(oef,oefp){
	this.onendfunction = oef; this.onendfunctionparams = oefp;
	if(browser._browser == 'IE' && browser._platform == 'Mac' || browser._browser == 'Opera'){
		this.hide();
	}else{
		if(this.vis == 'visible'){
			if(this.processing == false){ this.cf = 0; this.sv = 100; this.ev = 0; }
			this.startease();
		}
	}
}
Independent_Fader.prototype.fadeToggle = function(){
	if(this.processing == false){
		if(this.vis == 'hidden'){ this.fadeIn();
		}else if(this.vis == 'visible'){ this.fadeOut();
		}else{ alert("ERROR");
		}
	}else{
		
	}
}
Independent_Fader.prototype.getAlpha = function(){ return this.MASTER_OPACITY; }
Independent_Fader.prototype.setAlpha = function(){
	var a = this.MASTER_OPACITY;
	if(document.all && browser._browser != 'Opera') {
		this.elmstyle.filter="alpha(opacity="+a+")";
		if(a < 2 && this.ev == 0){ this.elmstyle.visibility = 'hidden'; this.vis = 'hidden';
		}else{ this.elmstyle.visibility = 'visible'; this.vis = 'visible';
		}
	} else if(browser._browser == 'Opera'){
		
	} else {
		if(a < 98){ this.elmstyle.opacity = (a / 100);
		}else{ this.elmstyle.opacity = 0.99; 
		}
		if(a < 2 && this.ev == 0){ this.elmstyle.visibility = 'hidden'; this.vis = 'hidden';
		}else{ this.elmstyle.visibility = 'visible'; this.vis = 'visible';
		}
	}
}
Independent_Fader.prototype.ADDPROPERTY = function(value){
	if(value == undefined || value == '' && typeof(this.sv) == 'string'){
		if(this.MASTER_OPACITY == ""){
			var value = 100;
		}else{
			var value = this.MASTER_OPACITY;
		}
	}else{
		var value = value;
	}
	if(this.MASTER_OPACITY == ""){
		if(document.all && browser._browser != 'Opera'){
			if (this.elmstyle.filter.indexOf("alpha") == -1) {
				this.elmstyle.filter="alpha(opacity="+value+")";
				var r = value;
				this.MASTER_OPACITY = r;
				return r;
			}else{ var a = this.elmstyle.filter; var b = a.toString(); b = a.substring(14,a.length); var c = parseInt(b); var r = c; this.MASTER_OPACITY = r; return r;
			}
		} else if(browser._browser == 'Opera'){
			
		}else{
			if(this.elmstyle.opacity == ''){
				this.elmstyle.opacity = value / 100;
				var r = value / 100;
				this.MASTER_OPACITY = r;
				return r;
			}else{
				var r = this.elmstyle.opacity * 100;
				this.MASTER_OPACITY = r;
				return r;
			}
		}
	} else { var r = this.MASTER_OPACITY; return r;
	}
}
Independent_Fader.prototype.onFadeEnd = function(){
	if(this.onendfunction != undefined){ eval(this.onendfunction)(this.onendfunctionparams); this.onendfunction = ''; this.onendfunctionparams = ''; }
}
Independent_Fader.prototype.show = function(){ this.elmstyle.visibility = 'visible'; this.vis = 'visible'; }
Independent_Fader.prototype.hide = function(){ this.elmstyle.visibility = 'hidden'; this.vis = 'hidden'; }
Independent_Fader.prototype.toggleSwitch = function(){
	if(this.vis == 'hidden'){ this.show();
	}else if(this.vis == 'visible'){ this.hide();
	}else{ alert("ERROR"); 
	}
}







//-->


