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);}
		}
	}()),
	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, "")}
}

