function strlen(str)
{
	var i;
	var len = 0;
	for (i=0;i<str.length;i++) if (str.charCodeAt(i)>255) len+=2; else len++;
	return len;
}
String.prototype.lenB = function(){return this.replace(/[^\x00-\xff]/g,"**").length;};
function checksearch(obj) {
	if (obj.keywords.value==""){
		alert("请输入搜索关键字.");
		obj.keywords.focus();
		return false;
	}
	if (obj.keywords.value.lenB()<2){
		alert("关键字不能少于2个字节.");
		obj.keywords.focus();
		return false;
	}
}
function $(o){return document.getElementById(o);}
function $s(i,a){$(i).style.display=a?'':'none';}
function hit(i){$(i).style.display=$(i).style.display=='block'?'none':'block';}
function lnet(a){$(a).innerHTML=$(a+'_code').innerHTML;$(a+'_code').innerHTML="";$(a+'_code').parentNode.removeChild($(a+'_code'));}
function setalpha(obj,o,a,s){if(!o) o=10;if(!a) a=5;if(!s) s=10;if(navigator.userAgent.indexOf("MSIE")>0){obj.style.filter='alpha(opacity:100)';obj.filters.alpha.opacity=o;var alphai = setInterval(function(){obj.filters.alpha.opacity+=a;if(obj.filters.alpha.opacity>=100)clearInterval(alphai);},s);}}
function getreq(url){
		if (window.XMLHttpRequest) { // Non-IE browsers
			req = new XMLHttpRequest();
			try {
				req.open("GET", url, false);
			} catch (e) {
				alert(e);
			}
			req.send(null);
		} else if (window.ActiveXObject) { // IE
			req = new ActiveXObject("Microsoft.XMLHTTP");
			if (req) {
				req.open("GET", url, false);
				req.send(null);
			}
		}
		return req;
}
function getCookie(name){
	var strCookies = document.cookie;
	var cookieName = name + "=";
	var valueBegin, valueEnd, value;
	valueBegin = strCookies.indexOf(cookieName);
	if (valueBegin == -1) return null;
	valueEnd = strCookies.indexOf(";", valueBegin);
	if (valueEnd == -1)
	valueEnd = strCookies.length;
	value = strCookies.substring(valueBegin+cookieName.length,valueEnd);
	return value;
}
function deleteCookie (name) 
{  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	var cval = getCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
function checkCookieExist(name){if (getCookie(name))return true;else return false;}
function setCookie (name, value) 
{
	var argv = setCookie.arguments;  
	var argc = setCookie.arguments.length;  
	var path = (argc > 2) ? argv[2] : "/";  
	var hours = (argc > 3) ? argv[3] : 24*365;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	deleteCookie (name);
	var expires = new Date((new Date()).getTime() + hours * 60 * 60 * 1000);
	document.cookie = name + "=" + value + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");

}

function yx99_top(sortid){
	var sorts = [
		[5, '休闲类'],
		[1, '策略类'],
		[7, '战争类'],
		[3, '敏捷类'],
		[6, '益智类'],
		[4, '体育类'],
		[2, '儿童类'],
		[8, '专辑类']
	];
	var tophtml = '<div id="top" onclick="document.location.href=\'http://www.yx99.com/?top\'"></div><div id="nav"><a href="http://www.yx99.com/">小游戏首页</a>';
	//var target = (document.body.id == "yx99_index")? ' target="_blank"':'';
	var target = "";
	for (var i=0; i<sorts.length; i++) {
		var style = (sortid == sorts[i][0])? ' class="current"':'';
		tophtml+=' | <a href="http://www.yx99.com/'+sorts[i][0]+'/"'+style+target+'>'+sorts[i][1]+'</a>';
	}
	tophtml+=' | <a href="http://www.2144.cn/html/127/"'+target+'>双人小游戏</a><a href="http://www.yx99.com/rss/'+(sortid>0?"?id="+sortid:"")+'" target="_blank" class="rss"><img src="http://www.yx99.com/images/yx99/rss.gif" alt="RSS订阅" /></a></div>';
	document.write(tophtml);
	if(document.body.id!='yx99_index' && document.body.id!='yx99_comment')document.write('<div style="margin-top:10px;"><script type="text/javascript" src="/javascript/mgame.js"></script></div>');
}
function ctb(){document.write('<button onclick="copyToClipBoard();" class="copybutton" title="点此复制标题和地址,直接粘贴即可^0^"></button><a id="qzonelink" href="#" target="_blank"></a>');}
function yx99_search_form(value,sortby){
	if(!value) value='';
	if(!sortby) sortby='';
	document.write('<div id="search">\
	<form name="flpage" id="flpage" action="http://www2.2144.cn/search.php" method="post" onsubmit="return checksearch(this)">\
			<input name="action" type="hidden" value="search" />\
			<input name="area" type="hidden" value="default" />\
			<input name="sortby" type="hidden" value="'+sortby+'" />\
			<input type="text" name="keywords" smartPid="yx99" id="smart_input" autocomplete="off" maxlength="40" class="kw" value="'+value+'" />\
			<input type="submit" class="sbt" value="搜 索" />\
		</form>\
	</div>');
}
if(document.all){self.moveTo(0,0);self.resizeTo(screen.availWidth,screen.availHeight);}
//document.write("<script src='http://line.2144.cn/server.js'></script>");