//a modification of a nifty implementation of importnode, from http://neo.dzygn.com/archive/id/56
if(!document.importNode){
	document.importNode = function(oNode, bImportChildren){
		var oNew;
		if(oNode.nodeType == 1){
			oNew = document.createElement(oNode.nodeName);
    		for(var i = 0; i < oNode.attributes.length; i++){
			    if(oNode.attributes[i].value == 'null' || oNode.attributes[i].value == '' ||
			    oNode.attributes[i].value == null)continue;
			    switch(oNode.attributes[i].name){
			        case 'onclick':		         
			            oNew.onclick =oNode.onclick;
			            break;
			        case 'onchange':
			            oNew.onchange = oNode.onchange;
			            break;
			        case 'onmouseover':
			            oNew.onmouseover = oNode.onmouseover;
			            break;
			        case 'class':
			            oNew.className = oNode.className;
			            break;
		            case 'src':			            
		            case 'type':
                    case 'id':
                    case 'sel'://extended attribute, used for determining if an element is selected
                    case 'sselect'://extended attribute, used for determining if elements in a list are single/multi select
			        case 'value':
			            oNew.setAttribute(oNode.attributes[i].name, oNode.attributes[i].value);
			            break;
			        default:
			            //ie does weird things when importing all attributes.  doing it on a case by case basis
			        break;
			    }			
			}
			oNew.style.cssText = oNode.style.cssText;
		} else if(oNode.nodeType == 3){
			oNew = document.createTextNode(oNode.nodeValue);
		}	
		if(bImportChildren && oNode.hasChildNodes()){	
			for(var oChild = oNode.firstChild; oChild; oChild = oChild.nextSibling){
				oNew.appendChild(document.importNode(oChild, true));
			}
		}
		return oNew;
	}
}