function $(i) {
	return document.getElementById(i)
}

function dc(t) {
	return document.createElement(t)
}
function cs() {
	document.write("<img id=s1616 src=about:blank style='display:none'>")
}

function s1616(u) {
	$('s1616').src = "http://st.1616.net/" + u;
	return true
}

function els(i, t) {
	return $(i).getElementsByTagName(t)
}

function setCookie(k, v, opt){
	var val = encodeURIComponent(v);
	if(!opt) opt = {duration:365};
	if(opt && opt.duration){
		var d = new Date();
		d.setTime(d.getTime() + opt.duration*24*3600*1000);
		val += ';expires=' + d.toGMTString();
	}
	document.cookie = k + '=' + val + ';';
}

function getCookie(k){
	var c = document.cookie.split("; "); 
	for(var i=0; i<c.length; i++) { 
		var p = c[i].split("="); 
		if(k == p[0]) 
			try{
				return decodeURIComponent(p[1])
			}catch(e){return null} 
		} 
	return null;
}

function ajax(url, callback, tk){
	var xhr = (window.XMLHttpRequest) ? new XMLHttpRequest() : (document.all ? new ActiveXObject('Microsoft.XMLHTTP') : null);
	if(!xhr){callback(null, tk);
	return null;
	}
	xhr.open('GET', url, true);
	xhr.onreadystatechange = function(ev) {
		if(xhr.readyState != 4) return;
		if((xhr.status >= 200) && (xhr.status < 300))callback(xhr.responseText, tk);
		else callback(null, tk)
		};
	try{xhr.send(null)}catch(e){}
	return xhr;
}

function gb2312(key) {
	var r = ""; 
	for(var i=0;i<key.length;i++)
	{ 
		var t = key.charCodeAt(i);
		if(t>=0x4e00 || t==0x300A || t==0x300B){ 
		try{execScript("ascCode=hex(asc(\""+key.charAt(i)+"\"))", "vbscript"); r += ascCode.replace(/(.{2})/g, "%$1"); }catch(e){}
		}else{r += escape(key.charAt(i))} 
	} 
	return r; 
}

function set_home(o, url) {
	if(document.all){
		o.target = "_self";
		o.style.behavior = "url(#default#homepage)";
		o.setHomePage(url);
	}else{
		o.target = "_search";
		try { 
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
			var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
			prefs.setCharPref('browser.startup.homepage', url);
		} catch (e) {}
	}
}