fulldomain = document.domain;
domain=fulldomain.substring(fulldomain.indexOf('.')+1,fulldomain.length);

String.prototype.len=function(){   
  var str=this;   
  return  this.replace(/[^\x00-\xff]/g,'**').length   
}

String.prototype.trim = function() {
    return this.replace(/(^\s+)|(\s+$)/g, "");
}

String.prototype.format = function(){
	var arg = arguments;	
	return this.replace(/\{(\d+)\}/g, function(m, i){
		return arg[i];
	});
}

function g(id){
	return  document.getElementById(id);
}

function getSampleDate(){
	var date = new Date(); 
	return date.getYear()+"-"+(date.getMonth() + 1)+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
}

function getDate(){	
	var date = new Date();
	return date.getYear()+"-"+(date.getMonth() + 1)+"-"+date.getDate();
}

function writeCookie(name,para,path ,expires,d){
	if(!path)
		path = "/";
	if(!expires)
		expires  = "Fri, 31 Dec 2099 0:0:0 GMT";
	if(!d)
		d = domain;
	document.cookie = name+"="+escape(para) +";path="+ path + "; expires=" + expires+" ; domain="+d;
}

function getCookie(sName){
// cookies are separated by semicolons
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++){
	// a name/value pair (a crumb) is separated by an equal sign
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0])
		return unescape(aCrumb[1]);
	}
// a cookie with the requested name does not exist
	return null;
}
// Delete the cookie with the specified name.
function delCookie(sName){
	document.cookie = sName + "=-1" + "; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}
/**
*判断是否为IE
*/
var isIE=function(){
	if(window.navigator.appName.indexOf("Microsoft")!=-1)
		return true;
	else
		return false;
}

function XMLRequst(purl,method,asy){
	if(typeof method =='undefined') method = 'get';	
	if(typeof asy =='undefined') asy = true;	
	
	this.http_request = false;
	this.url=purl;
	this.createXMLRequst = function(){
			//开始初始化XMLHttpRequest对象
		if(window.XMLHttpRequest) { //Mozilla 浏览器
			this.http_request = new XMLHttpRequest();
			if (this.http_request.overrideMimeType) {//设置MiME类别
				this.http_request.overrideMimeType("text/xml");
			}
		}
		else if (window.ActiveXObject) { // IE浏览器
			try {
				this.http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {				
					this.http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		if(!this.http_request) { // 异常，创建对象实例失败
			throw new Error("不能创建XMLHttpRequest对象实例.");
			return null;
		}
		this.http_request.open(method,this.url,asy);
		return this.http_request;
	}
}