// JavaScript Document
/* 

var caixiang = new creatSmallAD()
*/
function creatSmallAD(id,float,marginside,marginbottom,htmlcode){
	this.id = id;
	this.float = "left";
	this.marginside = 0;
	this.marginbottom = 0;
	this.htmlcode = "";
	function $id(p){return document.getElementById(p);}
	//判断浏览器是否为IE6
	var Sys = {};
	var ua = navigator.userAgent.toLowerCase();
	var s;
	(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
	(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
	(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
	(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
	(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
	this.creat = function(){
		var marginbottom = this.marginbottom;
		var marginside = this.marginside;
		var mydiv = document.createElement("div");
		//document.body.appendChild(mydiv);
		document.body.insertBefore(mydiv, document.body.childNodes[0]);//修改在IE6情况下"已终止操作"的问题
		mydiv.id = this.id;
		mydiv.innerHTML = this.htmlcode;
		var obj = $id(this.id);
		obj.style.width = "auto";
		if(this.float=="left"){obj.style.left = marginside + "px";}else{obj.style.right = marginside + "px";}
		if(Sys.ie=="6.0"){
			var cHeight = document.documentElement.clientHeight;
			obj.style.position = "absolute"
			if(this.float=="left"){obj.style.left = marginside + "px";}else{obj.style.right = marginside + "px";}
			obj.style.top = cHeight - marginbottom - obj.scrollHeight;
			setInterval(function(){obj.style.top = cHeight - marginbottom - obj.scrollHeight + document.documentElement.scrollTop + "px";},20);
		}else{
			obj.style.position = "fixed";
			obj.style.bottom = marginbottom + "px";
			if(this.float=="left"){obj.style.left = marginside + "px";}else{obj.style.right = marginside + "px";}
		}
	}
	this.hidden = function(){$id(this.id).style.display = "none"};
	this.remove = function(){
		var node = document.getElementById(this.id);
		if (node) {
		 node.parentNode.removeChild(node);
		}
	};
}
