var imgAdverClass = {
	/*增加图片类 @2009-11-24 lh*/
	num : 2,
	prefix : 'imglist_',
	wrapid : 'imglist',
	$ : function(id){
		return document.getElementById(id);
	},
	add : function(){
		var list = this.$(this.wrapid).getElementsByTagName("tbody");
		var total = list.length -2;/*元素的调整*/
		var next = total+1;
		
		var current = this.$(this.prefix+total);
		var parent = current.parentNode;
		var tbody = document.createElement("tbody");
		tbody.id = this.prefix+next;
		parent.insertBefore(tbody,current.nextSibling);
		this.template(next);
	},

	remove : function(num){
		var obj = this.$(this.prefix+num);
		var parent = obj.parentNode;
		parent.removeChild(obj);
	},

	template : function(next){
		/*template*/ 
		var tr1 = this.createTR();
		var td1 = this.createTD('图片地址 * <span class="gray">( 外链以http://开头 )</span>');
		var td2 = this.createTD('<input type="text" class="input input_wb" name="config[url]['+next+']" value=""> <a href="javascript:;">[移除]</a>');
		td1.className="td1";
		td2.className="td2";
		tr1.appendChild(td1);
		tr1.appendChild(td2);
		
		var a = tr1.getElementsByTagName("a")[0];/*绑定移除事件*/
		var _this = this;
		a.onclick = function(){
			_this.remove(next);
		}
		var tr2 = this.createTR();
		var td3 = this.createTD('图片链接 * <span class="gray">( 外链以http://开头 )</span>');
		var td4 = this.createTD('<input type="text" class="input input_wb" name="config[link]['+next+']" value="http://">');
		td3.className="td1";
		td4.className="td2";
		tr2.appendChild(td3);
		tr2.appendChild(td4);
		
		var nextId = this.prefix+next;
		this.$(nextId).appendChild(tr1);
		this.$(nextId).appendChild(tr2);
	},

	createTR : function(){
		var tr = document.createElement("tr");
		tr.className="tr1 vt";
		return tr;
	},
	
	createTD : function(html){
		var td = document.createElement("td");
		td.innerHTML = html;
		return td;
	}
}
		
var adverDuring = {
	/*广告排期@2009-11-25 lh*/
	prefix : 'wrappop',
	
	$ : function (id){
		return document.getElementById(id);
	},

	IE : function(){
		return ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	},
	
	bind : function(){
		var list = this.$("list").getElementsByTagName('div');
		this.remove();
		var _this = this;
		for(i=0;i<list.length;i++){
			list[i].onmouseover = function(e){
				var e = e || event;
				_this.tips(e,this);
			}
			list[i].onmouseout = function(){
				//_this.remove(this);
			}
		}
		obj = list[0] || list[1];
		obj.onmouseover();
	},

	tips : function(event,obj){
		//var left = event.offsetX;
		//var top  = event.offsetY;
		var info = obj.getAttribute("info");
		var id   = obj.getAttribute("id");
		var url   = obj.getAttribute("url");
		var pos = this.getpos(obj);
		var top  = pos[1]+20+"px";
		var left = pos[0]+"px";

		var wrap = this.$(this.prefix);
		if(!wrap){
			var wrap = document.createElement("div");
			wrap.className = "admin_pop";
			wrap.id = this.prefix;
			wrap.style.display  = "none";
			wrap.style.zIndex   = 100;
			wrap.style.position = "absolute";
		}
		wrap.style.top      = top;
		wrap.style.left     = left;
		
		var html = info;/*html elements*/
		url = url ? url : '#';
		html += '<br><a href="'+url+'" >添加广告</a>';
		wrap.innerHTML = html;
		
		var _this = this;
		wrap.onmouseout = function(){
			//_this.remove();
		}
		wrap.onmouseover = function(){
			//
		}
		document.body.appendChild(wrap);
		wrap.style.display = "";
	},

	getpos : function(d) {
		var e = [ 0, 0 ];
		var el = d;
		while (el) {
			if (el == document.body)
				break;
			e[0] = e[0] + el.offsetLeft;
			e[1] = e[1] + el.offsetTop;
			el = el.offsetParent;
		}
		return e;
	},

	remove : function(){
		var pop = this.$(this.prefix);
		pop ? document.body.removeChild(pop) : 0;
	},
	
	bindBench : function(){
		var bench = this.$("adverBench");
		bench.onchange = function(){
			document.during.submit();/*submit*/
		}
	},
	bindTime : function(){
		var time = this.$("advertime");
		time.onchange = function(){
			document.during.submit();/*submit*/
		}
	}
}