function $(id){
	var res = document.getElementById(id);
	if(res==undefined || res== null){
		try{
			res = document.getElementsByName(id)[0];		
		}catch(e){
			return null;
		}
	}
	return res;
}

function createCheckboxButtons(ele,name){   
    
      var checkbox = document.createElement("span");
      var input = createElement("input", name);    
      input.setAttribute("type","checkbox");   
      input.setAttribute("value",ele.id);   
      checkbox.appendChild(input);   
      checkbox.appendChild(document.createTextNode(" "+ele.name+" ")); 
      return checkbox;   
}   
  
function createElement(type, name) {   
   var element = null;   
  
   try {   
      element = document.createElement('<'+type+' name="'+name+'">');   
   } catch (e) {   
   }   
   if (!element) {   
      element = document.createElement(type);   
      element.name = name;   
   }   
   return element;   
}      

function getComboxValue(id){
	var selectNode=$(id);
	if(!selectNode){
		return "";
	}
	var index=selectNode.selectedIndex;
	var options=selectNode.options;
	if(!options||index==-1||index>=options.length){
		return "";
	}
	var combox=options[index];
	return combox.value;
}

function setComboxValue(id,arr){	
	var selectNode=$(id);
	if(!selectNode){
		return;
	}
	if((!arr)||arr.length<1){
		return;
	}
	//clear		
	while(selectNode.hasChildNodes()){
		selectNode.removeChild(selectNode.firstChild);
	}
	//add
	var option,txt;
	var elem=null;
	for(var i=0;i<arr.length;i++){
		elem=arr[i];
		if(elem){
			option=creatOption(elem.id,elem.name);
			selectNode.appendChild(option);
		}				
	}
}

function creatOption(value,txt){
	var option,inner;
	option=document.createElement("option");
	option.value=value;
	inner=document.createTextNode(txt);
	option.appendChild(inner);
	return option;
}

function showmsg(type,msg,focusId,showMsgId)//0 text  1 select
{
	if( type==null || type==undefined )
	{
		type=0;
	}
	alert(msg);
	if( type==0 )
	{
		$( focusId ).focus();
	}
}