﻿var intervalId = null; 
function slideAd(id,nStayTime,sState,nMaxHth,nMinHth)
{ 
	this.stayTime=nStayTime*1000 || 3000; 
	this.maxHeight=nMaxHth || 330; 
	this.minHeight=nMinHth || 0; 
	this.state=sState || "down" ; 
	var obj = document.getElementById(id); 
	if(intervalId != null)window.clearInterval(intervalId); 
	function openBox()
	{ 
		var h = obj.offsetHeight; 
		//obj.style.height = ((this.state == "down") ? (h + 10) : (h - 10))+"px";
		if(this.state == "down")
		{
		    obj.style.height = (((h + 10) > nMaxHth) ? nMaxHth : (h + 10)) + "px"; 
		}
		else
		{
		    obj.style.height = (((h - 10) < 0 ) ? 0 : (h - 10)) + "px"; 
		}
		
		if(obj.offsetHeight>=this.maxHeight)
		{ 
			window.clearInterval(intervalId); 
			intervalId=window.setInterval(closeBox,this.stayTime); 
		} 
		if (obj.offsetHeight<=this.minHeight)
		{ 
			window.clearInterval(intervalId); 
			obj.style.display="none"; 
		} 
	} 
	function closeBox()
	{ 
		slideAd(id,this.stayTime,"up",nMaxHth,nMinHth); 
	} 
	intervalId = window.setInterval(openBox,8); 
}

