/*************** 非公用函数 ****************/
function toggleImgchkChecked(obj) {
	if (obj.attributes['ex_disabled'].nodeValue=='true') return false;
	var checked = obj.attributes['ex_checked'].nodeValue;
	setImgchkChecked(obj, (checked=='true' ? false : true));
}
function setImgchkChecked(obj, checked) {
	if (obj.attributes['ex_disabled'].nodeValue=='true') return false;
	if (checked) {
		obj.style.backgroundPosition = "0 -451";
	}
	else{
		obj.style.backgroundPosition = "0 -301";
	}
	obj.attributes['ex_checked'].nodeValue = (checked ? 'true' : 'false');
}
function setImgchkDisabled(obj, disabled) {
	var checked = obj.attributes['ex_checked'].nodeValue;
	if (checked=='true') {	//如果当前选中状态
		if (disabled) {		//选中置灰
			obj.style.backgroundPosition = "0 -551";
		}
		else{				//选中可用
			obj.style.backgroundPosition = "0 -451";
		}
	}
	else{
		if (disabled) {		//未选置灰
			obj.style.backgroundPosition = "0 -401";
		}
		else{				//未选可用
			obj.style.backgroundPosition = "0 -301";
		}
	}
	obj.attributes['ex_disabled'].nodeValue = (disabled ? 'true' : 'false');
}
function setImgchkDisplay(obj, display) {
	if(display)
		obj.style.display = "inline";
	else
		obj.style.display = "none";
}
function getImgchkDisplay(obj) {
	return (obj.style.display != "none");
}
function jsonToStr(jsonData){
	var str="";
	if (typeof(jsonData)=='object') {
		str += "{";
		for(var key in jsonData){
			str += "'"+ key +"':'"+jsonData[key]+"',";
		}
		str = str.slice(0,-1);
		str += "}";
	}
	else{
		if(jsonData.length>0){
			for(var i=0;i<jsonData.length;i++){
				str +="{";
				str1 = "";
				for(var key in jsonData[i]){
					str1 +='"'+ key +'":"'+jsonData[i][key]+'",';
				}
				str1 = str1.slice(0,-1);
				str += str1;
				str +="}";
				str +=',';
			}
			str = str.slice(0,-1);
		}
		str = '['+str+']';
	}
	return str;
}
function videoUrlPostFix(mobile, pwd, clientip){
	if (mobile.length==0){
		mobile = "guest";
		pwd = "guest".MD5(32);
	}

	timestamp = new Date().getTime() + '';
	timestamp = timestamp.substr(0, timestamp.length-3);
	
	//var en = mobile + "+" + pwd + "+" + clientip + "+" + timestamp;
	var en = mobile + "+" + pwd + "+" + timestamp;
	
	en = en.MD5(32);
	
	rx = "id=" + mobile + "&t=" + timestamp + "&en=" + en;
	
	return rx;
}
/*************** 非公用函数 ****************/

 
// 说明：为 Javascript 数组添加一个 inArray 方法 
Array.prototype.inArray = function (value) 
{ 
    var i; 
    for (i=0; i < this.length; i++) { 
        // Matches identical (===), not just similar (==). 
        if (this[i] === value) { 
            return true; 
        } 
    } 
    return false; 
};
function getRndNumber(m,n){
	return Math.floor(Math.random()*n)+m;
}
function getRandomString(len){
	var charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	var charset_len = charset.length;
	var x = "";
	for (var i=0; i<len; i++)
	{
		x += charset.substr(getRndNumber(0, charset_len-1), 1);
	}
	return x;
}
function getLocTime(nS) {
    return new Date(parseInt(nS) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
}
function getPHPTimeStamp(){
	 var x = Date.parse(new Date());
	 x = x / 1000;
	 x = convert_int(x);
	 return x;
}
function sec2time(seconds) {
	var pd = 1*24*60*60;
	var ph = 1*60*60;
	var pm = 1*60;
	var d = 0;
	var h = 0;
	var m = 0;
	var s = 0;
	var strx = '';
	
	if (seconds<pm) return seconds+"秒";
	if (seconds<ph) {
		m = Math.floor(seconds / pm);
		s = seconds % pm;
		strx = m+"分";
		if (s>0) strx += s+"秒";
		return strx;
	}
	if (seconds<pd) {
		h = Math.floor(seconds / ph);
		m = Math.floor((seconds - ph*h) / pm);
		s = (seconds - ph*h) % pm;
		strx = h+"小时";
		if (m>0) strx += m+"分";
		if (s>0) strx += s+"秒";
		return strx;
	}
	if (seconds>=pd) {
		h = Math.floor(seconds / ph);
		m = Math.floor((seconds - ph*h) / pm);
		s = (seconds - ph*h) % pm;
		
		d = Math.floor(h / 24);
		h = h % 24;
		strx = d+"天";
		if (h>0) strx += h+"小时";
		if (m>0) strx += m+"分";
		if (s>0) strx += s+"秒";
		return strx;
	}
}
function appendHiddenField(frmA,name,value){
	var ipt = document.createElement("input");
	ipt.name = name;
	ipt.value = value;
	ipt.type = "hidden";
	frmA.appendChild(ipt);
}

function getBodyWidth(){
        return document.body.clientWidth-15;
}
function $(objid){
	return document.getElementById(objid);
}
function insertAfter(newElement, targetElement)
{
    var parent = targetElement.parentNode;
    if(parent.lastChild == targetElement)
    {
        parent.appendChild(newElement);
    }
    else
    {
        parent.insertBefore(newElement, targetElement.nextSibling);
    }
}
function conv_int(mix, dft){
	if (!isInt(mix)) {
		return dft;
	}
	else{
		return mix;
	}
}
function isInt(str){
	return /^(-|\+)?\d+$/.test(str);
}
function isUnsignInt(str){
	return /^\d+$/.test(str);
}
function isFullDateTime(str)
{
	var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/; 
	var r = str.match(reg); 
	if(r==null)return false; 
	var d= new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]);
	
	return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]&&d.getHours()==r[5]&&d.getMinutes()==r[6]&&d.getSeconds()==r[7]);
}
function fixDate2fullWidth(num, width){
	var rx = num.toString();
	if (rx.length<width){
		for(var i=1; i<=width-rx.length; i++){
			rx = "0"+rx;
		}
		
	}
	return rx;
}
function tagContent(tagA, tagB, vstr){
	var rx = "";
	if (vstr.length>0){
		var pa = -1;
		if (tagA.length==0){
			pa = 0;
		}
		else{
			pa = vstr.indexOf(tagA);
		}
		
		if (pa>-1){
			var pb = -1;
			if (tagB.length==0){
				pb = vstr.length;
			}
			else{
				pb = vstr.indexOf(tagB, pa+tagA.length);
			}
			//alert(vstr + ":::" + pa + "|" + pb);
			//alert(vstr + ":::" + (pa+tagA.length) + "|" + (pb-(pa+tagA.length)));
			if (pb>-1){
				rx = vstr.substr(pa+tagA.length, pb-(pa+tagA.length));
			}
		}
	}
	return rx;
}

function fillNumToCombox(obj, vFrom, vTo){
	try{
		for(var i=vFrom; i<=vTo; i++){
			var newopt = new Option(i, i); 	//先是文本，后是值
			obj.options.add(newopt);
		}
	}
	catch(e){}
}
function slideCombox(obj, vlu){
	try{
		for(var i=0; i<obj.options.length; i++){
			if (obj.options[i].value==vlu){
				obj.options[i].selected = true;
				break;
			}
		}
	}
	catch(e){}
}

//文档可见区域中心
function getPageVisCenterX(){
	try{
		//鼠标的浏览器坐标
		var x=document.body.offsetWidth / 2;
		var y=document.body.scrollTop + document.body.offsetHeight / 2;
		
		return x;
	}
	catch(e){
		return 0;	
	}
}
function getPageVisCenterY(){
	try{
		//鼠标的浏览器坐标
		var x=document.body.offsetWidth / 2;
		var y=document.body.scrollTop + document.body.offsetHeight / 2;
		
		return y;
	}
	catch(e){
		return 0;	
	}
}

function getScreenWidth(){
	return window.screen.width;	
}
function getScreenHeight(){
	return window.screen.height;	
}

function messageWindow(url, name, width, height, scrollbars, resizable) {
	if (typeof(scrollbars)=="undefined") scrollbars = "no";
	if (typeof(resizable)=="undefined") resizable = "no";
	aa = window.open(url, name, "width="+width+",height="+height+",left="+((getScreenWidth()-width)/2)+",top="+((getScreenHeight()-height)/2)+",toolbar=no,location=no,status=no,menubar=no,scrollbars="+scrollbars+",resizable="+resizable);
	aa.focus();
	return aa;
}
function normalWindow(url, name) {
	window.open(url, name, "width="+(parseFloat(window.screen.availWidth)-10)+",height="+(parseFloat(window.screen.availHeight)-155)+",left=0,top=0,toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes");
}

function getMax(vstr, vdeli){
	var rV;
	if (vstr.length>0){
		if (typeof(vdeli)=="undefined") vdeli = ",";
		var ary = vstr.split(vdeli);
		rV = ary[0];
		for(var i=1; i<ary.length; i++){
			if (parseFloat(ary[i])>parseFloat(rV)) rV = ary[i];	
		}
	}
	return rV;
}

function getMin(vstr, vdeli){
	var rV;
	if (vstr.length>0){
		if (typeof(vdeli)=="undefined") vdeli = ",";
		var ary = vstr.split(vdeli);
		rV = ary[0];
		for(var i=1; i<ary.length; i++){
			if (parseFloat(ary[i])<parseFloat(rV)) rV = ary[i];	
		}
	}
	return rV;
}

function openFullWindow(vurl,vname){
	window.open(vurl,vname,'fullscreen=yes,status=no');
	
	/*
	var winWidth=screen.availWidth ;
	var winHeight=screen.availHeight;

	var oPopup = window.createPopup();
	var oPopBody = oPopup.document.body;
	oPopBody.style.align="center";
	oPopBody.innerHTML = '<iframe src="' + vurl + '" id="' + vname + '" name="' + vname + '" width="100%" height="100%" marginwidth="0" marginheight="0" align="left" frameborder="0" scrolling="no"></iframe>';
	oPopup.show(0,0,winWidth,winHeight,document.body);
	*/
}

String.prototype.trim = function()   
{   
	  //   用正则表达式将前后空用空字符串替代。   
	  return this.replace(/(^\s*)|(\s*$)/g, "");   
} 
  
function getRequest(strName, strHref)
{
	if (typeof(strHref)=='undefined') strHref = window.location.href;
	var intPos = strHref.indexOf("?");
	var strRight = strHref.substr(intPos + 1);
	
	var arrTmp = strRight.split("&");
	for(var i = 0; i < arrTmp.length; i++)
	{
		var arrTemp = arrTmp[i].split("=");
		if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1];
	}
	return "";
}

function setFav(){
	window.external.addFavorite(document.location.href,'cn2live');
}

function setHmp(vobj){
	vobj.style.behavior='url(#default#homepage)';
	vobj.sethomepage(document.location.href);
}

function openUrl(vcmb,bs){
	var obj = document.all(vcmb);
	var url = obj.options[obj.options.selectedIndex].value;

	obj.options.selectedIndex = 0;

	if(url!=0){
		if(bs==0){
			document.location=url;
		}
		else{
			window.open(url);	
		}
	}
}

function dowelcom(vcmb){
	var obj = document.all(vcmb);
	var i = obj.options.selectedIndex;
	switch(i){
	case 1:
		setFav();
		break;
	case 2:
		setHmp(obj);
		break;
	}

	obj.options.selectedIndex = 0;
}

function testNUM(num){
	var tmp = num + "";
	return tmp==tmp.match(/^\d+$/);
}

function submitGoPage(vpg){
	frmPage.pg.value=vpg;
	frmPage.submit();
}

function getSiteHost(){
	var url = window.location.href;
	var rx = tagContent("//","/",url);
	if (rx.length==0) rx = tagContent("//","",url);
	if (rx.length==0) rx = url;
	
	return rx;
}

/*
 '请注意文件编码，如果客户端的md5文件编码和服务器端的md5文件编码不一样，则加密出来的字符串不一样
 '修改:xilou 2080711
 '例子:
	'www.chinacms.org'.MD5();//默认为16位加密
	'www.chinacms.org'.MD5(32);//32位加密
*/
String.prototype.MD5 = function (bit)
{
	var sMessage = this;
	function RotateLeft(lValue, iShiftBits) { return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits)); } 
	function AddUnsigned(lX,lY)
	{
		var lX4,lY4,lX8,lY8,lResult;
		lX8 = (lX & 0x80000000);
		lY8 = (lY & 0x80000000);
		lX4 = (lX & 0x40000000);
		lY4 = (lY & 0x40000000);
		lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF); 
		if (lX4 & lY4) return (lResult ^ 0x80000000 ^ lX8 ^ lY8); 
		if (lX4 | lY4)
		{ 
			if (lResult & 0x40000000) return (lResult ^ 0xC0000000 ^ lX8 ^ lY8); 
			else return (lResult ^ 0x40000000 ^ lX8 ^ lY8); 
		} else return (lResult ^ lX8 ^ lY8); 
	} 
	function F(x,y,z) { return (x & y) | ((~x) & z); } 
	function G(x,y,z) { return (x & z) | (y & (~z)); } 
	function H(x,y,z) { return (x ^ y ^ z); } 
	function I(x,y,z) { return (y ^ (x | (~z))); } 
	function FF(a,b,c,d,x,s,ac)
	{ 
		a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac)); 
		return AddUnsigned(RotateLeft(a, s), b); 
	} 
	function GG(a,b,c,d,x,s,ac)
	{ 
		a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac)); 
		return AddUnsigned(RotateLeft(a, s), b); 
	} 
	function HH(a,b,c,d,x,s,ac)
	{ 
		a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac)); 
		return AddUnsigned(RotateLeft(a, s), b); 
	} 
	function II(a,b,c,d,x,s,ac)
	{ 
		a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac)); 
		return AddUnsigned(RotateLeft(a, s), b); 
	} 
	function ConvertToWordArray(sMessage)
	{ 
		var lWordCount; 
		var lMessageLength = sMessage.length; 
		var lNumberOfWords_temp1=lMessageLength + 8; 
		var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64; 
		var lNumberOfWords = (lNumberOfWords_temp2+1)*16; 
		var lWordArray=Array(lNumberOfWords-1); 
		var lBytePosition = 0; 
		var lByteCount = 0; 
		while ( lByteCount < lMessageLength )
		{ 
			lWordCount = (lByteCount-(lByteCount % 4))/4; 
			lBytePosition = (lByteCount % 4)*8; 
			lWordArray[lWordCount] = (lWordArray[lWordCount] | (sMessage.charCodeAt(lByteCount)<<lBytePosition)); 
			lByteCount++; 
		} 
		lWordCount = (lByteCount-(lByteCount % 4))/4; 
		lBytePosition = (lByteCount % 4)*8; 
		lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition); 
		lWordArray[lNumberOfWords-2] = lMessageLength<<3; 
		lWordArray[lNumberOfWords-1] = lMessageLength>>>29; 
		return lWordArray; 
	} 
	function WordToHex(lValue)
	{ 
		var WordToHexValue="",WordToHexValue_temp="",lByte,lCount; 
		for (lCount = 0;lCount<=3;lCount++)
		{ 
			lByte = (lValue>>>(lCount*8)) & 255; 
			WordToHexValue_temp = "0" + lByte.toString(16); 
			WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2); 
		} 
		return WordToHexValue; 
	} 
	var x=Array(); 
	var k,AA,BB,CC,DD,a,b,c,d 
	var S11=7, S12=12, S13=17, S14=22; 
	var S21=5, S22=9 , S23=14, S24=20; 
	var S31=4, S32=11, S33=16, S34=23; 
	var S41=6, S42=10, S43=15, S44=21; 
	// Steps 1 and 2. Append padding bits and length and convert to words 
	x = ConvertToWordArray(sMessage); 
	// Step 3. Initialise 
	a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476; 
	// Step 4. Process the message in 16-word blocks 
	for (k=0;k<x.length;k+=16)
	{ 
		AA=a; BB=b; CC=c; DD=d; 
		a=FF(a,b,c,d,x[k+0], S11,0xD76AA478); 
		d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756); 
		c=FF(c,d,a,b,x[k+2], S13,0x242070DB); 
		b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE); 
		a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF); 
		d=FF(d,a,b,c,x[k+5], S12,0x4787C62A); 
		c=FF(c,d,a,b,x[k+6], S13,0xA8304613); 
		b=FF(b,c,d,a,x[k+7], S14,0xFD469501); 
		a=FF(a,b,c,d,x[k+8], S11,0x698098D8); 
		d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF); 
		c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1); 
		b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE); 
		a=FF(a,b,c,d,x[k+12],S11,0x6B901122); 
		d=FF(d,a,b,c,x[k+13],S12,0xFD987193); 
		c=FF(c,d,a,b,x[k+14],S13,0xA679438E); 
		b=FF(b,c,d,a,x[k+15],S14,0x49B40821); 
		a=GG(a,b,c,d,x[k+1], S21,0xF61E2562); 
		d=GG(d,a,b,c,x[k+6], S22,0xC040B340); 
		c=GG(c,d,a,b,x[k+11],S23,0x265E5A51); 
		b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA); 
		a=GG(a,b,c,d,x[k+5], S21,0xD62F105D); 
		d=GG(d,a,b,c,x[k+10],S22,0x2441453); 
		c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681); 
		b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8); 
		a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6); 
		d=GG(d,a,b,c,x[k+14],S22,0xC33707D6); 
		c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87); 
		b=GG(b,c,d,a,x[k+8], S24,0x455A14ED); 
		a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905); 
		d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8); 
		c=GG(c,d,a,b,x[k+7], S23,0x676F02D9); 
		b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A); 
		a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942); 
		d=HH(d,a,b,c,x[k+8], S32,0x8771F681); 
		c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122); 
		b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C); 
		a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44); 
		d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9); 
		c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60); 
		b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70); 
		a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6); 
		d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA); 
		c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085); 
		b=HH(b,c,d,a,x[k+6], S34,0x4881D05); 
		a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039); 
		d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5); 
		c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8); 
		b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665); 
		a=II(a,b,c,d,x[k+0], S41,0xF4292244); 
		d=II(d,a,b,c,x[k+7], S42,0x432AFF97); 
		c=II(c,d,a,b,x[k+14],S43,0xAB9423A7); 
		b=II(b,c,d,a,x[k+5], S44,0xFC93A039); 
		a=II(a,b,c,d,x[k+12],S41,0x655B59C3); 
		d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92); 
		c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D); 
		b=II(b,c,d,a,x[k+1], S44,0x85845DD1); 
		a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F); 
		d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0); 
		c=II(c,d,a,b,x[k+6], S43,0xA3014314); 
		b=II(b,c,d,a,x[k+13],S44,0x4E0811A1); 
		a=II(a,b,c,d,x[k+4], S41,0xF7537E82); 
		d=II(d,a,b,c,x[k+11],S42,0xBD3AF235); 
		c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB); 
		b=II(b,c,d,a,x[k+9], S44,0xEB86D391); 
		a=AddUnsigned(a,AA); b=AddUnsigned(b,BB); c=AddUnsigned(c,CC); d=AddUnsigned(d,DD); 
	}
	if(bit==32)
	{
		return WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);
	}
	else
	{
		return WordToHex(b)+WordToHex(c);
	}
}

function getXMLHTTPRequest() 
{
	var xmlHttp = null;
	try {
		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e){
		try {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e2) {
			xmlHttp = false;
		}
	}
	
	if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
	  xmlHttp = new XMLHttpRequest();
	}
	
	return xmlHttp;
}

function getEl(id){
	return document.getElementById(id);
}

/*
function qpSortArray123(vay){
	var n = vay.length; 
	for (var i = 0; i < n - 1; i++) { 
		for (var j = 0; j < n - 1; j++) { 
			if (parseFloat(vay[j]) > parseFloat(vay[j + 1])) { 
				
				var aa = vay[j];
				vay[j] = vay[j + 1];
				vay[j + 1] = aa;
			} 
		} 
	} 
}

function qpSortArray321(vay){
	var n = vay.length; 
	for (var i = 0; i < n - 1; i++) { 
		for (var j = 0; j < n - 1; j++) { 
			if (parseFloat(vay[j]) < parseFloat(vay[j + 1])) { 
				
				var aa = vay[j];
				vay[j] = vay[j + 1];
				vay[j + 1] = aa;
			} 
		} 
	} 
}
*/


function getSelIds(theName){
	var ids = "";
	var obj = null;
	for(var i=0;i<document.all.length;i++){
		obj = document.all[i]
		if(obj.name==theName){
			if(obj.checked==true){
				ids += obj.value + ",";
			}
		}
	}
	if(ids!=""){
		ids = ids.substr(0,ids.length-1);
	}
	return ids;
}

function loadXML(xmlFile)
{
    var xmlDoc;
    if(window.ActiveXObject)
    {
        xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
        xmlDoc.async = false;
        xmlDoc.load(xmlFile);
    }
    else if (document.implementation&&document.implementation.createDocument)
    {
        xmlDoc = document.implementation.createDocument('', '', null);
        xmlDoc.load(xmlFile);
    }
    else
    {
        return null;
    }
    
    return xmlDoc;
}

function addEventHandler(oTarget, sEventType, fnHandler) {
    if (oTarget.addEventListener) {
        oTarget.addEventListener(sEventType, fnHandler, false);
    } else if (oTarget.attachEvent) {
        oTarget.attachEvent("on" + sEventType, fnHandler);
    } else {
        //oTarget["on" + sEventType] = fnHandler;
    }
}

//获取浏览器类型
function getBrowser(){
   if(navigator.userAgent.indexOf("MSIE")>0) { 
        return "IE"; 
   } 
   if(navigator.userAgent.indexOf("Firefox")>0){ 
        return "Firefox"; 
   } 
   if(navigator.userAgent.indexOf("Safari")>0){ 
        return "Safari"; 
   } 
   if(navigator.userAgent.indexOf("Camino")>0){ 
        return "Camino"; 
   } 
   if(navigator.userAgent.indexOf("Gecko")>0){ 
        return "Gecko"; 
   } 
}

function copy_clip(copy){
	if (window.clipboardData){
	window.clipboardData.setData("Text", copy);}
	else if (window.netscape){
	netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
	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 = new Object();
	var len = new Object();
	var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
	var copytext=copy;
	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);}
	//alert("Copy OK: "+copy)
	return false;
}

function selCheckBoxGroup(chkg, values, deli){
	values = deli + values + deli;
	
	for(var i=0; i<chkg.length; i++){
		//alert(values + " : " + deli + chkg[i].value + deli + " : " + values.indexOf(deli + chkg[i].value + deli));
		if (values.indexOf(deli + chkg[i].value + deli) >= 0){
			
			chkg[i].checked = true;
		}
		else{
			//chkg[i].checked = true;
		}
	}
}

function DateAdd(interval,number,date){
	switch(interval.toLowerCase()){
	
		case "y": return new Date(date.setFullYear(date.getFullYear()+number));
		case "m": return new Date(date.setMonth(date.getMonth()+number));
		case "d": return new Date(date.setDate(date.getDate()+number));
		case "w": return new Date(date.setDate(date.getDate()+7*number));
		case "h": return new Date(date.setHours(date.getHours()+number));
		case "n": return new Date(date.setMinutes(date.getMinutes()+number));
		case "s": return new Date(date.setSeconds(date.getSeconds()+number));
		case "l": return new Date(date.setMilliseconds(date.getMilliseconds()+number));
	} 
}

function fixTimeWidth(value){
	if (value.toString().length==1) value = '0' + value;
	return value;
}


//随机关键字生成方法(AS和JS里都可以使用)
function getRandomKeyID(len){
    if (len == undefined) {
        len = 6;
    }
    var keyID = "";
    var char_arr = new Array();
    char_arr.push(function () {
        return String.fromCharCode(48+Math.floor(Math.random()*10));
    });
    char_arr.push(function () {
        return String.fromCharCode(97+Math.floor(Math.random()*26));
    });
    char_arr.push(function () {
        return String.fromCharCode(65+Math.floor(Math.random()*26));
    });
    for (var i = 0; i<len; i++) {
        keyID += char_arr[Math.floor(Math.random()*char_arr.length)]();
    }
    return keyID;
}
//获取在两个数值之间(包含两个数值)的随机数方法(AS和JS里都可以使用)
function getRandomNumber(minNum,maxNum){
    if(minNum == undefined){
        minNum = 0;
        maxNum = 10;
    }else if(maxNum == undefined){
        maxNum = minNum;
        minNum = 0;
    }else if(maxNum < minNum){
        var tmpNum = maxNum;
        maxNum = minNum;
        minNum = tmpNum;
    }
    return Math.floor(Math.random()*(maxNum-minNum+1))+minNum;
}
//全字符串替换(AS和JS里都可以使用)
function replaceAll(str,oldStr,reStr){
    return str.split(oldStr).join(reStr);
}


function strToDate2(str)
{
  var val=Date.parse(str);
  var newDate=new Date(val);
  return newDate;
}

function strToDate(str)
{
  var arys= new Array();
  arys=str.split('-');
  var newDate=new Date(arys[0],arys[1],arys[2]); 
  return newDate;
} 

function fixWidth(num, width, fixwith){
	var rx = '';
	for(var i=1; i<=width-num.length; i++){
		rx += fixwith;
	}
	return rx + '' + num;
}

function updateUrlValue(url, name, newvalue, deli){
	if (url.length==0) return '';
	
	if (typeof(deli)=='undefined') deli = '&'
	
	rx = '';
	uy = url.split(deli);
	for (var i=0; i<uy.length; i++) {
		if (uy[i].indexOf('=')>-1) {
			tmpy = uy[i].split('=');
			if (tmpy[0]==name) {
				uy[i] = name + '=' + newvalue;
			}
		}
		rx += (rx.length==0 ? '' : deli) + uy[i];
	}
	
	return rx;
}

function convert_int(value, def_value) {
	if (typeof(def_value)=='undefined') def_value = 0;
	if (isInt(value)) {
		return parseInt(value);
	}
	else{
		return parseInt(def_value);
	}
}

function strToObj(str, deli, subdeli) {
	var tmpay = str.split(deli);
	var obj = {};
	for(var i=0; i<tmpay.length; i++) {
		if (tmpay[i].length>0) {
			var ay = tmpay[i].split(subdeli);
			obj[ay[0]] = ay[1];
		}
	}
	return obj;
}


function isMobile(val){
	var validfield=false;
	
	if (val.length==11){
		var re = /1\d{10}/;
		validfield = re.test(val);
	}
	
	return validfield;
}

function isCfg(cfg,key) {
	if (typeof(cfg)!='object') return false;
	if (typeof(cfg[key])!='undefined') {
		return true;
	}
	else{
		return null;
	}
}
function Cfg(cfg,key,default_value) {
	if (typeof(cfg)=='undefined') {
		if (typeof(default_value)!='undefined') {
			return default_value;
		}else{
			return null;
		}
	}
	if (isCfg(cfg,key)==null) {
		if (typeof(default_value)=='undefined') {
			return null;
		}
		else{
			return default_value;
		}
	}
	else{
		return cfg[key];
	}
}

function getXMLDom() {
	var _xmlDom = null;
	if (!window.DOMParser  && window.ActiveXObject){
		var arrXmlDomTypes = ['MSXML2.DOMDocument.6.0','MSXML2.DOMDocument.3.0','Microsoft.XMLDOM'];
		for(var i = 0;i<arrXmlDomTypes.length;i++){
			try{
				_xmlDom = new ActiveXObject(arrXmlDomTypes[i]);
			}catch(ex){}//不支持MSXML.XMLDOM对象的IE
		}
	}else{// Mozilla browsers have a DOMParser
		try{
			if(_xmlDom == null && document.implementation && document.implementation.createDocument){
				//_xmlDom = document.implementation.createDocument("","",null);
				_xmlDom = document.implementation.createDocument("text/xml", "", null);
	
				Document.prototype.loadXML = function(sXml){
					var oParser= new DOMParser();
					var _xmlDom = oParser.parseFromString(sXml, "text/xml");
	
					while(this.firstChild){
						this.removeChild(this.firstChild);
					}
	
					for(var i=0;i<_xmlDom.childNodes.length;i++){
						var oNewNode = this.importNode(_xmlDom.childNodes[i],true);
						this.appendChild(oNewNode);
					}
				}
	
				Element.prototype.__defineGetter__("text",function(){ return this.textContent; });
	
				Element.prototype.selectSingleNode=function(sXPath){
					var oEvaluator = new XPathEvaluator();
					var oResult = oEvaluator.evaluate(sXPath,this,null, XPathResult.FIRST_ORDERED_NODE_TYPE,null);
					if(null != oResult){
						return oResult.singleNodeValue;
					}
					return null;
				}
	
				Element.prototype.selectNodes = function(sXPath){
					var oEvaluator = new XPathEvaluator();
					var oResult = oEvaluator.evaluate(sXPath,this,null, XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);
					var aNodes = new Array();
					if(null != oResult){
						var oElement = oResult.iterateNext();
						while(oElement){
							aNodes.push(oElement);
							oElement = oResult.iterateNext();
						}
					}
					return aNodes;
				}
			}
			isIE = false;
		}catch (ex){}
	}
	return _xmlDom;
}
function GetNodeValue(objXmlElement)
{
    var str = "";
    if(window.XMLHttpRequest)        //Mozilla
    {
        try
        {
            str = objXmlElement.firstChild.nodeValue;
        }
        catch(ex)
        {
            str = "";
        }
    }
    else if(window.ActiveXObject)    //IE
    {
        str = objXmlElement.text;
    }
    return str;
}

/*  
    版本: 2008-12-24
    作用: 脚本跨域函数
必填参数: script_e, path_s, callback_f
*/
function ajaxCrossDomain(script_e, path_s, callback_f)
{
  if(typeof script_e==='string'){ script_e = document.getElementById(script_e); }
  if(!script_e){ document.body.appendChild( script_e = document.createElement('script') ); }
  if(!callback_f){ callback_f = function(){} };
  
  script_e.onload = 
  function()
  {
    callback_f()
  }
  
  script_e.onreadystatechange =
  function()
  {
    if(script_e.readyState=='loaded')
    {
      callback_f()
    }
  }  
  script_e.src = path_s;
}



//转换为UNIX时间戳
function strToTimestamp(datestr)
{
	var new_str = datestr.replace(/:/g,"-");
	new_str = new_str.replace(/ /g,"-");
	var arr = new_str.split("-");
	var datum = new  Date(Date.UTC(arr[0],arr[1]-1,arr[2],arr[3]-8,arr[4],arr[5]));

	return (datum.getTime()/1000);  //为PHP所用
}
//转换为UNIX时间戳
function strtotime (str, now) {
    // http://kevin.vanzonneveld.net
    // +   original by: Caio Ariede (http://caioariede.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: David
    // +   improved by: Caio Ariede (http://caioariede.com)
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Wagner B. Soares
    // +   bugfixed by: Artur Tchernychev
    // %        note 1: Examples all have a fixed timestamp to prevent tests to fail because of variable time(zones)
    // *     example 1: strtotime('+1 day', 1129633200);
    // *     returns 1: 1129719600
    // *     example 2: strtotime('+1 week 2 days 4 hours 2 seconds', 1129633200);
    // *     returns 2: 1130425202
    // *     example 3: strtotime('last month', 1129633200);
    // *     returns 3: 1127041200
    // *     example 4: strtotime('2009-05-04 08:30:00');
    // *     returns 4: 1241418600
 
    var i, match, s, strTmp = '', parse = '';

    strTmp = str;
    strTmp = strTmp.replace(/\s{2,}|^\s|\s$/g, ' '); // unecessary spaces
    strTmp = strTmp.replace(/[\t\r\n]/g, ''); // unecessary chars

    if (strTmp == 'now') {
        return (new Date()).getTime()/1000; // Return seconds, not milli-seconds
    } else if (!isNaN(parse = Date.parse(strTmp))) {
        alert('ddd');
    	return (parse/1000);
    } else if (now) {
        now = new Date(now*1000); // Accept PHP-style seconds
    } else {
        now = new Date();
    }

    strTmp = strTmp.toLowerCase();

    var __is =
    {
        day:
        {
            'sun': 0,
            'mon': 1,
            'tue': 2,
            'wed': 3,
            'thu': 4,
            'fri': 5,
            'sat': 6
        },
        mon:
        {
            'jan': 0,
            'feb': 1,
            'mar': 2,
            'apr': 3,
            'may': 4,
            'jun': 5,
            'jul': 6,
            'aug': 7,
            'sep': 8,
            'oct': 9,
            'nov': 10,
            'dec': 11
        }
    };

    var process = function (m) {
        var ago = (m[2] && m[2] == 'ago');
        var num = (num = m[0] == 'last' ? -1 : 1) * (ago ? -1 : 1);

        switch (m[0]) {
            case 'last':
            case 'next':
                switch (m[1].substring(0, 3)) {
                    case 'yea':
                        now.setFullYear(now.getFullYear() + num);
                        break;
                    case 'mon':
                        now.setMonth(now.getMonth() + num);
                        break;
                    case 'wee':
                        now.setDate(now.getDate() + (num * 7));
                        break;
                    case 'day':
                        now.setDate(now.getDate() + num);
                        break;
                    case 'hou':
                        now.setHours(now.getHours() + num);
                        break;
                    case 'min':
                        now.setMinutes(now.getMinutes() + num);
                        break;
                    case 'sec':
                        now.setSeconds(now.getSeconds() + num);
                        break;
                    default:
                        var day;
                        if (typeof (day = __is.day[m[1].substring(0, 3)]) != 'undefined') {
                            var diff = day - now.getDay();
                            if (diff == 0) {
                                diff = 7 * num;
                            } else if (diff > 0) {
                                if (m[0] == 'last') {diff -= 7;}
                            } else {
                                if (m[0] == 'next') {diff += 7;}
                            }
                            now.setDate(now.getDate() + diff);
                        }
                }
                break;

            default:
                if (/\d+/.test(m[0])) {
                    num *= parseInt(m[0], 10);

                    switch (m[1].substring(0, 3)) {
                        case 'yea':
                            now.setFullYear(now.getFullYear() + num);
                            break;
                        case 'mon':
                            now.setMonth(now.getMonth() + num);
                            break;
                        case 'wee':
                            now.setDate(now.getDate() + (num * 7));
                            break;
                        case 'day':
                            now.setDate(now.getDate() + num);
                            break;
                        case 'hou':
                            now.setHours(now.getHours() + num);
                            break;
                        case 'min':
                            now.setMinutes(now.getMinutes() + num);
                            break;
                        case 'sec':
                            now.setSeconds(now.getSeconds() + num);
                            break;
                    }
                } else {
                    return false;
                }
                break;
        }
        return true;
    };

    match = strTmp.match(/^(\d{2,4}-\d{2}-\d{2})(?:\s(\d{1,2}:\d{2}(:\d{2})?)?(?:\.(\d+))?)?$/);
    if (match != null) {
        if (!match[2]) {
            match[2] = '00:00:00';
        } else if (!match[3]) {
            match[2] += ':00';
        }

        s = match[1].split(/-/g);

        for (i in __is.mon) {
            if (__is.mon[i] == s[1] - 1) {
                s[1] = i;
            }
        }
        s[0] = parseInt(s[0], 10);

        s[0] = (s[0] >= 0 && s[0] <= 69) ? '20'+(s[0] < 10 ? '0'+s[0] : s[0]+'') : (s[0] >= 70 && s[0] <= 99) ? '19'+s[0] : s[0]+'';
        return parseInt(this.strtotime(s[2] + ' ' + s[1] + ' ' + s[0] + ' ' + match[2])+(match[4] ? match[4]/1000 : ''), 10);
    }

    var regex = '([+-]?\\d+\\s'+
        '(years?|months?|weeks?|days?|hours?|min|minutes?|sec|seconds?'+
        '|sun\\.?|sunday|mon\\.?|monday|tue\\.?|tuesday|wed\\.?|wednesday'+
        '|thu\\.?|thursday|fri\\.?|friday|sat\\.?|saturday)'+
        '|(last|next)\\s'+
        '(years?|months?|weeks?|days?|hours?|min|minutes?|sec|seconds?'+
        '|sun\\.?|sunday|mon\\.?|monday|tue\\.?|tuesday|wed\\.?|wednesday'+
        '|thu\\.?|thursday|fri\\.?|friday|sat\\.?|saturday))'+
        '(\\sago)?';

    match = strTmp.match(new RegExp(regex, 'gi')); // Brett: seems should be case insensitive per docs, so added 'i'
    if (match == null) {
        return false;
    }

    for (i = 0; i < match.length; i++) {
        if (!process(match[i].split(' '))) {
            return false;
        }
    }

    return (now.getTime()/1000);
}
//UNIX时间戳转换为字符串
function date(format, timestamp) {
	// http://kevin.vanzonneveld.net
	// +   original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com)
	// +      parts by: Peter-Paul Koch (http://www.quirksmode.org/js/beat.html)
	// +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   improved by: MeEtc (http://yass.meetcweb.com)
	// +   improved by: Brad Touesnard
	// +   improved by: Tim Wiel
	// +   improved by: Bryan Elliott
	// +   improved by: Brett Zamir (http://brett-zamir.me)
	// +   improved by: David Randall
	// +      input by: Brett Zamir (http://brett-zamir.me)
	// +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   improved by: Brett Zamir (http://brett-zamir.me)
	// +   improved by: Brett Zamir (http://brett-zamir.me)
	// +   improved by: Theriault
	// +  derived from: gettimeofday
	// +      input by: majak
	// +   bugfixed by: majak
	// +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +      input by: Alex
	// +   bugfixed by: Brett Zamir (http://brett-zamir.me)
	// +   improved by: Theriault
	// +   improved by: Brett Zamir (http://brett-zamir.me)
	// +   improved by: Theriault
	// +   improved by: Thomas Beaucourt (http://www.webapp.fr)
	// +   improved by: JT
	// +   improved by: Theriault
	// +   improved by: Rafał Kukawski (http://blog.kukawski.pl)
	// %        note 1: Uses global: php_js to store the default timezone
	// *     example 1: date('H:m:s \\m \\i\\s \\m\\o\\n\\t\\h', 1062402400);
	// *     returns 1: '09:09:40 m is month'
	// *     example 2: date('F j, Y, g:i a', 1062462400);
	// *     returns 2: 'September 2, 2003, 2:26 am'
	// *     example 3: date('Y W o', 1062462400);
	// *     returns 3: '2003 36 2003'
	// *     example 4: x = date('Y m d', (new Date()).getTime()/1000);
	// *     example 4: (x+'').length == 10 // 2009 01 09
	// *     returns 4: true
	// *     example 5: date('W', 1104534000);
	// *     returns 5: '53'
	// *     example 6: date('B t', 1104534000);
	// *     returns 6: '999 31'
	// *     example 7: date('W U', 1293750000.82); // 2010-12-31
	// *     returns 7: '52 1293750000'
	// *     example 8: date('W', 1293836400); // 2011-01-01
	// *     returns 8: '52'
	// *     example 9: date('W Y-m-d', 1293974054); // 2011-01-02
	// *     returns 9: '52 2011-01-02'
	var that = this,
	jsdate, f, formatChr = /\\?([a-z])/gi, formatChrCb,
	// Keep this here (works, but for code commented-out
	// below for file size reasons)
	//, tal= [],
	_pad = function (n, c) {
		if ((n = n + "").length < c) {
			return new Array((++c) - n.length).join("0") + n;
		} else {
			return n;
		}
	},
	txt_words = ["Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur",
	"January", "February", "March", "April", "May", "June", "July",
	"August", "September", "October", "November", "December"],
	txt_ordin = {
		1: "st",
		2: "nd",
		3: "rd",
		21: "st",
		22: "nd",
		23: "rd",
		31: "st"
	};
	formatChrCb = function (t, s) {
		return f[t] ? f[t]() : s;
	};
	f = {
		// Day
		d: function () { // Day of month w/leading 0; 01..31
			return _pad(f.j(), 2);
		},
		D: function () { // Shorthand day name; Mon...Sun
			return f.l().slice(0, 3);
		},
		j: function () { // Day of month; 1..31
			return jsdate.getDate();
		},
		l: function () { // Full day name; Monday...Sunday
			return txt_words[f.w()] + 'day';
		},
		N: function () { // ISO-8601 day of week; 1[Mon]..7[Sun]
			return f.w() || 7;
		},
		S: function () { // Ordinal suffix for day of month; st, nd, rd, th
			return txt_ordin[f.j()] || 'th';
		},
		w: function () { // Day of week; 0[Sun]..6[Sat]
			return jsdate.getDay();
		},
		z: function () { // Day of year; 0..365
			var a = new Date(f.Y(), f.n() - 1, f.j()),
			b = new Date(f.Y(), 0, 1);
			return Math.round((a - b) / 864e5) + 1;
		},

		// Week
		W: function () { // ISO-8601 week number
			var a = new Date(f.Y(), f.n() - 1, f.j() - f.N() + 3),
			b = new Date(a.getFullYear(), 0, 4);
			return 1 + Math.round((a - b) / 864e5 / 7);
		},

		// Month
		F: function () { // Full month name; January...December
			return txt_words[6 + f.n()];
		},
		m: function () { // Month w/leading 0; 01...12
			return _pad(f.n(), 2);
		},
		M: function () { // Shorthand month name; Jan...Dec
			return f.F().slice(0, 3);
		},
		n: function () { // Month; 1...12
			return jsdate.getMonth() + 1;
		},
		t: function () { // Days in month; 28...31
			return (new Date(f.Y(), f.n(), 0)).getDate();
		},

		// Year
		L: function () { // Is leap year?; 0 or 1
			var y = f.Y(), a = y & 3, b = y % 4e2, c = y % 1e2;
			return 0 + (!a && (c || !b));
		},
		o: function () { // ISO-8601 year
			var n = f.n(), W = f.W(), Y = f.Y();
			return Y + (n === 12 && W < 9 ? -1 : n === 1 && W > 9);
		},
		Y: function () { // Full year; e.g. 1980...2010
			return jsdate.getFullYear();
		},
		y: function () { // Last two digits of year; 00...99
			return (f.Y() + "").slice(-2);
		},

		// Time
		a: function () { // am or pm
			return jsdate.getHours() > 11 ? "pm" : "am";
		},
		A: function () { // AM or PM
			return f.a().toUpperCase();
		},
		B: function () { // Swatch Internet time; 000..999
			var H = jsdate.getUTCHours() * 36e2, // Hours
			i = jsdate.getUTCMinutes() * 60, // Minutes
			s = jsdate.getUTCSeconds(); // Seconds
			return _pad(Math.floor((H + i + s + 36e2) / 86.4) % 1e3, 3);
		},
		g: function () { // 12-Hours; 1..12
			return f.G() % 12 || 12;
		},
		G: function () { // 24-Hours; 0..23
			return jsdate.getHours();
		},
		h: function () { // 12-Hours w/leading 0; 01..12
			return _pad(f.g(), 2);
		},
		H: function () { // 24-Hours w/leading 0; 00..23
			return _pad(f.G(), 2);
		},
		i: function () { // Minutes w/leading 0; 00..59
			return _pad(jsdate.getMinutes(), 2);
		},
		s: function () { // Seconds w/leading 0; 00..59
			return _pad(jsdate.getSeconds(), 2);
		},
		u: function () { // Microseconds; 000000-999000
			return _pad(jsdate.getMilliseconds() * 1000, 6);
		},

		// Timezone
		e: function () { // Timezone identifier; e.g. Atlantic/Azores, ...
			// The following works, but requires inclusion of the very large
			// timezone_abbreviations_list() function.
			/*              var abbr = '', i = 0, os = 0;
			if (that.php_js && that.php_js.default_timezone) {
			return that.php_js.default_timezone;
			}
			if (!tal.length) {
			tal = that.timezone_abbreviations_list();
			}
			for (abbr in tal) {
			for (i = 0; i < tal[abbr].length; i++) {
			os = -jsdate.getTimezoneOffset() * 60;
			if (tal[abbr][i].offset === os) {
			return tal[abbr][i].timezone_id;
			}
			}
			}
			*/
			return 'UTC';
		},
		I: function () { // DST observed?; 0 or 1
			// Compares Jan 1 minus Jan 1 UTC to Jul 1 minus Jul 1 UTC.
			// If they are not equal, then DST is observed.
			var a = new Date(f.Y(), 0), // Jan 1
			c = Date.UTC(f.Y(), 0), // Jan 1 UTC
			b = new Date(f.Y(), 6), // Jul 1
			d = Date.UTC(f.Y(), 6); // Jul 1 UTC
			return 0 + ((a - c) !== (b - d));
		},
		O: function () { // Difference to GMT in hour format; e.g. +0200
			var a = jsdate.getTimezoneOffset();
			return (a > 0 ? "-" : "+") + _pad(Math.abs(a / 60 * 100), 4);
		},
		P: function () { // Difference to GMT w/colon; e.g. +02:00
			var O = f.O();
			return (O.substr(0, 3) + ":" + O.substr(3, 2));
		},
		T: function () { // Timezone abbreviation; e.g. EST, MDT, ...
			// The following works, but requires inclusion of the very
			// large timezone_abbreviations_list() function.
			/*              var abbr = '', i = 0, os = 0, default = 0;
			if (!tal.length) {
			tal = that.timezone_abbreviations_list();
			}
			if (that.php_js && that.php_js.default_timezone) {
			default = that.php_js.default_timezone;
			for (abbr in tal) {
			for (i=0; i < tal[abbr].length; i++) {
			if (tal[abbr][i].timezone_id === default) {
			return abbr.toUpperCase();
			}
			}
			}
			}
			for (abbr in tal) {
			for (i = 0; i < tal[abbr].length; i++) {
			os = -jsdate.getTimezoneOffset() * 60;
			if (tal[abbr][i].offset === os) {
			return abbr.toUpperCase();
			}
			}
			}
			*/
			return 'UTC';
		},
		Z: function () { // Timezone offset in seconds (-43200...50400)
			return -jsdate.getTimezoneOffset() * 60;
		},

		// Full Date/Time
		c: function () { // ISO-8601 date.
			return 'Y-m-d\\Th:i:sP'.replace(formatChr, formatChrCb);
		},
		r: function () { // RFC 2822
			return 'D, d M Y H:i:s O'.replace(formatChr, formatChrCb);
		},
		U: function () { // Seconds since UNIX epoch
			return jsdate.getTime() / 1000 | 0;
		}
	};
	this.date = function (format, timestamp) {
		that = this;
		jsdate = (
		(typeof timestamp === 'undefined') ? new Date() : // Not provided
		(timestamp instanceof Date) ? new Date(timestamp) : // JS Date()
		new Date(timestamp * 1000) // UNIX timestamp (auto-convert to int)
		);
		return format.replace(formatChr, formatChrCb);
	};
	return this.date(format, timestamp);
}
function qpDHanzi(strdata){
	return decodeURIComponent(strdata).replace(/\+/g," ");
}

