function XML (xmlDoc){
	this.xmlDoc = xmlDoc;
	this.root = this.xmlDoc.getElementsByTagName("param")[0];
	this.object = this.read();
}

XML.prototype.get = function () {
	return this.object[0];
}

XML.prototype.read = function (parent){
	if(typeof(parent)=="undefined"){
		var parent = this.root;
	}
	var array = new Array();
	var childNodes = this.findChildNodes(parent);
	var n = 0;
	for(var i=0;i<childNodes.length;i++){
		var valueNode = childNodes[i];
		if(valueNode.tagName=="name") continue;
		var typeNode  = this.findFirstNode(valueNode);	//tagName =  struct|array|string|int|double
		switch(typeNode.tagName){
			case 'struct':
			var members = this.findChildNodes(typeNode);  //tagName  member;
			var object = new Object();
			for(var j=0;j<members.length;j++){
				var member = members[j];
				var nameNode = this.findFirstNode(member);
				var textNode = nameNode.firstChild;
				var back = this.read(member)[0];
				if(textNode==null) {
					continue;//
				}else{
					eval("object."+textNode.nodeValue+"=back;");
				}
			}
			array[n] = object;
			break;
			case 'array':
			var dataNode = this.findFirstNode(typeNode) ; //tagName = data;
			array[n] = this.read(dataNode);
			break;
			case 'string':
			case 'int':
			case 'double':
			var textNode = typeNode.firstChild;
			array[n] = textNode.nodeValue;
			break;
			default:
			return false;
			break;
		}
		n++;
	}
	return array;
}
XML.prototype.findFirstNode = function (root){
	var childNodes = root.childNodes;
	for(var i=0;i<childNodes.length;i++){
		if(typeof(childNodes[i].tagName)!="undefined"){
			return childNodes[i];
		}
	}
	return false;
}

XML.prototype.findChildNodes = function (root){
	if(navigator.appName.indexOf("Microsoft")>-1){
		var childNodes = root.childNodes
	}else{
		var children = root.childNodes;
		var childNodes = new Array();
		var j = 0;
		for(var i=0;i<children.length;i++){
			if(typeof(children[i].tagName)!="undefined"){
				childNodes[j++] = children[i];
			}
		}
	}
	return childNodes;
}
function Cookie (name){
	this.name = name;
}
Cookie.prototype.get = function(){
	var arr = document.cookie.match(new RegExp("(^| )"+this.name+"=([^;]*)(;|$)"));
	　　 if(arr != null) return unescape(arr[2]); return null;
}
Cookie.prototype.set = function(val,timeout){//timeout sencond
	if(typeof(timeout)!="undefined"){
		var expire = new Date();
		expire.setTime(expire.getTime() + timeout*1000);
		document.cookie = this.name + "=" + escape(val) + ";expire="+expire.toGMTString();
	}else{
		document.cookie = this.name + "="+ escape(val);
	}
}
Cookie.prototype.del = function () {
	/*	//var exp = new Date();
	　　// exp.setTime(exp.getTime() - 1);
	　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　// var cval=getCookie(name);
	　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　// if(cval!=null) document.cookie=name +"="+cval+";expire*="+**p.toGMTString();*/
}
//
//function Panel (id,url,row){
//	this.render = document.getElementById(id);
//	this.row = row;
//	this.url = url;
//	this.loadData();
//}
//
//Panel.prototype.initPanel = function (data){
//	var table = document.createElement("table");
//	this.render.appendChild(table);
//	var tbody = document.createElement("tbody");
//	table.appendChild(tbody);
//	var tr = document.createElement("tr");
//	tbody.appendChild(tr);
//	var td = document.createElement("td");
//	tr.appendChild(td);
//	td.colSpan = this.row-1;
//	td.innerHTML = data.pages;
//	var td = document.createElement("td");
//	tr.appendChild(td);
//	var img = document.createElement("img");
//	td.appendChild(img);
//	img.src = "images/refresh.jpg";
//	for(var i=0;i<data.rows.length;i++){
//		if(i%this.row==0){
//			var tr = document.createElement("tr");
//			tbody.appendChild(tr);
//		}
//		var one = data.rows[i];
//		var td = document.createElement("td");
//		tr.appendChild(td);
//		var a = document.createElement("a");
//		td.appendChild(a);
//		a.innerHTML = one.txt;
//		a.href = "javascript:;";
//		var A = new JS (a);
//		A.addEvent("click",function (o,id){
//			return function (){
//
//			}(a,one.id)
//		})
//	}
//}
//
//Panel.prototype.loadData = function (){
//	var panel = this;
//	var ajax = new Ajax(this.url,"get");
//	ajax.load(
//	function(){
//		panel.initPanel(ajax.data);
//	},
//	true,
//	function (){
//		panel.loading();
//	}
//	)
//}
//
//
//function CPanel (id,width,height,data){
//	this.width = width;
//	this.height = height;
//	this.content = document.createElement("div");
//	this.render = document.getElementById(id);
//	if(typeof(data)!="object"){
//		this.data = eval("("+data+")");
//	}else{
//		this.data = data;
//	}
//
//}



function Msg(type,msg,callback,callback_no){
	//type:alert,confirm
	if(top!=window){
		this.doc = top.document;
	}else{
		this.doc = document;
	}
	this.type = type;
	this.msg = msg;
	this.callback = callback;
	this.callback_no = callback_no;
	this.div = this.doc.createElement("div");
	this.bg =this.doc.createElement("div");
	this.table = this.doc.createElement("table");
	this.table.cellPadding = "0";
	this.table.cellSpacing = "0";

	this.tbody = this.doc.createElement("tbody");

	this.doc.body.appendChild(this.div);
	this.doc.body.appendChild(this.bg);
	this.doc.body.appendChild(this.table);


	this.table.appendChild(this.tbody);
	var w = this.doc.documentElement.clientWidth;
	var h =this.doc.documentElement.clientHeight;

	with(this.div.style){
		background = "#0044aa";
		position = "absolute";
		left = 0;
		top = 0;
		height = h +"px";
		width = w+"px";
		opacity = "0.2";
		filter = "alpha(opacity=20)";
		zIndex = 100;
	}
	this.init();
}
Msg.prototype.init = function(){

	var h = this.doc.body.clientHeight;
	var w = this.doc.body.clientWidth;

	var m_w = 200;
	var m_h = 80;

	with(this.table.style){
		background = "#F0FFF0";
		width = m_w+8+"px";
		height = m_h+4+"px";
		position = "absolute";
		top = parseInt((h-m_h)/2) + "px";
		left = parseInt((w-m_w)/2) + "px";
		zIndex = 102;
		border = "2px solid #83ABF1";
	}

	var tr = this.doc.createElement("tr");
	this.tbody.appendChild(tr);
	var td = this.doc.createElement("td");
	tr.appendChild(td);
	td.innerHTML = "提示";
	with(td.style){
		borderBottom = "1px solid #83ABF1";
		paddingLeft = "5px";
		fontWeight = "bold";
	}
	var td = this.doc.createElement("td");
	td.height = "20";

	tr.appendChild(td);
	var div = this.doc.createElement("div");
	td.appendChild(div);
	td.align = "right";
	with(td.style){
		float = "right";
		borderBottom = "1px solid #83ABF1";
		paddingRight = "3px";
	}
	div.className = "close_msg_icon";
	var msg = this;
	var oDiv = new JS (div);
	oDiv.addEvent("mouseover",function(){
		div.style.backgroundPosition = "-15px 0";
	});
	oDiv.addEvent("mouseout",function(){
		div.style.backgroundPosition = "0 0";
	});
	oDiv.addEvent("click",function(){msg.close()});
	var tr = this.doc.createElement("tr");
	var td = this.doc.createElement("td");
	td.colSpan = "2";
	with(td.style){
		textAlign = "center";
	}
	td.innerHTML = this.msg;
	this.tbody.appendChild(tr);
	tr.appendChild(td);
	var tr = this.doc.createElement("tr");
	var td = this.doc.createElement("td");
	this.tbody.appendChild(tr);
	tr.appendChild(td);
	td.colSpan = 2;
	with(td.style){
		textAlign = "center";
	}
	var oMsg = this;
	switch(this.type){
		case "alert":
		var input = this.doc.createElement("input");
		input.className = "button";
		input.type="button";
		input.value = "确定";
		td.appendChild(input);
		oInput = new JS (input);
		oInput.addEvent("click",function(){
			oMsg.close();
		});
		if(typeof(this.callback)!="undefined"){
			var callback = this.callback;
			oInput.addEvent("onclick",function(){
				callback();
			});
		}
		break;
		case "confirm":
		var input = this.doc.createElement("input");
		input.className = "button";
		input.type="button";
		input.value = "是";
		input.style.marginRight = "3px";
		td.appendChild(input);
		var oInput_yes = new JS (input);
		oInput_yes.addEvent("click",function(){
			oMsg.close();
		});
		if(typeof(this.callback)!="undefined"){
			var callback = this.callback;
			oInput_yes.addEvent("click",function(){
				callback();
			});
		}
		var input = this.doc.createElement("input");
		input.className = "button";
		input.type="button";
		input.value = "否";
		input.style.marginLeft = "3px";
		td.appendChild(input);
		var oInput_no = new JS (input);
		oInput_no.addEvent("click",function(){
			oMsg.close();
		});
		if(typeof(this.callback_no)!="undefined"){
			var callback_no = this.callback_no;
			oInput_no.addEvent("click",function(){
				callback_no();
			});
		}
		break;
	}
}

Msg.prototype.close = function(){
	this.doc.body.removeChild(this.div);
	this.doc.body.removeChild(this.bg);
	this.doc.body.removeChild(this.table);
}





//History
function History(){
	if(navigator.appName.indexOf("Microsoft")>-1){
		try{
			var oFrame = document.getElementById("History");
		}catch(e){
			var oFrame = document.createElement("iframe");
			oFrame.src = "index.html";
			oFrame.id = "History";
			document.body.appendChild(oFrame);
		}
		if(oFrame==null){
			var oFrame = document.createElement("iframe");
			oFrame.id = "History";
			oFrame.src = "index.html";
			document.body.appendChild(oFrame);
		}
		oFrame.style.display="none";
		oFrame.src = "index.html?timestamp="+new Date().getTime();
	}else{
		window.location.hash = new Date().getTime();
	}
}
//DD


//Tree Menu
function TreeMenu(id,data,url){
	this.render = document.getElementById(id);
	this.data = data;
	var tree = this;
	//this.root = document.createElement("div");
	this.root = document.createElement("div");
	this.root.className="Tree";
	this.cookie = new Cookie(id+"_TreeMenu");
	this.render.appendChild(this.root);
	if(data==null){
		var ajax = new Ajax(url,"post");
		ajax.onreadystatechange  = function (){
			if(ajax.readyState==4){
				if(ajax.status==200){
					tree.data = ajax.responseText;
					tree.initTree();
				}
			}
		}
	}else{
		this.initTree();
	}
}

TreeMenu.prototype.isOpen = function (title){
	var cookie = this.cookie.get();
	if(cookie==null||typeof(cookie)=="undefined"){
		return false;
	}else{
		var cookie_arr = cookie.split(",");
		for(var i=0;i<cookie_arr.length;i++){
			var c = cookie_arr[i];
			if(c==title){
				return true;
			}
		}
		return false;
	}

}

TreeMenu.prototype.initTree = function(root,data,deep,end,open){

	if(typeof(data)=="undefined"){
		var data = this.data;
	}
	if(typeof(data)=="string"){
		var data = eval("("+data+")");
	}
	if(typeof(deep)=="undefined"){
		var deep = 0;
	}
	if(typeof(end)=="undefined"){
		var end = false;
	}
	var ul = document.createElement("ul");
	if(typeof(root)=="undefined"){
		this.root.appendChild(ul);
	}else{
		with(ul.style){
			display = "none";
			overflow = "hidden";
		}
		root.appendChild(ul);
	}
	if(typeof(open)!="undefined"&&open){
		ul.style.display = "block";
	}

	for(var i=0;i<data.length;i++){
		if(data[i].show==false) continue;
		var li = document.createElement("li");
		with(li.style){
			height = "18px";
		}

		ul.appendChild(li);
		for(var j=0;j<deep;j++){
			var img = document.createElement("img");
			li.appendChild(img);
			if(end==true&&j==deep-1&&i==data.length-1){
				img.src = "images/tree-end.gif";
			}else{
				img.src = "images/elbow-line.gif"
			}
		}
		var div = document.createElement("div");
		var oDiv = new JS (div);
		var tree = this;

		li.appendChild(div);
		with(div.style){
			display="inline";
		}
		var img = document.createElement("img");
		div.appendChild(img);

		if(typeof(data[i].leavies)!="undefined"||typeof(data[i].child)!="undefined"){
			var child = data[i].leavies||data[i].child;
			var	isFolder = false;
			for(var x=0;x<child.length;x++){
				if(child[x].show!=false){
					isFolder = true;
					break;
				}
			}
			if(isFolder){
				var isOpen = this.isOpen(data[i].title);
				if(i==data.length-1){
					if(isOpen){
						img.src = "images/tree_open.gif";
					}else {
						img.src = "images/tree_close.gif";
					}
					//img.src = "images/tree-end-plus.gif";
				}else{
					if(isOpen){
						img.src = "images/tree_open.gif";
					}else {
						img.src = "images/tree_close.gif";
					}
				}
				var oImg = new JS(img);
				oImg.addEvent("click",function(o,title){return function(){tree.action(o,title)}}(div,data[i].title));
			}else {
				img.src = "images/leaf.gif";
				var isOpen = false;
				data[i].leavies = undefined;
				data[i].child = undefined;
			}

		}else{
			img.src = "images/leaf.gif";
			var isOpen = false;
		}
		var font = document.createElement("font");

		div.appendChild(font);
		font.innerHTML = data[i].title;
		if(typeof(data[i].url)!="undefined"){
			var oFont = new JS (font);
			oFont.addEvent("click",function(url){return function(){document.getElementById("admin_content").src=url}}(data[i].url))
		}

		if(typeof(data[i].leavies)!="undefined"){
			with(li.style){
				height = "";
			}
			deep++;
			if(i==data.length-1){
				end = true;
			}else{
				end = false;
			}
			this.initTree(li,data[i].leavies,deep,end,isOpen);
			deep--;
		}else if(typeof(data[i].child)!="undefined"){
			with(li.style){
				height = "";
			}
			//oDiv.addEvent("onclick",function(o){return function(){tree.action(o)}}(div));
			deep++;
			if(i==data.length-1){
				end = true;
			}else{
				end = false;
			}
			this.initTree(li,data[i].child,deep,end,isOpen);
			deep--;
		}

	}
}

TreeMenu.prototype.action = function (e,title){
	var u = e.nextSibling;
	var cookie = this.cookie.get();
	if(u.style.display=="block") {
		var c = new JS(e).getChildNodes();
		c[0].src = "images/tree_close.gif";
		if(cookie!=null&&typeof(cookie)!="undefined"){
			var arr = cookie.split(",");
			var m =0;
			var cookie_arr = new Array();
			for(var n=0;n<arr.length;n++){
				if(arr[n]!=title){
					cookie_arr[m++] = arr[n];
				}
			}
			cookie = cookie_arr.join(",");
			//	alert(cookie);
			this.cookie.set(cookie);
		}
		this.hide(u);
		return ;
	}else{
		var c = new JS(e).getChildNodes();
		c[0].src =  "images/tree_open.gif";
		if(cookie==null||typeof(cookie)=="undefined"||cookie==""){
			//			alert(title);
			this.cookie.set(title);
		}else{
			//	alert(cookie+","+title);
			this.cookie.set(cookie+","+title);
		}
		this.show(u);

	}

}
TreeMenu.prototype.show = function (e,i){
	var E = new JS (e);
	var child = E.getChildNodes();
	var m_h = child.length * 18;
	if(typeof(i)=="undefined"){
		var i = 1;
	}
	var h = parseInt(i*(m_h/5));
	with(e.style){
		display = "block";
		height = h + "px";
		overflow = "hidden";
	}
	if(i==5){
		e.style.height = m_h + "px";
		e.style.height = "";
		return true;
	}
	var tree = this;
	i++;
	setTimeout(function(){tree.show(e,i)},20);
}
TreeMenu.prototype.hide = function(e,i){
	var E = new JS (e);
	var child = E.getChildNodes();
	var m_h = child.length * 18 ;
	if(typeof(i)=="undefined"){
		var i = 5;
	}
	var h = parseInt(i*(m_h/5));
	with(e.style){
		height = h + "px";
		overflow = "hidden";
	}
	if(i==0){
		e.style.height = 0 +"px";
		e.style.display = "none";
		return true;
	}
	i--;
	var tree = this;
	setTimeout(function(){tree.hide(e,i)},20);


}


//Drop Menu

function createXHR(){
	var xmlHttp;
	try{
		xmlHttp = new XMLHttpRequest();
	}catch(e){
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return xmlHttp;
}

function Ajax(url,method,arg){
	this.xmlHttp = createXHR();
	var reg = /[Gg][Ee][Tt]/;
	if(reg.test(method)){
		this.method = "GET";
		this.arg = null;
	}else{
		this.method = "POST";
		this.arg = arg;
	}
	//url = BASEURL + url;
	if(this.method=="GET"){
		if(url.indexOf("?")>-1){
			url +="&request=ajax&timestamp="+new Date().getTime();
		}else{
			url +="?request=ajax&timestamp="+new Date().getTime();
		}
	}else{
		if(url.indexOf("?")>-1){
			url +="&request=ajax";
		}else{
			url +="?request=ajax";
		}
	}
	this.url = url;
	this.xmlHttp.open(this.method,this.url,true);
	if(this.method=="POST"){
		this.xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	}
	this.xmlHttp.send(this.arg);
}

Ajax.prototype.backState = function (){
	var xmlHttp = this.xmlHttp;
	this.xmlHttp.onreadystatechange = function () {
		if(xmlHttp.readyState==4){
			return xmlHttp.status;
		}
	}
}
Ajax.prototype.load = function(func,json,func2){
	var xmlHttp = this.xmlHttp;
	var ajax = this;
	this.xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState==4){
			if(xmlHttp.status==200){
				if(json==2){
					ajax.data = xmlHttp.responseXML;
				}else {
					if(typeof(json)!="undefined"&&json==true){
						ajax.data = eval("("+xmlHttp.responseText+")");
					}else{
						ajax.data = xmlHttp.responseText;
					}
				}
				func();
			}
		}else{
			if(typeof(func2)!="undefined"){
				func2();
			}
		}
	}
}



//
//function String(str){
//	this.string = str;
//	this.length = str.length;
//}
//String.prototype.toUpper = function (index,length){
//	var str = '';
//	if(typeof(length)=='undefined'){
//		var length = this.length-index;
//	}
//	for(var i=0;i<this.length;i++){
//		if(i==index||--length>0){
//			str +=this.string[i].toUpperCase();
//		}else{
//			str +=this.string[i];
//		}
//	}
//	return str;
//}
//

function JS (data) {
	if(typeof(data)=='undefined'){
		return this;
	}
	this.dom = this.get(data);
	return this;
}

JS.prototype.navigator = function (){
	var n = [];
	n[0] = navigator.appName;
	n[1] = navigator.appVersion;
	return n;
}

JS.prototype.loadOver = function(func){
	this.dom = window;
	this.addEvent('load',func);
}

JS.prototype.addEvent = function(name,func){
	var reg = /^(on)/;
	if(reg.test(name)){
		var ie_name = name;
		var ff_name = name.replace('on','');
	}else{
		var ie_name = 'on'+name;
		var ff_name = name;
	}
	if(window.addEventListener){
		this.dom.addEventListener(ff_name,eval(func),true);
	}else{
		this.dom.attachEvent(ie_name,eval(func));
	}
}

JS.prototype.reSet = function(){
	var oInputs = this.dom.getElementsByTagName("input");
	var oSelects = this.dom.getElementsByTagName("select");
	var oTextarea = this.dom.getElementsByTagName("textarea");
	for(var i=0;i<oInputs.length;i++){
		oInputs[i].value = "";
	}
	for(var j=0;j<oSelects.length;j++){
		oSelects[j].value = "";
	}
	for(var m=0;m<oTextarea.length;m++){
		oTestarea[m].value = "";
	}
	return true;
}


JS.prototype.getForms = function (tag) {
	if(typeof(tag)!="undefined"&&tag){
		var tag = true;
	}else{
		var tag = false;
	}
	//tag 表示 对于 checkbox 是否全部提交；
	var oInputs = this.dom.getElementsByTagName("input");
	var oSelects = this.dom.getElementsByTagName("select");
	var oTextarea = this.dom.getElementsByTagName("textarea");
	var data = '';
	for(var i=0;i<oInputs.length;i++){
		if(oInputs[i].type=="checkbox"){
			if(oInputs[i].checked==true){
				data +="&"+oInputs[i].name+"="+oInputs[i].value;
			}else{
				if(tag){
					data +="&"+oInputs[i].name+"=off";
				}
			}

		}else if(oInputs[i].type=="radio"){
			if(oInputs[i].checked==true){
				data +="&"+oInputs[i].name+"="+oInputs[i].value;
			}
		}else{
			data +="&"+oInputs[i].name+"="+oInputs[i].value;
		}
	}
	for(var j=0;j<oSelects.length;j++){
		data+="&"+oSelects[j].name+"="+oSelects[j].value;
	}
	//escape
	for(var m=0;m<oTextarea.length;m++){
		data +="&"+oTextarea[m].name+"="+escape(oTextarea[m].value);
	}
	return data;
}

JS.prototype.getFromsByIds = function (ids,start){
	var id_arr = ids.split("|");
	var arg = "";
	for(var i=0;i<id_arr.length;i++){
		var form = new JS(id_arr[i]);
		var dom = form.dom;
		switch(dom.tagName){
			case "INPUT":
			if(dom.type=="radio"||dom.type=="checkbox"){
				if(dom.checked==true){
					arg +="&"+dom.name+"="+dom.value;
				}
			}else{
				arg +="&"+dom.name+"="+dom.value;
			}
			break;
			case "SELECT" :
			arg+="&"+dom.name+"="+dom.value;
			break;
			case  "TEXTAREA":
			arg+="&"+dom.name+"="+escape(dom.value);
			break;
		}
	}
	if(typeof(start)!="undefined"&&start){
		return arg.replace("&","");
	}else{
		return arg;
	}
}


JS.prototype.getChildNodes = function(){
	if(navigator.appName.indexOf('Microsoft')>-1){
		return this.dom.childNodes;
	}else{
		var children = [];
		var j = 0;
		for(var i=0;i<this.dom.childNodes.length;i++){
			if(typeof(this.dom.childNodes[i].tagName)!='undefined'){
				children[j++] = this.dom.childNodes[i];
			}
		}
		return children;
	}
}
JS.prototype.Style = function(data){
	if(data.indexOf(";")){
		var style_arr = data.split(";");
	}else{
		var style_arr = [data];
	}
	for(var i=0;i<style_arr.length;i++){
		if(style_arr[i]=='') continue;
		var style_one_arr = style_arr[i].split(":");
		style_one_arr[0]=style_one_arr[0].toLowerCase();
		if(typeof(style_one_arr[1])=="undefined") continue;
		if(style_one_arr[0].indexOf("-")>-1){
			var name = style_one_arr[0];
			while(name.indexOf("-")>-1){
				var index = name.indexOf("-");
				name = name.replace("-","");
				var s = new String(name);
				name = s.toUpper(index,1);
			}
			style_one_arr[0] = name;
		}
		eval("this.dom.style."+style_one_arr[0]+"=style_one_arr[1]");
	}
	//*******************
}
JS.prototype.next = function(){
	//var n = this.dom.nextSibling;
	var n = this.dom.nextSibling;
	while(n!=null&&typeof(n.tagName)=="undefined"){
		n = n.nextSibling;
	}
	return n;
}
JS.prototype.previous = function (){
	var p = this.dom.previousSibling;
	while(typeof(p.tagName)=="undefined"){
		p = p.previousSibling;
	}
	return p;
}
JS.prototype.remove = function (){
	this.dom.parentNode.removeChild(this.dom);
}

function stopLink(obj){
	if(typeof(obj)=='undefined'){
		var Links = document.getElementsByTagName("a");
	}else if(typeof(obj)=='string'){
		var Links = document.getElementById(obj).getElementsByTagName("a");
	}else {
		var Links =obj.getElementsByTagName("a");
	}
	for(var i=0;i<Links.length;i++){
		Links[i].onclick = function(){return false;};
	}
}

function Windows(width,height,position,id){
	this.window = document.createElement("div");
	if(typeof(id)!="undefined"){
		var d = document.getElementById(id);
		if(d!=null){
			d.parentNode.removeChild(d);
		}
		this.window.id = id;
	}
	this.width = width;
	this.height = height;
	var dwidth = document.body.clientWidth;
	var dheight = document.body.clientHeight;
	this.body = document.createElement("div");
	this.header = document.createElement("div");
	with(this.header.style) {
		padding = "2px 0 2px 5px";
	}
	this.title = document.createElement("div");
	this.close = document.createElement("img");
	this.header.appendChild(this.title);
	with(this.title.style){
		display = "inline-block";
		float = "left";
		height = "25px";
		width = this.width-30 +"px";
	}
	with(this.close.style){
		display ="inline-block";
		float = "right";
		height = "14px";
		width = "14px";
		margin = "2px";
		fontFamily = "Arial";
		fontWeight = "bold";
		textAlign = "center";
		border = "1px #ffffff solid";
		verticalAlign = "middle";
		//	paddingBottom = "-5px"
	}
	var win = this;
	this.close.src="images/icon_close.gif";
	with(this.close.style){
		cursor = "pointer";
		width = "12px";
		height = "12px";
		border ="2px transparent";
	}
	//this.close.innerHTML = "X";
	var c = new JS(this.close);
	c.addEvent("click",function(){win.closeWin()});
	c.addEvent("onmouseover",function(){c.Style("border:1px solid #D2FEFF;")});
	c.addEvent("mouseout",function(){c.Style("border:1px solid #F0FFF0")});
	this.header.appendChild(this.close);

	new JS (this.window).Style("border:1px solid #B0E0E6;background:#F0FFF0;");
	new JS (this.header).Style("background:#F0FFF0;border-bottom:1px solid #B0E0E6;height:20px;font-weight:bold;color:#666666;padding-top:5px");
	new JS (this.body).Style("background:#F0FFF0");
	this.window.appendChild(this.header);
	this.window.appendChild(this.body);
	with(this.window.style){
		width = this.width + "px";
		height = this.height + "px";
	}
	if(position=="center"){
		with(this.window.style){
			left = parseInt((dwidth-this.width)/2) + "px";
			top = parseInt((dheight-this.height)/2) + "px";
			position = "absolute";
			border = "2px solid #B0E0E6";
		}
	}
	document.body.appendChild(this.window);
}
Windows.prototype.setTitle = function (title){
	this.title.innerHTML = title;
}
Windows.prototype.setBody = function (html,url,arg,func){
	if(html!=null){
		this.body.innerHTML = html;
		return true;
	}
	if(typeof(arg)!="undefined"){
		var ajax = new Ajax(url,"post",arg);
	}else{
		var ajax = new Ajax(url,"get");
	}
	var win = this;
	ajax.load( function (){
		win.body.innerHTML = ajax.data;
		if(typeof(func)!="undefined"){
			eval(func);
		}
	},false);
}

Windows.prototype.closeWin = function (i){
	if(typeof(i)=="undefined"){
		var  i = 5;
	}
	var f = i*20;
	var o = f/100;
	with(this.window.style){
		filter = "alpha(opacity="+f+")";
		opacity = o;
	}
	if(i==0){
		this.window.parentNode.removeChild(this.window);
		return true;
	}
	i--;
	var win = this;
	setTimeout(function(){win.closeWin(i)},100);

}

JS.prototype.Position = function(element){
	if(typeof(element)!="undefined"){
		e = element;
	}else{
		var e = this.dom;
	}
	var x = e.offsetLeft;
	var y = e.offsetTop;
	var p = e.offsetParent;
	if(p!=null){
		var position = this.Position(p);
		x += position[0];
		y += position[1];
	}
	var arr = [x,y];
	return arr;

}
JS.prototype.Create = function (tag){
	if(this.dom==null){
		return	document.createElement(tag);
	}else{
		var html_element = document.createElement(tag);
		this.dom.appendChild(html_element);
		return html_element;
	}
}
JS.prototype.html = function (html){
	if(typeof(html)=="undefined"){
		return this.dom.innerHTM;
	}
	if(this.dom.tagName=="SELECT"&&navigator.appName.indexOf("Microsoft")>-1){
		var select = this.dom;
		var outerhtml = select.outerHTML;
		var firstOptPot = outerhtml.indexOf("<OPTION");
		if(firstOptPot<0){
			firstOptPot = outerhtml.indexOf("</SELECT");
		}
		var tagStart = outerhtml.substring(0,firstOptPot);
		var replace_str = tagStart+html+"</select>";
		var parent = select.parentNode;
		var parentinnerHTML = parent.innerHTML;
		parent.innerHTML = parentinnerHTML.replace(outerhtml,replace_str);
	}else{
		this.dom.innerHTML = html;
	}
}
JS.prototype.get = function (data) {
	if (typeof(data)=='string') {
		var reg = /^#.*/;
		if(reg.test(data)){
			return document.getElementsByName(data.replace("#",""));
		}
		if(data.indexOf(' ')>-1){
			data = data.replace(/\s+/,' ');
        	var arr = data.split(' ');
        	if(arr[1].indexOf('<')>-1&&arr[1].indexOf('>')>-1){
        	  // var name = arr[1].replace(/^<.*>$/,)
        	  var name = arr[1].replace("<","").replace(">","");
        	  return document.getElementById(arr[0]).getElementsByTagName(name);
        	}else{
        	  return document.getElementById(arr[0]).getElementsByName(arr[1]);
        	}
        }else{
           return document.getElementById(data);
        }
   }else{
       if(typeof(data)=='object'){
          return data;
       }
   }
}

