function Ad(){
	this.xPos = 300;
	this.yPos = 200; 
	this.step = 1;
	this.delay = 30; 
	this.height = 0;
	this.Hoffset = 0;
	this.Woffset = 0;
	this.yon = 0;
	this.xon = 0;
	this.pause = true;
	this.interval;
	this.ads;

	this.SetPos = function(ad_id,Pos,x,y){
		this.ads = document.getElementById(ad_id);
		this.xon = x;
		this.yon = y;
		switch(Pos){
			case "左上":	{
							document.getElementById(ad_id).style.top = "200px";
							document.getElementById(ad_id).style.left = "300px";
							this.xPos = 300;
							this.yPos = 200;
							} break;
			case "右上":	{
							document.getElementById(ad_id).style.top = "200px";
							document.getElementById(ad_id).style.left = "700px";
							this.xPos = 700;
							this.yPos = 200;
							} break;
			case "左下":	{
							document.getElementById(ad_id).style.top = "500px";
							document.getElementById(ad_id).style.left = "300px";
							this.xPos = 300;
							this.yPos = 500;
							} break;
			case "右下":	{
							document.getElementById(ad_id).style.top = "500px";
							document.getElementById(ad_id).style.left = "700px";
							this.xPos = 700;
							this.yPos = 500;
							} break;
			default:{
							document.getElementById(ad_id).style.top = "200px";
							document.getElementById(ad_id).style.left = "300px";
							this.xPos = 300;
							this.yPos = 200;
						} 
		}
	}

	this.changePos = function() {
		this.width = document.body.clientWidth;
		this.height = document.body.clientHeight;
		this.Hoffset = this.ads.offsetHeight;
		this.Woffset = this.ads.offsetWidth;
		this.ads.style.left = this.xPos + document.body.scrollLeft;
		this.ads.style.top = this.yPos + document.body.scrollTop;
		if (this.yon) 
			{this.yPos = this.yPos + this.step;}
		else 
			{this.yPos = this.yPos - this.step;}
		if (this.yPos < 0) 
			{this.yon = 1;this.yPos = 0;}
		if (this.yPos >= (this.height - this.Hoffset)) 
			{this.yon = 0;this.yPos = (this.height - this.Hoffset);}
		if (this.xon) 
			{this.xPos = this.xPos + this.step;}
		else 
			{this.xPos = this.xPos - this.step;}
		if (this.xPos < 0) 
			{this.xon = 1;this.xPos = 0;}
		if (this.xPos >= (this.width - this.Woffset)) {
			this.xon = 0;
			this.xPos = (this.width - this.Woffset);   
		}
	}

	this.Start = function(id){
		this.ads.visibility = "visible";
		this.interval = setInterval("ads"+id+".changePos()", this.delay);
	}
}
