// JavaScript Document
function Opacity(id,opacity,speed){
	var obj=document.getElementById(id);
	var t1,t2,op;
	this.id=id;
	
	this.setOpacity=function(x){
		clearInterval(t1);
		clearInterval(t2);
		if (!(typeof obj.style.opacity=='string')) {
			 x *= 100;
    		 obj.style.filter='alpha(opacity='+x+')';
  			} else {// Другие браузеры
    		obj.style.opacity = x;}
		}
		
	this.setOpacity(opacity);
	
	this.getOpacity=function(){
		var op = (obj.style.opacity)?parseFloat(obj.style.opacity):parseInt(obj.style.filter.substr(14,3),10)/100;
		return op;
		}
		
	this.opDown=function(x2){
		clearInterval(t1);
		var op = this.getOpacity();
		//alert(op+' '+x2);
		t2=setInterval(function(){
							       
							 	   if (op>x2){
								   
								   //obj.style.opacity = op;    
								   op-=0.1;
								    if (obj.style.opacity){
								   obj.style.opacity = op;
								   } else obj.style.filter='alpha(opacity='+op*100+')'; 
								   
								   }else {clearInterval(t2);} 
							   },speed);
		}
	this.opUp=function(x1){
		clearInterval(t2);
		var op = this.getOpacity();
		//alert(op);
		t1=setInterval(function(){
							       if (op<x1){
								   //alert(op+' '+x);
								   //obj.style.opacity = op;   
								   op+=0.1;
								   if (obj.style.opacity){
								   obj.style.opacity = op;
								   } else obj.style.filter='alpha(opacity='+op*100+')'; 
								   
								   }else {clearInterval(t1);} 
							   },speed);
		}
}
