slib={
	UA_MSIE   :0x01,
	UA_FIREFOX:0x02,
	UA_OPERA  :0x04,
	UA_CHROME :0x08,
	UA_SAFARI :0x10,
	UA_UNKNOWN:0x20,
	//UserAgent type
	UA:(function(){
		var ua=window.navigator.userAgent.toLowerCase();
		var str=["msie","firefox","opera","chrome","safari"];
		for(var i=0;i<str.length;i++){
			if (ua.indexOf(str[i]) > -1){return (0x01<<i);}
		}
	}()),
	getUrlQuery:function (s){
    	var p =new Array();
    	var hs = (s.indexOf('?')<0) ? new Array(): ((s.split('?'))[1].split('#'))[0].split('&');
    	for(var i = 0; i <hs.length; i++){
        	var n=hs[i].split('=');
        	p[n[0]] = n.length>0?n[1]:null;
    	}
    	return p;
    },
	getPath:function (s){
    	return (s.indexOf('?')<0)?((s.indexOf('#')<0)?s:s.split('#')[0]):s.split('?')[0];
	},
	downloadAsFile:function(fn,c)
	{
		if((this.UA & (this.UA_FIREFOX|this.UA_CHROME))!=0){
			var blob = new Blob([c]);
			var blobURL = (window.URL || window.webkitURL).createObjectURL(blob);
			var a = document.createElement('a');
			a.download = fn;
			a.href = blobURL;
    		var evt = document.createEvent("MouseEvents");
    		evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0,a);
    		a.dispatchEvent( evt );
    	}else{
			var p = window.open("", "", "width=400,height=200");
			p.document.open();
			p.document.write(
			'<html><body><center>Please right-click a link and save a file.<br/><br/>'+
			'<a href="data:application/octet-stream,'+encodeURIComponent(c)+'" alt="'+fn+'">Download File</a>'+
			'</center></body></html>');
			p.document.close();
    	}
	},
	strtrim:function(s){return s.replace(/^\s+|\s+$/g, "")},
	xhr:function(i_url,i_cb,i_method,i_data)
	{
		var x = XMLHttpRequest ?  new XMLHttpRequest():new XDomainRequest();
    	if(i_cb!=undefined){
    		x.onreadystatechange = function(){
				if (x.readyState == 4){
					i_cb(x);
				}
			}
    	}else{
    		x.onreadystatechange = function(){};
    	}
        x.open(i_method==undefined?"GET":i_method,i_url,false);
    	try{
    		x.setRequestHeader('Content-Type',"text/plain");
    	}catch(e){
    		alert(e);
    	}
        x.send(i_data==undefined?null:i_data);
	    return x;
	}
}

