function $(id)
{ 
	try
	{
		return document.getElementById(id);
	}catch(ex)
	{
		try
		{
			return document.getElementsByName(id);
		}
		catch(ex){return null;}
	}
}
var Class = {
  create: function() {
    return function() {
      this.initialize.apply(this, arguments);
    }
  }
};
var Browser={
    IE:!!(window.attachEvent && !window.opera),
    Opera:  !!window.opera,
    WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
    Gecko:  navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1,
    MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/),
    Firefox:navigator.userAgent.indexOf('Firefox/') > 0
  };
/* 包含中文的字符长度 */
String.prototype.StrLength=function()
{
	var chineseRegex = /[^\x00-\xff]/g; 
	return this.replace(chineseRegex,"**").length;   
};
/* 截取字符串，*/
String.prototype.sub=function(len, hasDot)  
{  
		var str=this;
    var newLength = 0;  
    var newStr = "";  
    var chineseRegex = /[^\x00-\xff]/g;  
    var singleChar = "";  
    var strLength = str.replace(chineseRegex,"**").length;  
    for(var i = 0;i < strLength;i++)  
    {  
        singleChar = str.charAt(i).toString();  
        if(singleChar.match(chineseRegex) != null)  
        {  
            newLength += 2;  
        }      
        else  
        {  
            newLength++;  
        }  
        if(newLength > len)  
        {  
            break;  
        }  
        newStr += singleChar;  
    }  
    if(hasDot && strLength > len)  
    {  
        newStr += "...";  
    }  
    return newStr;  
};

String.prototype.left=function(n)
{
	return this.substr(0,n);
};

String.prototype.right=function(n)
{
	return this.substr(this.length-n);
};
if (!('trim' in String.prototype))
{
	String.prototype.trim = function()
	{
		return this.replace(/(^\s*)|(\s*$)/g, ""); 
	}
};
/* 是否为数字 */
String.prototype.isNumber=function()
{
	var re = /^[0-9]+.?[0-9]*$/;
	return re.test(this);
};
/* 是否为整数 */
String.prototype.isInteger=function() 
{
	var re = /^\+?[0-9]*$/;
	return re.test(this);
};
/* 字符补位 */
String.prototype.incstr=function(s,l)
{
	var tmp=this;
	for(var i=tmp.length;i<l;i++)
	{
		tmp=s+""+tmp;
	}
	return tmp;
};

function DateDiff(sDate1,  sDate2){
	var  aDate,  oDate1,  oDate2,  iDays;
	aDate  =  sDate1.split("-");
	oDate1  =  new  Date(aDate[1]  +  '-'  +  aDate[2]  +  '-'  +  aDate[0]);
	aDate  =  sDate2.split("-");
	oDate2  =  new  Date(aDate[1]  +  '-'  +  aDate[2]  +  '-'  +  aDate[0]);
	iDays  =  parseInt(Math.abs(oDate1  -  oDate2)  /  1000  /  60  /  60  /24);
	return  iDays;
}
/* 格式化日期与时间 */
Date.prototype.toString=function(t)
{
	if(t)
	{
		var dt=new Date();
		var tmp="";
		t=t.replace(/day/g,this-dt);
		t=t.replace(/age/g,dt.getFullYear()-this.getFullYear());
		t=t.replace(/yyyy/g,this.getFullYear());
		t=t.replace(/MM/g,String(this.getMonth()+1).incstr('0',2));
		t=t.replace(/M/g,this.getMonth()+1);
		t=t.replace(/dd/g,String(this.getDate()).incstr('0',2));
		t=t.replace(/d/g,this.getDate());
		t=t.replace(/HH/g,String(this.getHours()).incstr('0',2));
		t=t.replace(/H/g,this.getHours());
		t=t.replace(/mm/g,String(this.getMinutes()).incstr('0',2));
		t=t.replace(/m/g,this.getMinutes());
		t=t.replace(/ss/g,String(this.getSeconds()).incstr('0',2));
		t=t.replace(/s/g,this.getSeconds());
		t=t.replace(/w/g,this.getDay());
		return t;
	}else return this.getFullYear()+"-"+(this.getMonth()+1)+"-"+this.getDate();
};
Function.prototype.bindAsEventListener = function(object) {
  var __method = this;
  return function(event) {
    return __method.call(object, event || window.event);
  }
};
/* */

Number.prototype.format = function(format) {
if (typeof(format)!='string') {return "";}
var hasComma = -1 < format.indexOf(',');
var psplit = format.split('.');
that = this;
if (1<psplit.length)
{
	that = that.toFixed(psplit[1].length);
}
else if (2<psplit.length) {
	throw('NumberFormatException: invalid format, formats should have no more than 1 period: ' + format);
}
else
{
	that = that.toFixed(0);
}
var fnum = that.toString();
if(hasComma)
{
	psplit = fnum.split('.');
	var cnum = psplit[0],
	parr = [],
	j = cnum.length,
	m = Math.floor(j / 3),
	n = cnum.length % 3 || 3; 
	for (var i = 0; i < j; i += n)
	{
		if (i != 0) {n = 3;}
		parr[parr.length] = cnum.substr(i, n);
		m -= 1;
	}
	fnum = parr.join(',');
	if (psplit[1]) {fnum += '.' + psplit[1];}
}
return format.replace(/[d,?.?]+/, fnum);
};

function open_window(url,name,para)
{
	
	
	window.open(url,name,para);	
	
	
	
}
var cookieString=document.cookie;
var start=cookieString.indexOf("cookiesleep");
if(start!=-1)
{
	
	
	
}else 
{
	
	var expires=new Date();
	
	expires.setTime(expires.getTime()+24*60*60*1000);
	
	document.cookie="cookiesleep=test;expires="+expires.toGMTString();
		
}

