// 常用函数库
//window.onerror=function(){return true};
// 字符串对象方法之检查是否存在指定字符串
String.prototype.check = function(str) {
	return this.indexOf(str)>-1?true:false
}
// 字符串对象方法之返回指定长度的字符串
String.prototype.leftB = function(len) {
	var s = this.replace(/\*/g," ").replace(/[^\x00-\xff]/g,"**");
	return this.slice(0,s.slice(0,len).replace(/\*\*/g," ").replace(/\*/g,"").length)
}
// 数组对象方法之添加
Array.prototype.add = function(key) {
	this[this.length] = key;
}
// getElementById简写方式
function $(obj) {
	return document.getElementById(obj);
}
// 删除指定元素节点
function oDel(obj) {
	if (obj!=null) {
		obj.parentNode.removeChild(obj);
	}
}
// 获取指定元素节点的文本节点
function oTxt(obj) {
	try {
		return obj.firstChild.nodeValue;
	} catch(e){
		return ""
	}
}
// 获取指定元素节点的指定属性节点
function oKey(obj,key) {
	var o=obj.getAttribute(key);
	return o==null?"":o;
}
// 事件绑定及解除
function addEvent(obj, evt, fn) {
	if (obj.addEventListener) {
		obj.addEventListener(evt,fn,false);
	} else if (obj.attachEvent) {
		obj["e"+evt+fn] = fn;
		obj[evt+fn] = function () {
			obj["e"+evt+fn](window.event);
		};
		obj.attachEvent("on"+evt,obj[evt+fn]);
	}
}
function removeEvent(obj, evt, fn) {
	if (obj.removeEventListener) {
		obj.removeEventListener(evt,fn,false);
	} else if (obj.detachEvent) {
		obj.detachEvent("on"+evt,obj[evt+fn]);
		obj[evt+fn] = null;
		obj["e"+evt+fn] = null;
	}
}
// 设置非IE浏览器使用srcElement来获得事件目标对象、x、y来获得相对窗口的坐标
if(!document.all){
	Event.prototype.__defineGetter__("srcElement",function(){var node=this.target;while(node.nodeType!=1){node=node.parentNode}return node})
	Event.prototype.__defineGetter__("x",function(){return this.clientX})
	Event.prototype.__defineGetter__("y",function(){return this.clientY})
}
// 读取元素坐标及尺寸
function objxy(e) {
	var t=e.offsetTop;
	var l=e.offsetLeft;
	var w=e.offsetWidth;
	var h=e.offsetHeight;
	while (e=e.offsetParent) {
		t+=e.offsetTop;
		l+=e.offsetLeft;
	}
	var a=new Array(t,l,w,h);
	return a;
}
// 屏幕尺寸
var windowWidth=window.screen.width||0, windowHeight=window.screen.height||0;
addEvent(window,"load",function(){
	windowWidth = document.documentElement.clientWidth || document.body.clientWidth;
	windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
});

// 滚动条高度
function scrolltop() {
	if (window.pageYOffset) {
		return window.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {
		return document.documentElement.scrollTop;
	} else if (document.body) {
		return document.body.scrollTop;
	}
	return null;
}
// 创建css
function insCss(css) {
	if (document.all) {
		var oStyle=document.styleSheets[document.styleSheets.length-1];
		var a=css.split("\n");
		for (var i=0; i<a.length; i++) {
			if (a[i]=="") {
				continue;
			}
			var ad=a[i].replace(/([\s\S]*)\{([\s\S]*)\}/,"$1|$2").split("|");
			var classNames=ad[0].split(",");
			for (var j=0; j<classNames.length; j++) {
				oStyle.addRule(classNames[j],ad[1]);
			}
		}
	} else {
		var style=document.createElement("style");
		style.type="text/css";
		style.innerHTML=css;
		document.getElementsByTagName("HEAD").item(0).appendChild(style);
	}
}
// Ajax快捷操作函数
/*
function SetAjax(url,parameter,echo) {
	//提交类型
	var put="get";
	if (parameter.slice(0,5)=="post:") {
		parameter=parameter.slice(5);
		put="post";
	}
	var req=null;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		var msxml=new Array('MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP');
		for (var i=0; i<msxml.length; i++) {
			try {
				req=new ActiveXObject(msxml[i]);
				break;
			} catch (e) {
			}
		}
	}
	if (put=="get") {
		if (parameter!="") {
			if (url.check("?")) {
				url+="&"+parameter;
			} else {
				url+="?"+parameter;
			}
		}
		parameter=null;
	}
	var t=new Date();
	if (url.check("?")) {
		url+="&"+t.getTime();
	} else {
		url+="?"+t.getTime();
	}
	req.open(put,url, true);
	req.onreadystatechange = function() {
		if (req.readyState==4&&req.status==200) {
			//alert(req.responseText)
			echo(req.responseXML,req.responseText);
			try {
				put=null;
				msxml=null;
				req=null;
				CollectGarbage();
			} catch (e) {
			}
		}
	}
	req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	req.send(parameter);
	//if (document.all)
	//window.attachEvent('onbeforeunload',function(){try{req.abort()}catch(e){}})
}
 */
function SetAjax(url,parameter,echo){
	var put="get"	//提交类型
	if(parameter.slice(0,5)=="post:"){
		parameter=parameter.slice(5)
		put="post"
	}
	var req = null;
	if(window.XMLHttpRequest){
		req = new XMLHttpRequest();
	}else if(window.ActiveXObject){
		var msxml = new Array('MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP');
		for(var i=0;i<msxml.length;i++){
			try{
				req = new ActiveXObject(msxml[i]);
			    break;
			}catch(e){}
		}
	}
	if(put=="get"){
		if(parameter!="")
			if(url.check("?"))
				url+="&"+parameter
			else
				url+="?"+parameter
			//url+="&"+parameter
		parameter=null
	}
		var t=new Date()
		if(url.check("?"))
			url+="&"+t.getTime()
		else
			url+="?"+t.getTime()
	req.open(put,url, true);
	req.onreadystatechange = function(){
		if(req.readyState==4 && req.status==200){
		//	alert(req.responseText)
			echo(req.responseXML,req.responseText)
try{
			put=null
			msxml=null
			req=null;
			CollectGarbage();
}catch(e){}

		}
	}
	req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	req.send(parameter);
//	if (document.all)
//		window.attachEvent('onbeforeunload',function(){try{req.abort()}catch(e){}})
}


// 选择匹配 XPath 表达式的节点集合
function SelectNodes(Xml,xpath) {
	if (! xpath.check("/")) {
		return Xml.getElementsByTagName(xpath);
	}
	if (document.all) {
		return Xml.selectNodes(xpath);
	} else {
		var aNodeArray = new Array();
		var xPathResult=Xml.evaluate(xpath,Xml,Xml.createNSResolver(Xml.documentElement),XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);
		if (xPathResult) {
			var oNode=xPathResult.iterateNext();
			while (oNode) {
				aNodeArray[aNodeArray.length]=oNode;
				oNode=xPathResult.iterateNext();
			}
		}
		return aNodeArray;
	}
}
function xva(Xml,xpath){return SelectNodes(Xml,xpath)}
function xv(Xml,xpath,n){try{return oTxt(xva(Xml,xpath)[n==null?0:n])}catch(e){return ""}}



/////////////////////////////////////////////////////////////////////
var zindex=1000		/////全局浮动层顺序
function _$w(isShield){//isShield 是否显示弹出框底层颜色
	////////底部屏蔽层
	var shield=document.createElement("div")		////创建底部屏蔽层
	shield.className="shield"
	zindex++
	shield.style.zIndex=zindex
	
	if(isShield==true)
		shield.style.cssText="position:absolute;filter:alpha(opacity=30);-moz-opacity:0.3;opacity:0.3;background:#000;";
	
	if(windowHeight>document.documentElement.scrollHeight)
		shield.style.height=windowHeight+"px";
	else
		shield.style.height=document.documentElement.scrollHeight+"px";
		
	//////////////底部屏蔽层end
	var box,fm,close_w
	//////////层遮罩
	var wframe=document.createElement("iframe")
	//if(isShield==true)
	//	wframe.style.cssText="position:absolute;filter:alpha(opacity=30);-moz-opacity:0.3;opacity:0.3;background:#000;";
	//else
		wframe.style.cssText="position:absolute;filter:alpha(opacity=0);-moz-opacity:0;opacity:0;";
	
	
	zindex++
	wframe.style.zIndex=zindex

	box=document.createElement("span")
	box.className="msg"
	zindex++
	box.style.zIndex=zindex
	fm=document.createElement("FORM");
	fm.style.cssText="z-index:2;position:absolute;left:0;top:0;margin:5px;width:100%;border:1px solid #666;";
	this.form=fm;
	box.appendChild(fm);
	blueBackground=document.createElement("div");
	blueBackground.id="blueBackground";
	blueBackground.style.cssText="position:absolute;filter:alpha(opacity=30);-moz-opacity:0.3;opacity:0.3;z-index:1;background:#666;top:0;left:0;";
	box.appendChild(blueBackground);
	////头部
	var top=document.createElement("div")	///头部
	if(isShield==true)
		top.className="top1"
	else
		top.className="top"	
	var tl=document.createElement("div")		////头部左侧
	tl.className="tl"
	top.appendChild(tl)
	var title_dom=document.createElement("div")	////标题
	title_dom.className="title"
	top.appendChild(title_dom)
	fm.appendChild(top)

	///拖拽操作
	var dragxy={}		//拖拽信息
	var adang=0;
	var drag=function(e){
		e=e||event
		wframe.style.left=box.style.left=(e.x-dragxy.left)+"px"
		wframe.style.top=box.style.top=(e.y-dragxy.top)+"px"
	}
	top.onmousedown=function(e){
		e=e||event;
		var ee=e.srcElement
		dragxy.left=e.x-parseInt(box.style.left.replace("px",""))
		dragxy.top=e.y-parseInt(box.style.top.replace("px",""))
		addEvent(document.body,"mousemove",drag)
	}
	top.onmouseup=function(e){removeEvent(document.body,"mousemove",drag)}

	////头部结束
	/////内容
	var content=document.createElement("div")		///中间内容
	content.className="content"
	var br=document.createElement("div")
	br.className="br"
	content.appendChild(br)

	var info=document.createElement("div")			///显示内容
	info.className="info"

	br.appendChild(info)

	var bt_box=document.createElement("div")		////按钮容器
	if(isShield!=true)
		bt_box.className="bt"

	br.appendChild(bt_box)

	fm.appendChild(content)
	////内容end

	///*关闭窗口
	this.close_w=close_w=document.createElement("input")
	close_w.type="button"
	if(isShield==true)
		close_w.className="close1"
	else
		close_w.className="close"	
	fm.appendChild(close_w)
	///关闭窗口end

	////////事件

	this.title=function(titles){				////添加标题
		if(titles==null||titles=="")
			titles="系统消息"
		title_dom.innerHTML=titles
	}

	this.content=function(str){		
		//info.innerHTML=str	// 原始语句修改如下 by longerface
		// 如果显示内容有form表单则转外层表单改为div
		if(/<form/ig.test(str)){			
			var div=document.createElement("DIV");
			while(fm.childNodes.length>0){
				div.appendChild(fm.firstChild);
			}
			div.style.cssText=fm.style.cssText;
			fm.parentNode.replaceChild(div, fm);
			fm=div;
		}
		
		// 如果显示内容中有脚本则运行脚本 用于ajax返回内容
		var ua = navigator.userAgent.toLowerCase();
		if (ua.indexOf('msie') >= 0 && ua.indexOf('opera') < 0) {			
			str = '<div style="display:none">for IE</div>' + str;
			str = str.replace(/<script([^>]*)>/gi,'<script$1 defer>');			
			info.innerHTML = '';			
			info.innerHTML = str;			
			info.removeChild(info.firstChild);
		} else if(ua.indexOf('safari') >= 0 || ua.indexOf('chrome') >= 0){
			var aCode= [];
			while(/<script(.|\r|\n)*?<\/script>/gi.test(str)){
				js = /<script(.|\r|\n)*?<\/script>/gi.exec(str)[0];
				str = str.replace(js,'');
				aCode.push(js.substr(/<script.*?>/i.exec(js)[0].length, js.toLowerCase().indexOf('<\/script>')-/<script.*?>/i.exec(js)[0].length));
			}
			info.innerHTML = '';info.innerHTML = str;
			for(var i=0;i<aCode.length;i++){
				eval(aCode[i]);
			}
		}else {			
			var el_next = info.nextSibling;
			var el_parent = info.parentNode;
			el_parent.removeChild(info);
			info.innerHTML = str;
			if (el_next) {
				el_parent.insertBefore(info, el_next)
			} else {
				el_parent.appendChild(info);
			}
		}
		
	}
	this.width=function(w){
		wframe.style.width=fm.style.width=w+"px"
		wframe.style.width=parseInt(wframe.style.width)+20+"px";
	}
	this.height=function(h){
		if(h==null){
			wframe.style.height=fm.offsetHeight+20+"px"
		}else{
			wframe.style.height=h+"px"
		}
	}

	this.add_bt=function(obj){					/////添加按钮
		var onbutton=document.createElement("button")
		onbutton.innerHTML=obj.value
		onbutton.className="sendBtn2";
		if(onbutton.innerHTML=="取消") onbutton.className="cancelBtn";;
		onbutton.setAttribute("type",obj.type)
		bt_box.appendChild(onbutton)

		onbutton.onclick=function(){
			if(obj.echo!=null){
				if(typeof(obj.echo)=="function"){
					var onecho=obj.echo()
					if(onecho==false)
						return
				}else{
					eval(obj.echo)
				}
			}
			oDel(box)
			oDel(shield)
			oDel(wframe)
			try{
				shield=box=fm=close_w=top=tl=title=dragxy=drag=content=br=info=fm=botm=bm_l=bm_r=close_w=null;
				CollectGarbage();
			}catch(e){}
		}
	}
	this.show=function(){						//显示窗口
		document.body.appendChild(box)
		document.body.appendChild(wframe)
		document.body.appendChild(shield)
		blueBackground.style.width=fm.offsetWidth+10+"px";
		blueBackground.style.height=fm.offsetHeight+10+"px";
		wframe.style.top=box.style.top=(scrolltop()+(windowHeight-fm.offsetHeight-10)/2)+"px"
		wframe.style.left=box.style.left=(windowWidth-fm.offsetWidth-10)/2+"px"
		close_w.focus()
	}
	top.onselectstart=function(){return false}	////屏蔽选择文字
	this.closew=function(){
		oDel(box)
		oDel(shield)
		oDel(wframe)
		try{
			wframe=shield=box=fm=close_w=top=tl=title=dragxy=drag=content=br=info=fm=botm=bm_l=bm_r=close_w=null;
			CollectGarbage();
		}catch(e){}
	}
	close_w.onclick=function(){					//////关闭按钮
		oDel(box)
		oDel(shield)
		oDel(wframe)
		try{
			wframe=shield=box=fm=close_w=top=tl=title=dragxy=drag=content=br=info=fm=botm=bm_l=bm_r=close_w=null;
			CollectGarbage();
		}catch(e){}
	}
}
function getback(url){
	var style = document.createElement("style");
	style.type = "text/css";
	style.href = url
	document.getElementsByTagName("HEAD").item(0).appendChild(style);
}

/////////////消息对话框
function msg(nr,echo,title){
	nr="<div style='height:60px;text-align:center;line-height:60px'>"+nr+"</div>"
	var w=new _$w()
	w.content(nr)
	w.title(title)
	w.width(300)
	w.add_bt({"value":"确定","type":"button","echo":echo})
	if(echo!=null)
		w.add_bt({"value":"取消","type":"button"})
	w.show()
	w.height(null)
}
///////////不用对话框提示消息而将提示写入网页位置 
function innerMsg(id,nr,echo,title){
	if(typeof id=='object'){
		if(!id.nodeType) return msg(nr,echo,title);
	}else
		id = document.getElementById(id);
	if(!id) return msg(nr,echo,title);
	nr = "<span class='success'>"+nr+"</span>";
	id.innerHTML = nr;
	id.style.display = 'block';
}
/////////////提示消息框
function alertMsg(nr,echo,title, lineheight){
	lineheight = lineheight?lineheight:60;
	nr="<div style='height:60px;text-align:center;line-height:"+lineheight+"px'>"+nr+"</div>"
	var w=new _$w()
	w.content(nr)
	w.title(title)
	w.width(240)
	w.add_bt({"value":"确定","type":"button","echo":echo})
	w.show()
	w.height(null)
}
/////////////消息对话框(内容较多)
function moreMsg(nr,echo,title){
	nr="<div style='height:250px;text-align:center;line-height:30px'>"+nr+"</div>"
	var w=new _$w()
	w.content(nr)
	w.title(title)
	w.width(400)
	w.add_bt({"value":"确定","type":"button","echo":echo})
	if(echo!=null)
		w.add_bt({"value":"取消","type":"button"})
	w.show()
	w.height(300)
}
/////////////////////////工具
var tpl=[]

function tools(key,echos){
	if(tpl[key]==null){
		tpl[key]={}
		if(echos!=null)
			tpl[key].echos=echos
		var url="../space/xml/"+key+".xml"
		SetAjax(url,"",backtools)
	}else{
		tpl[key].echos=echos
		settool(key)
	}
	//
}
function backtools(xml){
	var key=oKey(xva(xml,"/root/xhtml")[0],"tpl")
	tpl[key].html=xv(xml,"/root/xhtml")
	eval(xv(xml,"/root/xjs"))
	eval("tpl['"+key+"']").obj=eval("new "+key+"()")
	settool(key)
}
function settool(key){
	tpl[key].obj.onload()
}




//////////////////////////////////
var onselectcolor=null
function selectcolor(obj){
	if(obj==onselectcolor)
		return
	onselectcolor=obj
///	a[0]=t;a[1]=l;a[2]=w;a[3]=h
	var xy=objxy(obj)
	var top=xy[0]+xy[3]
	var l="<table border='0' cellspacing='5' cellpadding='0' align='center' style='position:absolute;top:0;left:0;z-index:2'>\
			<tr> \
			  <td colspan='3' style='background:"+obj.style.background+";border:1px solid #000000;height:20px;width:60px'>&nbsp;</td>\
			  <td colspan='5'>选择色彩</td>\
			</tr>"
			var c="000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF".split(",")
			for(var i=0;i<5;i++){
				l+="<tr>"
					for(var j=0;j<8;j++){
						l+="<td style='width:13px;cursor:pointer;height:15px;border:1px solid #000;font-size:2px;background:#"+c[j+i*8]+"'>&nbsp;</td>"
					}
				l+="</tr>"
			}
	l+="</table>"
	zindex++
	var bg=document.createElement("iframe")
	bg.style.cssText="background:#FFF;wdith:180px;height:140px;position:absolute;top:0;left:0;filter:alpha(opacity=0);-moz-opacity:0;z-index:1"
	var box=document.createElement("div")
	zindex++
	box.style.cssText="width:180px;height:140px;background:#FFF;border:1px solid #CCC;position:absolute;overflow:hidden;top:"+top+"px;left:"+xy[1]+"px;z-index:"+zindex
	box.innerHTML=l
	box.appendChild(bg)
	document.body.appendChild(box)
	var onbox=function(e){
		e=e||event;
		var ee=e.srcElement
		if(ee==obj)
			return
			if(ee.tagName=="TD"){
				if(ee.parentNode.parentNode.parentNode.parentNode==box){
					obj.style.background=ee.style.backgroundColor
					css[obj.id]=ee.style.backgroundColor
					insCss(obj.getAttribute("inscss").replace(/#key#/gi,ee.style.backgroundColor))
					oDel(box)
					removeEvent(document.body,"mousedown",onbox)
					onselectcolor=null
					return
				}
			}
		while(ee){
			if(ee==box)
				return
			if(ee.tagName=="HTML"){
				oDel(box)
				removeEvent(document.body,"mousedown",onbox)
				onselectcolor=null
				return
			}
			ee=ee.parentNode
		}

	}
	addEvent(document.body,"mousedown",onbox)
}

// 新添加函数

// 返回值给as调用歌曲
function returnUserId(){
	return curOwnerId + "&time=" + (new Date().getTime());
}
// 返回选择项值
function setOption(obj, value) {
	try {
		for (var i=0; i<obj.options.length; i++) {
			if (obj.options[i].value==value) {
				return obj.options[i].selected=true;
			}
		}
	} catch (e) {
		return "";
	}
}

/**
*    void allCheckSame(object self, object form, Array exNameArr)
*
*    onclick 事件。传入this与form对象，全选中当前 form 下的 checkbox 。
*    exNameArr 为传入数组。内容为除这些 name 名之外的全选中。可以为空。
*    e.g 为 onClick="allCheckSame(this, this.form, new Array(this.name));"
*    by longerface
*/
function allCheckSame(obj, objForm, exNameArr) {
	if (! objForm) {
		objForm = obj.form;
	}
	if (! objForm) {
		return;
	}
	for (var i=0; i<objForm.elements.length; i++) {
		var e = objForm.elements[i];
		if (e.type == 'checkbox' && e != obj) {
			if (exNameArr) {
				var _$ = false;
				for (var j=0; j<exNameArr.length; j++) {
					if (e.name == exNameArr[j]) {
						_$ = true;
					}
				}
				if (! _$) {
					if (e.click) {
						if (e.checked == obj.checked) {
							e.checked = !obj.checked;
						}
						e.click();
					} else {
						e.checked = obj.checked;
					}
				}
			} else {
				if (e.click) {
					if (e.checked == obj.checked) {
						e.checked = !obj.checked;
					}
					e.click();
				} else {
					e.checked = obj.checked;
				}
			}
		}
	}
}
function allCheckSamed(obj, objForm, exNameArr) {
	if (! objForm) {
		objForm = obj.form;
	}
	if (! objForm) {
		return;
	}
	for (var i=0; i<objForm.elements.length; i++) {
		var e = objForm.elements[i];
		if (e.type == 'checkbox' && e != obj) {
			if (exNameArr) {
				var _$ = false;
				for (var j=0; j<exNameArr.length; j++) {
					if (e.name == exNameArr[j] || e.id == exNameArr[j]) {
						_$ = true;
					}
				}
				if (! _$) {
					e.checked = obj.checked;
				}
			} else {
				e.checked = obj.checked;
			}
		}
	}
}
/**
 * 记录多选框选中数量方法
 * @param objTar		--	计数容器
 * @param objForm		--	多选范围
 * @param exNameArr		--	排除范围
 * @return
 */
function countCheckSamed(objTar,objForm,exNameArr){
	var count = 0;
	if (! objForm) {
		objForm = obj.form;
	}
	if (! objForm) {
		return;
	}
	for (var i=0; i<objForm.elements.length; i++) {
		var e = objForm.elements[i];
		if (e.type == 'checkbox') {
			if (exNameArr) {
				var _$ = false;
				for (var j=0; j<exNameArr.length; j++) {
					if (e.name == exNameArr[j] || e.id == exNameArr[j]) {
						_$ = true;
					}
				}
				if (! _$ && e.checked) {					
					count++;
				}
			} else if(e.checked) {
				count++;
			}
		}
	}
	
	document.getElementById(objTar).innerText=count+"";
}
/**
*  boolean in_array() 判断 v 值是否在数组 a 里
*  by longerface
*/
function in_array(v, a){
	if(!v || !a || a.length<1) return false;
	for(var _=0;_<a.length;_++)
		if(v==a[_])
			return true;
	return false;
}
/**
*  string ltrim(string str,char ABC)
*    去掉字符左边空格或左右的字符默认空格
*  string rtrim(string str,char ABC)
*    去掉字符右边空格或左右的字符默认空格
*  string trim(string str,char ABC)
*    去掉字符左右两边边空格或左右的字符默认空格
*/
function ltrim(str,ABC) {
    if(typeof(ABC)=="undefined" || ABC==null || ABC=="") ABC = " \t\n\r"
	var whitespace = new String(ABC);
    var s = new String(str);
    if (whitespace.indexOf(s.charAt(0)) != -1)
    {
        var j=0, i = s.length;
        while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
        {
            j++;
        }
        s = s.substring(j, i);
    }
    return s;
}
function rtrim(str,ABC) {
    if(typeof(ABC)=="undefined" || ABC==null || ABC=="") ABC = " \t\n\r"
    var whitespace = new String(ABC);
    var s = new String(str);
    if (whitespace.indexOf(s.charAt(s.length-1)) != -1)
    {
        var i = s.length - 1;
        while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
        {
            i--;
        }
        s = s.substring(0, i+1);
    }
    return s;
}
function trim(str,ABC) {
    if(typeof(ABC)=="undefined" || ABC==null || ABC=="") ABC = " \t\n\r"
    return rtrim(ltrim(str,ABC),ABC);
}
/**
*    string Request(string)
*    取得 get 传过来参数的值。
*/
function Request(name) {
	var reg = new RegExp("(^|\\?|&)"+ name +"=([^&]*)(\\s|&|$)", "i");
	if (reg.test(location.href))
	return unescape(RegExp.$2.replace(/\+/g, " "));
	return "";
}
/**
*      void playFlash(string file,string width,string height,string bgcolor,string quality,string name)
*      在调用当前函数位置打印出输出 flash 的对象字符。
*      file 为swf文件路径，width 为flash宽度，height为flash高度，bgcolor 为背景色，quality 为清晰度大多为"high"，name 可为空""
*/
function playFlash(file,width,height,bgcolor,quality,name) {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="'+name+'">');
	document.write('<param name="allowScriptAccess" value="always" />');
	document.write('<param name="movie" value="'+file+'" />');
	document.write('<param name="quality" value="'+quality+'" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="bgcolor" value="'+bgcolor+'" />');
	document.write('<embed src="'+file+'" quality="'+quality+'" wmode="transparent" bgcolor="'+bgcolor+'" width="'+width+'" height="'+height+'" name="'+name+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}
/**
* motion 动作控制类
* by longerface
* e.g
* 	motion.$seek(id)	返回动作对象
*	motion.$seek(id).$switch(sp, fn)	打开关闭控制	sp速度'slow','fast','normal' fn回调函数
*	motion.$seek(id).$loom(sp, fn)	淡出淡入开关控制	sp速度'slow','fast','normal' fn回调函数
*	motion.$seek(id).$show(sp, fn)	显示对象	sp速度'slow','fast','normal' fn回调函数
*	motion.$seek(id).$hide(sp, fn)	隐藏对象	sp速度'slow','fast','normal' fn回调函数
*	motion.$seek(id).$slideUp(sp, fn)	向上滑动隐藏对象	sp速度'slow','fast','normal' fn回调函数
*	motion.$seek(id).$slideDown(sp, fn)	向下滑动显示对象	sp速度'slow','fast','normal' fn回调函数
*	motion.$seek(id).$fadeOut(sp, fn)	淡出隐藏对象	sp速度'slow','fast','normal' fn回调函数
*	motion.$seek(id).$fadeIn(sp, fn)	淡入显示对象	sp速度'slow','fast','normal' fn回调函数
*	motion.$isEmptyFunction(fn)	判断是否是空方法	fn传入方法闭包
*	motion.$isVisual($)	判断对象是否可见	$传入对象引用默认$seek取得对象
*	motion.$isIE()	判断浏览器是否是 IE 浏览器
*	motion.$isNumber(s)	判断是否是数值型	s传入字符
*/
var motion = {
	$: {},	// 获取对象
	$self: this,	// 类本身
	$temp: new Object(),	// 临时对象引用数据
	$tempsy: new Object(),	// 临时对象样式
	$tempfn: new Function(),	// 临时方法
	$doing: 0,	//	正在运行状态
	/**
	* 构造方法
	*/
	$init: function(){
		
	}(),
	$_: function(){return this;},
	/**
	* 返回由 id 名返回对象引用 public
	* return this object
	*/
	$seek: function(_){
		if(this.$doing==1)return this;
		var doc = window.document || this.$;
		this.$ = (typeof _=='string')?doc.getElementById(_):_;
		return this;
	},
	/**
	* 返回速度值 private
	* return json
	*/
	$speed: function(sp){
		var h = this.$.offsetHeight;
		var hasHeight=(typeof(h)=="undefined" || h==null || h=="" || isNaN(h) || parseInt(h)<100)?false:true;
		h=hasHeight?parseInt(h):null;
		switch (sp.toLowerCase()){
			case 'slow':return (hasHeight)?{sec: 10, pix:parseInt(h/70), alp:1}:{sec: 6, pix: 4, alp:1};
			case 'fast':return (hasHeight)?{sec: 10, pix:parseInt(h/30), alp:3}:{sec: 2, pix: 6, alp:3};
			case 'normal':
			default:return (hasHeight)?{sec: 10, pix:parseInt(h/50), alp:2}:{sec: 4, pix: 5, alp:2};
		}
	},
	/**
	* 显示开关控制 public
	*/
	$switch: function(sp, fn){
		return this.$isVisual()?this.$hide(sp,fn):this.$show(sp,fn);
	},
	/**
	* 淡出淡入开关控制 public
	*/
	$loom: function(sp, fn){
		return this.$isVisual()?this.$fadeOut(sp,fn):this.$fadeIn(sp,fn);
	},
	/**
	* 隐藏动作 public
	*/
	$hide: function(sp, fn){
		return this.$isVisual()?this.$slideUp(sp, fn):this;
	},
	/**
	* 显示动作 public
	*/
	$show: function(sp, fn){
		return this.$isVisual()?this:this.$slideDown(sp, fn);
	},
	/**
	* 向上缩回动作 public
	*/
	$slideUp: function(sp, fn){
		var _=this;
		with(_){		
			if($doing==1)return $_;else $doing=1;
			$tempsy.height=$.style.height;
			$tempsy.overflow=$.style.overflow;
			$.style.display='block';
		}
		_.$.style.display=sp?(function(_){
			with(_){
			$.style.overflow='hidden';
			$tempfn=fn;
			$shrink($speed(sp));
			}
			return 'block';
		}(_)):function(_){_.$doing=0;return 'none'}(_);
		return this.$isEmptyFunction(_.$tempfn)&&fn?fn():_;
	},
	/**
	* 向下展开动作 public
	*/
	$slideDown: function(sp, fn){
		var _=this;
		with(_){
			if($doing==1)return $_;else $doing=1;
			$tempsy.height=$.style.height;
			$tempsy.overflow=$.style.overflow;
			$.style.display='block';
			$temp['oldHeight']=parseInt($.offsetHeight)-($.style.borderTopWidth?parseInt($.style.borderTopWidth):0)-($.style.borderBottomWidth?parseInt($.style.borderBottomWidth):0);
			$.style.display='none';
		}
		_.$.style.display=sp?(function(_){
			with(_){
			$.style.height="0px";
			$.style.overflow='hidden';
			$tempfn=fn;
			$expand($speed(sp));
			}
			return 'block';
		}(_)):function(_){_.$doing=0;return 'block'}(_);
		return this.$isEmptyFunction(_.$tempfn)&&fn?fn():_;
	},
	/**
	* 淡出动作 public
	*/
	$fadeOut: function(sp, fn){
		var _=this;
		with(_){
			if($doing==1)return $_;else $doing=1;
			var css = $.style.cssText;
			$.style.display='block';
			if($isIE())$tempsy['width']=/width/ig.test(css)?$.style.width:(function($_){$.style.width='100%';return 'auto';}($_));
			$tempsy['alpha']=/filter|alpha/ig.test(css)?css.replace(/.*?alpha\(.*?opacity=(\d*).*?\).*/ig, "$1"):(function($_){$.style.filter='alpha(opacity=100)';return '100';}($_));
			$tempsy['opacity']=/opacity\s*:.*?\;/ig.test(css)?css.replace(/.*?opacity\s*:\s*(.*?)\;.*/ig, "$1"):'1';
			sp=sp?sp:'normal';
			$tempfn=fn;
			$hyaline($speed(sp));
		}
	},
	/**
	* 淡入动作 public
	*/
	$fadeIn: function(sp, fn){
		var _=this;
		with(_){
			if($doing==1)return $_;else $doing=1;
			var css = $.style.cssText;
			$.style.display='block';
			$tempsy['alpha']=/filter|alpha/ig.test(css)?css.replace(/.*?alpha\(.*?opacity=(\d*).*?\).*/ig, "$1"):(function($_){$.style.filter='alpha(opacity=0)';return '100';}($_));
			$tempsy['opacity']=/opacity\s*:.*?\;/ig.test(css)?css.replace(/.*?opacity\s*:\s*(.*?)\;.*/ig, "$1"):'1';
			if($isIE()){
				$tempsy['width']=/width/ig.test(css)?css.replace(/.*?width\s*:\s*(.*?)\;.*/ig, "$1"):(function($_){$.style.width='100%';return 'auto';}($_));
				$.style.filter=$.style.filter.replace(/alpha(\s*?)\((.*?)opacity=(\d*)(.*?\))/ig,"alpha$1($2opacity=0$4");
			}else{
				$.style.opacity='0';
			}
			sp=sp?sp:'normal';
			$tempfn=fn;
			$opaque($speed(sp));
		}
	},
	/**
	* 收缩方法 private
	*/
	$shrink: function(sp){
		var _=this;
		with(_){
			var newHeight = parseInt($.offsetHeight)-($.style.borderTopWidth?parseInt($.style.borderTopWidth):0)-($.style.borderBottomWidth?parseInt($.style.borderBottomWidth):0)-sp.pix;
			if(newHeight<0){
				$.style.height=$tempsy.height;
				$.style.overflow=$tempsy.overflow;
				$.style.display='none';
				$doing=0;
				return $tempfn?$tempfn():$_;
			}
			$.style.height = newHeight+"px";
		}
		return setTimeout(function(){
			_.$shrink(sp);
		}, sp.sec);
	},
	/**
	* 展开方法 private
	*/
	$expand: function(sp){
		var _=this;
		with(_){
			var newHeight = parseInt($.offsetHeight)-($.style.borderTopWidth?parseInt($.style.borderTopWidth):0)-($.style.borderBottomWidth?parseInt($.style.borderBottomWidth):0)+sp.pix;
			if(newHeight>$temp.oldHeight){
				$.style.height=$tempsy.height;
				$.style.overflow=$tempsy.overflow;
				$.style.display='block';
				$doing=0;
				return $tempfn?$tempfn():$_;
			}
			$.style.height = newHeight+"px";
		}
		return setTimeout(function(){
			_.$expand(sp);
		}, sp.sec);
	},
	/**
	* 变透明方法 private
	*/
	$hyaline: function(sp){
		var _=this;
		with(_){
			var css = $.style.cssText;
			alpha=css.replace(/.*?alpha\s*\(.*opacity=(\d*).*\).*/ig, "$1");
			alpha=alpha&&$isNumber(alpha)?parseInt(alpha):parseInt($tempsy.alpha);
			opacity=css.replace(/.*?opacity\s*:\s*(.*?)\;.*/ig, "$1");
			opacity=opacity&&$isNumber(opacity)?parseFloat(opacity):parseFloat($tempsy.opacity);
			if($isIE()){
				if(alpha==0){
					$.style.display='none';
					$.style.width=$tempsy.width;
					$.style.filter=$.style.filter.replace(/alpha(\s*?)\((.*?)opacity=(\d*)(.*?\))/ig,"alpha$1($2opacity="+$tempsy.alpha+"$4");
					$doing=0;
					return $tempfn?$tempfn():$_;
				}
				$.style.filter=$.style.filter.replace(/alpha(\s*?)\((.*?)opacity=(\d*)(.*?\))/ig,"alpha$1($2opacity="+(alpha-sp.alp<=0?0:alpha-sp.alp)+"$4");
			}else{
				opacity=parseInt(opacity*100);
				if(opacity==0){
					$.style.opacity=$tempsy.opacity;
					$.style.display='none';
					$doing=0;
					return $tempfn?$tempfn():$_;
				}
				$.style.opacity=opacity-sp.alp<=0?0:(opacity-sp.alp)/100;
			}
		}
		return setTimeout(function(){
			_.$hyaline(sp);
		}, sp.sec);
	},
	/**
	* 变不透明方法 private
	*/
	$opaque: function(sp){
		var _=this;
		with(_){
			var css = $.style.cssText;
			alpha=css.replace(/.*?alpha\s*\(.*opacity=(\d*).*\).*/ig, "$1");
			alpha=alpha&&$isNumber(alpha)?parseInt(alpha):parseInt($tempsy.alpha);
			opacity=css.replace(/.*?opacity\s*:\s*(.*?)\;.*/ig, "$1");
			opacity=opacity&&$isNumber(opacity)?parseFloat(opacity):parseFloat($tempsy.opacity);
			if($isIE()){
				if(alpha==parseInt($tempsy.alpha)){
					//$.style.width=$tempsy.width;
					$.style.filter=$.style.filter.replace(/alpha(\s*?)\((.*?)opacity=(\d*)(.*?\))/ig,"alpha$1($2opacity="+$tempsy.alpha+"$4");
					$doing=0;
					return $tempfn?$tempfn():$_;
				}
				$.style.filter=$.style.filter.replace(/alpha(\s*?)\((.*?)opacity=(\d*)(.*?\))/ig,"alpha$1($2opacity="+(alpha+sp.alp>=parseInt($tempsy.alpha)?parseInt($tempsy.alpha):alpha+sp.alp)+"$4");
			}else{
				opacity=parseInt((opacity*100).toFixed(1));
				oldOpacity=parseInt((parseFloat($tempsy.opacity)*100).toFixed(1));
				if(opacity==oldOpacity){
					$.style.opacity=$tempsy.opacity;
					$doing=0;
					return $tempfn?$tempfn():$_;
				}
				$.style.opacity=opacity+sp.alp>=oldOpacity?oldOpacity/100:(opacity+sp.alp)/100;
			}
		}
		return setTimeout(function(){
			_.$opaque(sp);
		}, sp.sec);
	},
	/**
	* 判断方法是否是空方法 public
	* return boolean
	*/
	$isEmptyFunction: function(fn){
		return fn?new RegExp(/functionanonymous\(\)\{\}/i).test(fn.valueOf().toString().replace(/\s*/g,'')):false;
	},
	/**
	* 判断对象是否可见 public
	* return boolean
	*/
	$isVisual: function($){
		return /none/i.test(($?$:this.$).style.display.toString())?false:true;
	},
	/**
	* 判断浏览器是否IE public
	* return boolean
	*/
	$isIE: function(){
		b = window.navigator.userAgent;
		if(/msie/ig.test(b))	return true;
		else if(/gecko/ig.test(b)) return false;
		else return false;
	},
	/**
	* 判断是否是数值型 public
	*/
	$isNumber: function (s){
		return !isNaN(s);
	}
}
/**
*     string getFormStr(object obj, string func)
*     此函数用于取得某 form 里每个控件的名称和值。
*     by longerface
*     e.g:  getFormStr(form对象, 字串转换方法)
*           返回 get 型上传字串，aaa=11&bbb=2&ccc=333。此处中文用 escape 函数转成URL编码。
*		可以选用//escape//encodeURIComponent//encodeURI
*/
function getFormStr(obj, encode){
	var encode = encode ? encode : 'encodeURI';
    var FormStr = "1=1";
    for(j=0;j<obj.length;j++){
	    if(obj[j].type=="checkbox"){  //多选框
	        var mychk = document.getElementsByName(obj[j].name);
	        for(ck=0;ck<mychk.length;ck++){
		        if(mychk[ck].checked){
			        FormStr += ("&" + obj[j].name + "=" + eval(encode+'(mychk[ck].value)'));
		        }
	        }
	    }else if(obj[j].type=="select-one"){  //下拉框(下拉框选中value=""的项返回)
		    for(op=0;op<obj[j].options.length;op++){
			    if(obj[j].options[op].selected){
				    FormStr += ("&" + obj[j].name + "=" + eval(encode+'(obj[j].options[op].value)'));
			    }
		    }
	    }else if(obj[j].type=="radio"){  //单选框
	        var mychk = document.getElementsByName(obj[j].name);
            for(ck=0;ck<mychk.length;ck++){
		        if(mychk[ck].checked){
			        FormStr += ("&" + obj[j].name + "=" + eval(encode+'(mychk[ck].value)'));
		        }
	        }
	    }else if(obj[j].type=="hidden"){  //隐藏框
		    FormStr += ("&" + obj[j].name + "=" + eval(encode+'(obj[j].value)'));
	    }else {  //文本框,输入框,密码框,文件浏览框
		    FormStr += ("&" + obj[j].name + "=" + eval(encode+'(obj[j].value)'));
        };
    }
    return FormStr
}
/**
* 字串返回json
* by longerface
*/
function strToJson(str){
	if(!/^\s*[\{|\[].*[\}|\]]\s*$/m.test(str)) return false;
	var json = eval('['+str+']');
	return json[0];
}
/**
* object offsetCoordinate(object)
* 返回元素对象的绝对坐标 {top: int, left: int}
* by longerface
*/
function offsetCoordinate(ob){
	for(_={top:0,left:0};ob&&ob.tagName.toLowerCase()!='body';ob=ob.offsetParent?ob.offsetParent:false)
	{
		_.top  += ob.offsetTop;
		_.left += ob.offsetLeft;
	}
	return _;
}
/**
* boolean object_exists(String objName, String parentObjName)
* 返回对象是否存在
* by longerface
*/
function object_exists(objName, parentObjName){
	if(!objName) return false;
	var parentObject = parentObjName || 'window';
	if(parentObject!='window'&&(!object_exists(parentObject))){
		return false;
	}else{
		obj = parentObject + '.' + objName;
		return eval("typeof "+obj+"!='undefined'?true:false");
	}
}
/**
* boolean function_exists(String funcName, String objName)
* 返回函数方法是否存在
* by longerface
*/
function function_exists(funcName, objName){
	if(!object_exists(funcName, objName)) return false;
	func = (objName || 'window') + '.' + funcName;
	return eval("typeof "+func+"!='undefined'?(typeof "+func+"=='function'?true:false):false");
}
/**
*  
*  图层拖拽类
*  by longerface
*  _$m 使用说明：
*	一、使用方法：
*	  代码：在鼠标焦点拖动的位置写入 onMouseDown 事件：
*		  onmousedown="_$m.m('DivId', event);"
*	  分析：onMouseDown 事件内有两句语句分别为：
*		  _$m.moveDivDown('DivId', event);  运行点下鼠标事件，并传入此事件。DivId为类变量赋值，值为你要拖动的 div 层的 id 名也可传入对象。
*		  e.g _$m.moveDivDown(this, event);
*		  注：position:absolute;图层绝对定位
*	二、图层拖动类各属性方法说明：
*		属性：
*		moveDivId                          要拖动的图层 id。默认空
*		moveDivLeft                        图层原始居左距离。默认0
*		moveDivTop                         图层原始居上距离。默认0
*		onMouseDownState                   鼠标是否按下，按下为 true ，抬起为 false。默认 false
*		方法：
*		void moveDivInit()                 初始化属性值
*		void moveDivDown(event ev)         鼠标按下后的初始化
*		void moveDivUp()                   鼠标抬起后还原变量
*		void moveDiv(event ev)             鼠标移动控制图层位置
*		object getMousePosition(event ev)  JSON返回当前鼠标x,y位置 this.x 为 left 距离， this.y 为 top 距离
*/
var _$m = {
	moveDivInit: function(){
		this.moveDivId = null;
		this.moveType = 'copy';
		this.moveDivLeft = 0;
		this.moveDivTop = 0;
		this.onMouseDownState = false;
		this.copyDivTemp = null;
	}(),
	moveDivDown: function(ob, ev, ty){
		this.moveDivId = ob;
		var ID = typeof (this.moveDivId)=='string' ? document.getElementById(this.moveDivId) : this.moveDivId;
		if(ID.style.position!='absolute')ID.style.position='absolute';
		this.moveType = ty || 'default';
		if(this.moveType=='copy'){
			this.copyDivTemp = document.createElement("DIV");
			this.copyDivTemp = ID.cloneNode(ID);
			this.copyDivTemp.style.cssText=ID.style.cssText;
			ID.parentNode.appendChild(this.copyDivTemp);
			if(typeof ID.style.filter=='undefined')
				ID.style.opacity = .5;
			else
				ID.style.filter="alpha(opacity=50)";
		}
		this.onMouseDownState = true;
		ev = ev || window.event;
		var mouse = this.getMousePosition(ev);
		if(typeof ID.style.left=="undefined" || ID.style.left==null || ID.style.left==""){
			if(ID.offsetLeft=="undefined" || ID.offsetLeft==null){
				ID.style.left = "0px;";
			}else{
				ID.style.left = ID.offsetLeft + "px";
			}
		}
		if(typeof ID.style.top=="undefined" || ID.style.top==null || ID.style.top==""){
			if(ID.offsetTop=="undefined" || ID.offsetTop==null){
				ID.style.top = "0px;";
			}else{
				ID.style.top = ID.offsetTop + "px";
			}
		}
		this.moveDivLeft = mouse.x - parseInt(ID.style.left);
		this.moveDivTop  = mouse.y - parseInt(ID.style.top);
		mouse = null;
		if(document.addEventListener){
			document.addEventListener('mousemove', this.moveDiv, true);
			document.addEventListener('mouseup', this.moveDivUp, true);
		}else if(document.attachEvent){
			document.attachEvent('onmousemove', this.moveDiv);
			document.attachEvent('onmouseup', this.moveDivUp);
		}else{
			document.onmousemove = this.moveDiv;
			document.onmouseup = this.moveDivUp;
		}
	},
	m: function(ob, ev, ty){return this.moveDivDown(ob, ev, ty)},
	moveDivUp: function(){
		var m = _$m || window;
		var ID = typeof (m.moveDivId)=='string' ? document.getElementById(m.moveDivId) : m.moveDivId;
		m.onMouseDownState = false;
		m.moveDivLeft = null;
		m.moveDivTop = null;
		m.moveDivId = null;
		m.copyDivTemp?function(m){
			m.copyDivTemp.parentNode.removeChild(m.copyDivTemp);
			m.copyDivTemp = null;
			if(typeof ID.style.filter=='undefined')
				ID.style.opacity = 1;
			else
				ID.style.filter="alpha(opacity=100)";
		}(m):null;
		document.onmousemove = new Function();
		document.onmouseup = new Function();
	},
	moveDiv: function(ev)
	{
		var m = _$m || window;
		if(typeof m.onMouseDownState!="undefined" && m.onMouseDownState)
		{
			var ID = typeof (m.moveDivId)=='string' ? document.getElementById(m.moveDivId) : m.moveDivId;
			ev = ev || window.event;
			var mouse = m.getMousePosition(ev);
			if((mouse.y - m.moveDivTop)>0 && (mouse.x - m.moveDivLeft)>0){
				ID.style.left = (mouse.x - m.moveDivLeft) + "px";
				ID.style.top =  (mouse.y - m.moveDivTop) + "px";
			}
			mouse = null;
		}
	},
	getMousePosition: function(ev){
		return ev.pageX || ev.pageY ? {
				x:ev.pageX,
				y:ev.pageY
			} : {
				x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
				y:ev.clientY + document.body.scrollTop  - document.body.clientTop
			};
	}
}

/**
*  string radiovalue(object obj)
*  返回input中 radio 所选择的 value 值
*  obj为 document.formName.objectName或this 
*  by longerface
*/
function radiovalue(obj){
	try{
		if(!obj) return '';
		if(obj[0]) for(var i=0;i<obj.length;i++){
			if(obj[i].checked==true){
				return (obj[i].value);
			}
		}else{
			if(obj.checked==true)
				return obj.value;
			else
				return '';
		}
	}catch(e){return "";}
}

function reflow() {
	document.body.style.zoom = 1.1;
	document.body.style.zoom = '';
}

function copyToClipboard(txt){
	if(window.clipboardData){
		window.clipboardData.clearData();
		window.clipboardData.setData('Text', txt);
	}else
		if(navigator.userAgent.indexOf('Opera')!=-1){
			window.location = txt;
		}else
			if(window.netscape){
				try{
					netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
				}catch(e){return false;}
				var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
				if(!clip) return;
				var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
				if(!trans) return;
				trans.addDataFlavor('text/unicode');
				var str={},len={};
				var str = Components.classes['@mozilla.org/supports-string;1'].createInstance(Components.interfaces.nsISupportsString);
				var copytext = txt;
				str.data = copytext;
				trans.setTransferData('text/unicode', str, copytext.length*2);
				var clipid = Components.interfaces.nsIClipboard;
				if(!clip) return false;
				clip.setData(trans, null, clipid.kGlobalClipboard);
			}
}


function getEvent() { //获取浏览器事件，同时兼容ie和ff的写法
if (document.all) return window.event;
 func = getEvent.caller;
 while (func != null) {
 var arg0 = func.arguments[0];
 if (arg0) {
 if ((arg0.constructor == Event || arg0.constructor == MouseEvent) || (typeof (arg0) == "object" && arg0.preventDefault && arg0.stopPropagation)) {
 return arg0;
 }
 }
 func = func.caller;
 }
 return null;
}

var getNav = function() {
	var obj = new Object();
	obj.isIE = navigator.userAgent.indexOf("MSIE") > 0 ? true : false;
	obj.isIE6 = (obj.isIE && navigator.userAgent.indexOf("MSIE 6.0") > 0) ? true : false;
	obj.isIE7 = (obj.isIE && navigator.userAgent.indexOf("MSIE 7.0") > 0) ? true : false;
	obj.isFirefox = navigator.userAgent.indexOf("Firefox") > 0 ? true : false;
	obj.isChrome = navigator.userAgent.indexOf("Chrome") > 0 ? true : false;
	obj.isSafari = navigator.userAgent.indexOf("Safari") > 0 ? true : false;
	obj.isCamino = navigator.userAgent.indexOf("Camino") > 0 ? true : false;
	obj.isMozilla = navigator.userAgent.indexOf("Gecko/") > 0 ? true : false;
	obj.GetNavName = function() {
	return navigator.userAgent;
	};
	obj.GetAllNav = function() {
	//return { ie: obj.isIE, firefox: obj.isFirefox, Chrome: obj.isChrome };
	return '' + obj.isIE + obj.isFirefox + obj.isChrome;
	};
	return obj;
};


