function o(id){
	return document.getElementById(id);
}
function $N(name){
	return document.getElementsByName(name);
}
Public={
	showDiv:function(id){
		o(id).style.display='';
	},
	hiddenDiv:function(id){
		o(id).style.display='none';
	},
	allSelect:function(choose) {//全选
		var ch =$N(choose);
		for (i = 0; i < ch.length; i++) {
			ch[i].checked = true;
		}
	},
	reverseSelect:function(choose) { //reverse select
	var	ch =$N(choose);
		for (i = 0; i < ch.length; i++) {
			ch[i].checked=ch[i].checked?false:true;
		}
	},
	cancelAllSelect:function(choose) {//取消全选
		ch = $N(choose);
		for (i = 0; i < ch.length; i++) {
			ch[i].checked = false;
		}
	},
	isSelectRow:function (choose) {//check one row is select
		var count = 0;
	   //alert(document.all(choose));
		//var ch =document.all(choose);
		var ch=document.getElementsByName(choose);
		for (i = 0; i < ch.length; i++) {
			if (ch[i].checked == false && ch[i].type=='checkbox') {
				count++;
				
			}
		}
		if (count == ch.length) {
			return false;
		}
		return true;
	},
	isInt:function(txt, str) {//check the text of value is null
		letter = new RegExp("\\d+");
		flag = txt.value.match(letter);
		if (flag == null) {
			//txt.value = "";
			return false;
		}else{
			return true;
		}
	},
	isEmpty:function(txt) {//check the text of value is null
		if (txt.value.replace(/^ +| +$/g, "") == "") {
			return true;
		}
	},getCheckValue:function(ids){
		var pars='';
		var ch=document.getElementsByName(ids);
		 for(i=0;i<ch.length;i++){
		 	if(ch[i].checked==true && ch[i].type=='checkbox'){
		 		pars+='ids='+ch[i].value+'&';
		 	}
		 }
		 pars=pars.substring(0,pars.length-1);
		 return pars;
	}
}

function showWin(url,w,h){
var w;
w=window.open(url, 'window', 'width='+w+',height='+h+',top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
return w;
}


function showLight(obj){
	//obj.style.backgroundColor='E3ECF3';
}
function offLight(obj){
	//obj.style.backgroundColor='';
}



function toDateString(date){
  if(date!=null &&  date!=''){
  	return date.substring(0,10);
  }else{
  	return "&nbsp;";
  }
}

function toDateString1(date){
  if(date!=null &&  date!=''){
  	return date.substring(0,19);
  }else{
  	return "&nbsp;";
  }
}

function replaceNull(str){
	if(str!=null &&  str!=''){
  	return str;
  }else{
  	return "&nbsp;";
  }
}


function setOptionSelected(id,txt){
	var op=document.getElementById(id);
	for(o=0;o<op.options.length;o++){
		if(op.options[o].text==txt){
			op.options[o].selected=true;
			return;
		}
	}
}


function setOptionValSelected(id,txt){
	var op=document.getElementById(id);
	for(o=0;o<op.options.length;o++){
		if(op.options[o].value==txt){
			op.options[o].selected=true;
			return;
		}
	}
}

function getNewStr(str){
    var ss='';
	if(str!=null){
		for(var s=0;s<str.length;s++){
			if(str.charAt(s)!=' '){
				ss+=str.charAt(s);
			}
		}
	}
	return ss;
}

var Hash = function(h){    
    this._data = new Object();
}
    function Hash$clear(){
        delete this._data;
        this._data = new Object();    
    }        
    function Hash$add(key,value){
        if(!key || typeof(value) === 'undefined') return false;                
        this._data[key] = {key: key,value: value};
        return true;
    }
    function Hash$addRange(h){
        for(var key in h._data){
            var item = h._data[key];
            if(typeof(item) !== 'undefined'){
                this.add(item.key,item.value);
            }
        }
    }
    function Hash$remove(key){
        if(!key) return undefined;
        var item = this._data[key];    
        delete this._data[key];
        return item;
    }
    function Hash$removeAt(index){
        if(isNaN(index)) return undefined;
        var i = 0;        
        for(var key in this._data){
            if(i == index){
                return this.remove(key);
            }
            i++;
        }
        return undefined;
    }
    function Hash$removeRange(startIndex,endIndex){
        if(isNaN(startIndex) || isNaN(endIndex)) return undefined;
        var i = 0;
        var h = new Hash();
        for(var key in this._data){
            if(i >= startIndex && i<= endIndex){
                h.add(key,this.remove(key).value);
            }
            i++;
        }
        return h;
    }    
    function Hash$getCount(){
        var i = 0;
        for(var key in this._data) i++;       
        return i;
    }
    function Hash$forEach(method,instance){
        var i = 0;
        for(var key in this._data){
            var item = this._data[key];
            if(typeof(item) !== 'undefined'){
                method.call(instance, item, i, this);
                i++;
            }else{
                delete this._data[key];
            }
        }
    }
    function Hash$getKeys(){
        var arr = new Array();
        for (var key in this._data){
            var item = this._data[key];
            arr.push(item.key);
        }
        return arr;
    }
    function Hash$getValues(){
        var arr = new Array();
        for (var key in this._data){
            var item = this._data[key];
            arr.push(item.value);
        }
        return arr;        
    }
    function Hash$getItem(key){
        if(!key) return undefined;
        var item = this._data[key];
        if (typeof(item) !== 'undefined'){
            return item;                        
        }else{
            delete this._data[key];
            return undefined;
        }        
    }
    function Hash$containsKey(key){        
        if(typeof(this.getItem(key)) !== 'undefined'){
            return true;
        }
        return false;
    }
    function Hash$containsValue(value){
        for(var key in this._data){        
            if(value === this._data[key].value){
                return true;
            }
        }
        return false;    
    }
Hash.prototype = {
    _data : null,
    _keys : null,
    clear : Hash$clear,
    add : Hash$add,
    addRange : Hash$addRange,
    remove : Hash$remove,
    removeAt : Hash$removeAt,
    removeRange : Hash$removeRange,
    getCount : Hash$getCount,
    forEach : Hash$forEach,
    getKeys : Hash$getKeys,
    getValues : Hash$getValues,
    getItem: Hash$getItem,
    containsKey: Hash$containsKey, 
    containsValue: Hash$containsValue
}
Hash.__typeName = 'Hash';
Hash.__class = true;
