Object.prototype.dump = function(){
	var str = '';
	for(prep in this)str+= prep +" = "+ this[prep]+"\n";
	return str ;
}

String.prototype.ltrim = function ()
{
	var regx = /^[\s]+/g ;
	return this.replace(regx,"");
}
String.prototype.rtrim = function ()
{
	var regx = /[\s]+$/g ;
	return this.replace(regx,"");
}
String.prototype.trim = function ()
{
	return this.replace(/(^[\s]*)|([\s]*$)/g, "");
}
//get real length chinese charactor will be 2 char
String.prototype.realLength = function()
{
	return this.replace(/[^\x00-\xff]/g,"xx").length; 
}
//cut str
String.prototype.msubstr = function(iLen) 
{ 
    if(this.replace(/[^\x00-\xff]/g,"xx").length <= iLen)  return this; 
    var str = ""; 
    var l = 0; 
    var schar; 
    for(var i=0; schar=this.charAt(i); i++) 
    { 
        str += schar; 
        l += (schar.match(/[^\x00-\xff]/) != null ? 2 : 1); 
        if(l >= iLen) 
        { 
            break; 
        } 
    } 
    return str; 
}
//字串是否是中文
String.prototype.isChinese = function()
{
	return this.trim().match(/^[\u4e00-\u9fa5]+$/g) != null;
}


Date.prototype.toString = function()
{
	return this.getFullYear()+"-"+(this.getMonth()+1)+"-"+this.getDate()+" " + this.getHours()+":"+this.getMinutes()+":"+this.getSeconds()+" "+this.getMilliseconds();
}

Date.prototype.cloneDate = function()
{
	return  new Date(
					this.getFullYear(),this.getMonth(),this.getDate(),
					this.getHours(),this.getMinutes(),this.getSeconds() ,
					this.getMilliseconds()
				);
}

Date.prototype.parseString = function(dstr)
{
		//console.log(dstr);
		if(typeof(dstr)=='undefined' || dstr == '') return new Date();
		dstr = dstr.trim();
		var orgstr=dstr ;
		if(dstr.match(/^[0-9]+$/g))
		{
			var d = new Date();
			d.setTime(parseInt(dstr,10)*1000);
			return d; 
		}
		
		dstr = dstr.replace(/[\.\-/\s]+/g,':').replace(/[:]+/g,':');
		var vals = dstr.split(':');	
		
		var tmp, d =new Date();
		for(var i=0,j=vals.length;i<j;i++)
		{
			if(i>6)break;
			tmp =  parseInt(vals[i],10);
			if(!isNaN(tmp))
			{
				//console.log(tmp+"\n");
				switch(i)
				{
					case 0:d.setFullYear(tmp);break;
					case 1:{if(tmp >= 1 && tmp<=12)	d.setMonth(tmp-1);};break;
					case 2:{if(tmp >= 1 && tmp <=31) d.setDate(tmp);};break;
					case 3:{if(tmp >= 0 && tmp <= 23) d.setHours(tmp);};break;
					case 4:{if(tmp >= 0 && tmp <= 59) d.setMinutes(tmp);};break;
					case 5:{if(tmp >= 0 && tmp <= 59) d.setSeconds(tmp);};break;
					case 6:{if(tmp >= 0 && tmp <= 999) d.setMilliseconds(tmp);};break;
					default:{}
				}
			}
		}
		return d ;
}
//前置0
function formatInt (num , len)
{
	var s = new Number(num).toString();
	var z = len - s.length;
	for(var i=0;i<z;i++) s = '0'+s;
	return s;
}
// MInterval(function , 10 , arg1 ,arg2 ...)
function MInterval(funcName,time){
	var args=[];
	for(var i=2;i<arguments.length;i++){
		args.push(arguments[i]);
	}
   return window.setInterval(function(){funcName.apply(this,args);},time);
} 
///////////////////////////////////////////
function Request()
{
	var query=unescape(window.location.search);
	this.data=new Array();

	if(query!="") {
		query=query.substr(1);
		varStr=query.split('&');
		var data=new Array();
		var varid=0;
		for(var i=0;i<varStr.length;i++){		
			this.data[varid]=varStr[i].split('=');		
			varid++;
		}
	}

	this.get= function (varname)
	{
		var value="";
		for(var i=0;i<this.data.length;i++){
			//alert('Find:'+this.data[i][0]);
			if(this.data[i][0]==varname) {
				value=this.data[i][1];
			}
		}
		return value;
	}
	this.toString = function (){return window.location.search;}
}

//ui function
function selectItem(sel_id,value){
	var sel=document.getElementById(sel_id);
	var items=sel.options;
	for(var i=0;i<items.length;i++){
		if(items[i].value==value){
			items[i].style.color="#555";
			sel.options[i].selected=true;
		}
	}
}

//select multiitems
function selectMultiItems(sel_id,value){
	var sel=document.getElementById(sel_id);
	var items=sel.options;
	var values=value.split(',');
	for(var i=0,j=0;i<values.length;i++){
		for(;j<items.length;j++){
			if(items[i].value==value[i]){				
				sel.options[i].selected = true;
			}
		}
	}
}
//SELECT CHECK BOX
function selectCheckbox(sel_name,value)
{
	//if(value=="")return "";
	var values = value.split(",");
	var chkBoxes = document.getElementsByName(sel_name);
	for(var i=0;i<chkBoxes.length;i++)
	{
		for(var j=0;j<values.length;j++)
		{
			if(chkBoxes[i].value == values[j])
			{
				chkBoxes[i].checked=true;
			}
		}
	}
}
/**
 * Operate checkbox opValue= ALL|NONE|REV
 */
function operateCheckbox(sel_name , opValue)
{
	
	var checkboxes = document.getElementsByTagName("INPUT");
	var size = checkboxes.length;	
	sel_name = sel_name.toLowerCase();
	opValue = opValue.toLowerCase();
	for(var i=0 ;i<size;i++)
	{
		if(checkboxes[i].name.toLowerCase() != sel_name || checkboxes[i].type.toLowerCase() != 'checkbox') 
			continue;
		
		if(opValue == 'all')
		{
			checkboxes[i].checked = true ;
		}
		else if(opValue == 'none')
		{
			checkboxes[i].checked = false ;
		}else if(opValue == 'rev'){
			if(checkboxes[i].checked == true)	checkboxes[i].checked = false ;			
			else checkboxes[i].checked = true ;
		}
	}
}
//
function showConfirm(message,location){
	var doit=confirm(message);
	if(doit){
		window.location=location;
	}
}
//switch element' s id 
function showElement(elementId)
{
	var obj = document.getElementById(elementId);
	if(typeof(obj) != 'undefined')
	{
		var dsp = obj.style.display ;
		dsp = dsp.toLowerCase();
		if(dsp == "none")
			obj.style.display = "";
		else 
			obj.style.display = "None";
	}
}

function showDialog(url,width,height,handler){	

	if(typeof(width)=="undefined")
	{
		width = Math.floor(screen.width*0.8);
	}
	
	if(typeof(height)=="undefined")
	{
		height = Math.floor(screen.height*0.8);
	}
	
	if(typeof(handler)=="undefined")
	{
		handler = 'mfdlg';
	}
	
	var option="width="+width+",height="+height+",status=no,resizable=yes,scrollbars=yes";	
	var x=(screen.width-width)/2;
	var y=(screen.height-height)/2;
	if(x>0&&y>0){
		option+= ",top="+x+",left="+y;
	}	
	var obj=window.open(url,handler,option);
	
	obj.focus();
	obj.scrollTo(0,0);
	return obj;
}

function showWindow(url,width,height,handler){	

	if(typeof(width)=="undefined")
	{
		width = Math.floor(screen.width*0.8);
	}
	
	if(typeof(height)=="undefined")
	{
		height = Math.floor(screen.height*0.8);
	}
	
	if(typeof(handler)=="undefined")
	{
		handler = 'mfdlg2';
	}

	
	
	var option="width="+width+",height="+height+",scrollbars=yes,resizable=yes";	
	var x=(screen.width-width)/2;
	var y=(screen.height-height)/2;
	if(x>0&&y>0){
		option+= ",top="+x+",left="+y;
	}	
	var obj=window.open(url,handler,option);
	
	
	obj.focus();
	obj.scrollTo(0,0);
	return obj;
}






























