﻿var intervalId = null; 
function slideAd(id,nStayTime,sState,nMaxHth,nMinHth){
//类构造器以下构造类slideAd的属性和方法

	this.stayTime = nStayTime * 6000 || 6000; //页面停留时间，单位毫秒
	this.maxHeigth = nMaxHth || 400; //最大高度属性
	this.minHeigth = nMinHth || 1; //最小高度属性
	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 + 30) : (h - 50)) + "px"; 
		if(obj.offsetHeight > this.maxHeigth){ //大于最大高度
			window.clearInterval(intervalId); //清除时间间隔
			intervalId = window.setInterval(closeBox,this.stayTime); //执行等待时间关闭窗口
		} 
		if (obj.offsetHeight < this.minHeigth){ //小于最小高度
			window.clearInterval(intervalId); 
			//window.alert("obj.offsetHeight:" + obj.offsetHeight + "\n" + "this.minHeigth" + this.minHeigth);
			obj.style.display = "none"; //隐藏对象
			//window.open('http://www.cnmis.cn/','popup','width=350,height=250,resizable=0,scrollbars=0'); 弹出窗口
		}
	}

	function closeBox(){ 
		slideAd(id,this.stayTime,"up",nMaxHth,'10'); 
	} 
	intervalId = window.setInterval(openBox,10); 
} 




    // 随机数

    rnd.today=new Date(); 

    rnd.seed=rnd.today.getTime(); 

    function rnd() { 

　　　　rnd.seed = (rnd.seed*9301+49297) % 233280; 

　　　　return rnd.seed/(233280.0); 

    }; 

    function rand(number) { 

　　　　return Math.ceil(rnd()*number); 

    };
