VeryIDE.SlideBox=function(obj,box) {
	this.Obj = obj;
	this.Box = box;
	this.Mark = "";
	this.Alpha = 0;
	this.Speed = 10;
	this.zIndex = 999;
	this.iStyle = 0;
	this.iTop = 0;
	this.iLeft = 0;
	this.iClock = null;
	this.iDoc = [];
	this.iBox = [];
	this.iStop = false;

	var self=this;
	
	this.onShow = function(){
		
	}
	
	this.onHide = function(){
		
	}
	
	this.setMark = function(){
		if(this.Mark){
			if($(this.Mark)){
				delElement(this.Mark);
			}else{
				var doc=VeryIDE.getDocment();
				//bg
				var bg=document.createElement("DIV");
					bg.id=this.Mark;
					
					bg.style.zIndex=this.zIndex;
					bg.style.position="absolute";
					bg.style.height=(doc.scrollHeight>doc.offsetHeight?doc.scrollHeight:doc.offsetHeight)+"px";
					bg.style.width="100%";
					bg.style.top="0px";
					bg.style.left="0px";
				document.body.appendChild(bg);
			}
		}
	}
	
	this.setSize = function(flag){
		var doc=VeryIDE.getDocment();
		var obj=this.Obj;
		var box=this.Box;
		
		//self.iDoc=[doc.scrollWidth,(doc.scrollHeight>doc.offsetHeight?doc.scrollHeight:doc.offsetHeight),doc.scrollTop]
		self.iDoc=[doc.scrollWidth,doc.offsetHeight,doc.scrollTop]
		self.iBox=[box.offsetWidth,box.offsetHeight]
		
		var top=(self.iDoc[2])+((self.iDoc[1]-self.iBox[1])/2);
		//var top=self.iDoc[2]+((self.iBox[1]));
		if(top<0){
			top=0;
		}
		self.iTop=top;
		
		if(flag){
			box.style.position="absolute";
			box.style.left=-self.iBox[0]+"px";
			box.style.top=self.iTop+"px";
		}
		
		//alert(self.iDoc[0]+" | "+self.iDoc[1]+" | "+self.iDoc[2])
		
		//alert(doc.scrollTop+" "+((self.iDoc[1]-self.iBox[1])/2) )
	}
	
	this.Start = function(){
		this.setSize(true);
		
		addLoadEvent(function(){
			self.setSize(true);
		});

		this.Obj.onclick=function(){
			self.setSize();

			if(self.iStop){
				self.Stop();
			}else{
				self.Play();
			}
		}
	}
	
	this.Play = function(){
	
		if (this.iLeft >= ((this.iDoc[0]-this.iBox[0])/2) ) {
			self.setMark();
			window.clearTimeout(this.iClock);
			
			this.iClock = null;
			this.iStop = true;
			this.Alpha=100;
			
			this.onShow();
		}else{
			this.iLeft+=this.Speed;
			this.Alpha+=5;
			
			with(this.Box.style){
				left = this.iLeft+"px",
				zIndex = this.zIndex+1,
				filter = "alpha(opacity="+ parseInt(this.Alpha++) +")",
				mozOpacity = (this.Alpha/100),
				opacity = (this.Alpha/100)
			}
					
			this.iClock = setTimeout(function(){self.Play();},this.Speed);
		}
	}
	
	this.Stop = function(){
		if (this.iLeft >= (this.iDoc[0]-this.iBox[0]-20) ) {
			self.setMark();
			window.clearTimeout(this.iClock);
			
			this.iClock = null;
			this.iStop = false;
			this.iLeft=0;
			this.Alpha=0;
			
			with(this.Box.style){
				left = -this.iBox[0]+"px",
				top = this.iTop+"px",
				filter = "alpha(opacity=0)",
				mozOpacity = "0",
				opacity = "0"
			}
			
			self.setSize(true);
			this.onHide();
		}else{
			this.iLeft+=this.Speed;
			this.Alpha-=5;
			
			with(this.Box.style){
				left = this.iLeft+"px",
				filter = "alpha(opacity="+ parseInt(this.Alpha++) +")",
				mozOpacity = (this.Alpha/100),
				opacity = (this.Alpha/100)
			}
			
			this.iClock = setTimeout(function(){self.Stop();},this.Speed);
		}
	}

}


/*******************/

function outFlash(movie,vars){
	movie=movie.replace(/.swf/ig,"");
	if(movie){
		AC_FL_RunContent('obj','flash-preview','width','164','height','276','quality','high','movie',movie,'FlashVars',vars,'wmode','transparent');
		window.setTimeout(function(){
			resetFlash("","")
		},1000);
	}else{
		$("flash_size").style.display="none";
		$("flash_code").style.display="none";
	}
}

function resetFlash(width,height){
	var object=document.getElementsByTagName("OBJECT")[0];
	if(!width || !height){
		var flash=new getFlashSize(object);
		var width=flash.width;
		var height=flash.height;
		
		$("width").value=width;
		$("height").value=height;
		
		$("hideWidth").value=width;
		$("hideHeight").value=height;
	}
	
	object.style.width=width;
	object.style.height=height;
	
	$("flash_size").style.display="";
	$("flash_code").style.display="";
		$("html").value='<embed width="'+width+'" height="'+height+'" src="'+$('u').value+'" flashvars="" allowscriptaccess="sameDomain"></embed>';
		$("ubb").value='[flash='+width+','+height+']'+$('u').value+'[/flash]';
	//	$("url").value='http://www.i2up.com/lab/flash.asp?u='+encodeURIComponent($('u').value);
}

function getFlashSize(obj){
	if(!obj){
		return false;
	}
	
	try{
		this.width = obj.GetVariable("Stage.width");
		this.height = obj.GetVariable("Stage.height");
	}catch(e){
		this.width=100
		this.height=100
	}
}