var jlib={
	$:function(qid){
		return document.getElementById(qid);
	},
	//create new element
	$CE:function(qel,qchild){
		var el;
		if ('string'==typeof qel) {
			el=document.createTextNode(qel);
		} else {
			el=document.createElement(qel.tag);
			delete(qel.tag);
	
			if ('undefined'!=typeof qchild) {
				for(var i=0; i<qchild.length; i++) {
					el.appendChild(qchild[i]);
				}
			}
			delete(qchild);
			for (attr in qel) {
				el[attr]=qel[attr];
			}
		}
		return el;
	},
	//delete element
	$DE:function(qid){
		var el=jlib.$(qid);
		if(el!=null){
			el.parentNode.removeChild(el);
		}
		el=null;
	},
	addClassName:function(qel,qclass){
		var el=jlib.$(qel);
		el.className=jlib.String.addOnce(el.className, qclass);
		el=null;
	},
	removeClassName:function(qel,qclass){
		var el=jlib.$(qel);
		el.className=jlib.String.remove(el.className, qclass);
		el=null;
	},
	$PreviousSibling:function(qel){
		var sibling=qel.previousSibling
		if(sibling.nodeType==3){
			sibling=jlib.$PreviousSibling(sibling);
		}
		return sibling
	},
	$NextSibling:function(qel){
		var sibling=qel.nextSibling
		if(sibling.nodeType==3){
			sibling=jlib.$NextSibling(sibling);
		}
		return sibling
	}
}
jlib.String={
	
	addOnce:function(qel,str){
		qel=(qel==undefined)?'':qel;
		if (qel.indexOf(str)!=-1) return qel;
		
		if (qel==''){
			return qel.concat(str);
		}else{
			return qel.concat(' '+str);
		}
	},
	remove:function(qel,str){
		
		if (qel.indexOf(str)==-1) return qel;
		return qel.split(' '+str).join('').split(str).join('');
	}
}