function TtSpacePub(){
	this.isIE=function(){
		return (window.navigator.userAgent.indexOf("MSIE")>=1);
	};
	/*
	判断文字是否为空
	*/
	this.isEmpty=function(str){
		if(!str||str.length==0)
			return true;
		
		return false;
	}

	this.$=function(tag){
		return document.getElementById(tag);
	}

	this.ele=function(tag,cid){
		var t=document.createElement(tag);
		if(cid){
			t.setAttribute("id",cid);
		}
		return t;
	}


	this.remove=function(id){
		var removeid=null;
		if(typeof(id)=='string'){
			removeid=this.$(id);
		}else{
			removeid=id;
		}
		if(removeid){	
			removeid.parentNode.removeChild(removeid);
		}
	}


	/**
	判断是否是数字
	**/
	this.checkInt=function(txt){
		var reg=/\d+$/;
		return reg.test(txt);
	}

	this.getRadioCheck=function(cid){
		var array=document.getElementsByName(cid);
		var value="NaN";
		if(array){
			for(var i=0;i<array.length;i++){
				if(array[i].checked){
					value=i;
					break;
				}
			}
		}
		return value;
	}

	this.getRadioCheckValue=function(cid){
		var v=this.getRadioCheck(cid)
		if(v=='NaN'){
			return null;
		}
	
		var array=document.getElementsByName(cid);
		
		return array[v].value;
	};
	this.hasObject=function(cid){
		return (typeof(cid)=='object');
	}
	this.getValue=function(cid){
	//alert("222222222222");
		if(!this.hasObject(cid))
			cid=this.$(cid);
			
		if(cid.tagName.toLowerCase()=='input'){
			if(cid.type=='text'){
				return cid.value;
			}else{
				return null;
			}
		}else{		
			return cid.innerHTML;
		}
	}

	this.setText=function(cid,value){
		if(!cid)return;
		if(!this.hasObject(cid))
			cid=this.$(cid);
		if(this.isIE()){	
			cid.innerText=value;
		}else{
			cid.textContent=value;
		}	
	}
	
	this.setHtml=function(cid,value){
		if(!this.hasObject(cid))
			cid=this.$(cid);

		cid.innerHTML=value;
	}

	this.setValue=function(cid,value){
		if(typeof(cid)=='string'){
			cid=this.$(cid);
		}
		if(this.isIE()){
			cid.value=value;
		}else{
			cid.setAttribute("value",value)
		}
	}
	this.show=function(cid){
		var id=cid;
		if(typeof(cid)=='string'){
			id=this.$(cid);
		}
		if(id){
			id.style.display="block";
		}
	}
	this.hide=function(cid){
		var id=cid;
		if(typeof(cid)=='string'){
			id=this.$(cid);
		}
		if(id){
			id.style.display="none";
		}
	}

	this.selectedAllCheckbox=function(c_name,check){
		var checks=document.getElementsByName(c_name);
		if(checks){
			for(var i=0;i<checks.length;i++){
				checks[i].checked=check;
			}
		}
	}

	this.getCheckBoxValue=function(c_name){
		var checks=document.getElementsByName(c_name);
		var array=new Array();
		if(checks){		
			for(var i=0;i<checks.length;i++){
				if(checks[i].checked){
					array.push(checks[i].value);
				}
			}		
		}
		if(array==null||array.length==0)
			return null;
			
		return array;
	}
	this.selectedValue=function(c_name){
		return c_name.options[c_name.selectedIndex].value;
	}
	
	this.getLeft=function(ObjectID){
	var iPositionX=ObjectID.offsetLeft;
	while(ObjectID=ObjectID.offsetParent)
	{
		iPositionX+=ObjectID.offsetLeft;
	}
	return iPositionX;
}

this.getTop=function(ObjectID){
	var iPositionY=ObjectID.offsetTop;
	while(ObjectID=ObjectID.offsetParent)
	{
   		iPositionY+=ObjectID.offsetTop;
	}
	return iPositionY;
}

this.setStyle=function(cid,value){
	if(typeof(cid)=='string'){
		cid=this.$(cid);
	}
	if(this.isIE()){
		cid.style.cssText=value;
	}else{
		cid.setAttribute("style",value);
	}
}
}
var ttspace=new TtSpacePub();
