/*
 * jQuery JavaScript Library v1.3.2
 * 试玩网公共的JS 
 * www.shiwan.com 
 */
 
 // 引用游戏智能搜索js文件
	document.write(unescape("%3Cscript language='javascript' src='http://www.shiwanjs.cn/js/jquery.autocomplete.js'%3E%3C/script%3E"));
 
 
 // 试玩网各页面选项卡的JS 公共 start------------------------------------------------------
 
// 编辑内容组专用选项卡JS
function editorTab(thisObj,Num){
	if(thisObj.className == "active")return;
	var tabObj = thisObj.parentNode.id;
	var tabList = document.getElementById(tabObj).getElementsByTagName("li");
	for(i=0; i <tabList.length; i++)
	{
		if (i == Num)
		{
		   thisObj.className = "active";
			  document.getElementById(tabObj+"_content"+i).style.display = "block";
		}else{
		   tabList[i].className = "normal";
		   document.getElementById(tabObj+"_content"+i).style.display = "none";
		}
	}
}
// ajax取游戏数量
function getGameNum(){
	var gameIds = document.getElementById("gameIds").value;
	//var ArrayIds = gameIds.split(",");
	var url = "/ajaxgameaccountsum/index/ids";
	$.ajax({
		type: "post",
		url: url,
		data :{ids:gameIds,format:"html"},
		success: function(data, textStatus){
			data = eval("("+ data +")");
			for (var key in data){
				var numId = "#numId_"+key;
				$(numId).html(data[key]);
				//document.getElementById("numId_"+ArrayIds[i-1]).innerHTML = data[ArrayIds[i-1]];
			}
		}
	});	
}
// 显示隐藏游戏区服列表
function showGameList(num){
	if (num == 1){
		var listHtml = $("#gamelist_type_1").html()
		//$("#gamelist_type_1").hide();
		//$("#gamelist_type_2").html(listHtml);
		$("#gamelist_type_2").show();
		$(".type_more").html("<a onclick='showGameList(0);'><img src='http://www.shiwanimg.cn/images/order_arrow_up.gif' border='0' /> 显示部分分类</a><div class='clear'></div>");
	}
	if (num == 0){
		$("#gamelist_type_2").hide();
		//$("#gamelist_type_1").show();
		$(".type_more").html("<a onclick='showGameList(1);'><img src='http://www.shiwanimg.cn/images/order_arrow_dowm.gif' border='0' /> 显示所有分类</a><div class='clear'></div>");
	}
}
// 顶部下拉菜单
function subM(){
	$(".user_info .dropdown").hover(
	function(){
		$(".top_submenu").slideToggle(300);
	},function(){
		$(".top_submenu").slideUp(400)
	})
}
// 加入收藏JS
function AddFavorite(sURL, sTitle)
{
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
// 省市菜单
function PopProvince() {  
		 $('#province').empty();
		 var province = document.getElementById("P").value;
		 $.each(CityList.Province, function(i, v) {  
			 if (v.Name == province){
			 	$("#province").append("<option selected='selected'>" + v.Name + "</option>");   //把省份填充到列表province中
			 }else{
				$("#province").append("<option>" + v.Name + "</option>"); 	 
			 }
		 });  
	  
		 $('#province').change(function() {          // 增加省份改变的事件触发  
			 var index = $('#province').find(':selected').text();  
			 if (index != '请选择') {  
				 PotCity();  
			 }  
			 $('#city').focus();  
		 });
	 } 
  
function PotCity() {    // 填充城市到列表city  
	 $('#city').empty();
	 var city = document.getElementById("C").value;
	 var name = $('#province').find(':selected').text();  
	 $.each(CityList.Province, function(i, v) {  
		 if (v.Name == name) {  
			 $.each(v.City, function(i, v) {  
				 if(city == v){
				 	$("#city").append("<option selected='selected'>" + v + "</option>");
				 }else{
					$("#city").append("<option>" + v + "</option>");	 
				 }
			 });  
		 }  
	 });  
 }
// 二级页面游戏列表AJAX请求
function gameOneAjax(){
		var serverid = document.getElementById("serverid").value;
		var userid = document.getElementById("userid").value;
		var activeTab = $("ul.listgametabs li:first").find("a").attr("name");
		var tabObj = $(activeTab);
		gameListAjax(userid,serverid,tabObj,activeTab);
		$("#loading").show();
}

function gameListAjax(userid,serverid,obj,mode){
	var url = '/accountview/getlist';
	$.ajax({
		type: "get",
		url: url,
		data :{userid:userid,serverid:serverid,mode:mode,format:"html"},
		success: function(data, textStatus){
			//alert(data);
			obj.html(data);	
			$("#loading").hide()
		}
	});	
}
// 翻页ajax请求
function pagesAjax(userid,serverid,mode,page){
	var url = "/accountview/getlist/page/"+page;
	$.ajax({
		type: "get",
		url: url,
		data :{userid:userid,serverid:serverid,mode:mode,format:"html"},
		success: function(data, textStatus){
			$(mode).html("");	
			$(mode).html(data);	
		}
	});	
}
//cross Domain request
function crossDomainRequest(method, url, data, callback, dataType, iframeId) {
    // call iframe request
    if (undefined == dataType) {dataType=null;}
    domian_back = document.domain;
    document.domain = "shiwan.com";
	if(undefined == iframeId) 
	{
		if (undefined == document.getElementById("iframeProxy"))
		{
			var myiframe = document.createElement("iframe");
			myiframe.src = "http://www.shiwan.com/SubDomainProxy.html";
			myiframe.id = "iframeProxy";
			myiframe.style.cssText = "display:none;";
			$(myiframe).load(function(){crossDomainRequest(method, url, data, callback, dataType, iframeId)});
			document.body.appendChild(myiframe);
			return;
		}
		
    	var proxy = document.getElementById("iframeProxy").contentWindow;
	}
	else
	{
		var proxy = document.getElementById(iframeId).contentWindow;	
	}
    proxy.sendRequest(method, url, data, callback, dataType);
    document.domain = domian_back;
}

// check request is/not cross domain
function isCrossDomain(url) {
    var a = url.match(/:\/\/(.[^/]+)/);
    if (a == null) {
        return false; 
    } else {
        if (a[1] == document.domain) {
            return false;
        } else {
            return true;
        }
    }
}

// 翻页ajax请求 (公用的方法)
function commonPagesAjax(url,divobj,iframeId){
	var url = url;
	var divobj_header = divobj.substr(0,6);
	if(divobj_header != "header" && divobj_header != "ztnew_"){
		$("#" + divobj).fadeIn();
		$("#" + divobj).html("<div style='padding:30px;text-align:center;'><img src='http://www.shiwanimg.cn/images/loading.gif'/></div>");
	}
    callback_func = function(data, textStatus){	
            	$("#" + divobj).html("");
            	$("#" + divobj).html(data);	
		    };
    if (isCrossDomain(url)) {
        crossDomainRequest("get", url, {format:"html"}, callback_func, null, iframeId);
    } else {
	    $.ajax({
		    type: "get",
		    url: url,
		    data :{format:"html"},
		    success: callback_func
	    });	
    }
}

// 翻页ajax请求 (公用的方法) 此方法用在onclik等能获取到当前doc的事件中，
// 这样就不用为父容器专门指定一个id，方便调用
function commonPagesOnEventAjax(url,$docobj){
	var url = url;
    callback_func = function(data, textStatus){	
            	$docobj.html("");
            	$docobj.html(data);	
                return false;
		    };
    if (isCrossDomain(url)) {
        crossDomainRequest("get", url, {format:"html"}, callback_func, null);
    } else {
	    $.ajax({
		    type: "get",
		    url: url,
		    data :{format:"html"},
		    success: callback_func,
		    async:false
	    });	
    }
    return false;
}

// 20 40 80分页显示
function perpagesAjax(userid,serverid,mode,perpage){
	var url = '/accountview/getlist';
	$.ajax({
		type: "get",
		url: url,
		data :{userid:userid,serverid:serverid,mode:mode,perpage:perpage,format:"html"},
		success: function(data, textStatus){
			//alert(data);
			$(mode).html("");
			$(mode).html(data);
		}
	});	
}
// 游戏列表排序显示ajax
function gameOrderAjax(userid,serverid,mode,order){
	var url = '/accountview/getlist';
	$.ajax({
		type: "get",
		url: url,
		data :{userid:userid,serverid:serverid,mode:mode,order:order,format:"html"},
		success: function(data, textStatus){
			//alert(data);
			$(mode).html("");
			$(mode).html(data);
		}
	});	
}
// 收到、作出的投诉ajax
function complaintPageAjax(mode,page){
	var url = "/consolecomplain/getrecord";
	$.ajax({
		type: "get",
		url: url,
		data :{mode:mode,page:page,format:"html"},
		success: function(data, textStatus){
			$(mode).html("");
			$(mode).html(data);	
		}
	});	
}

function complaintAjax(mode){
	var url = "/consolecomplain/getrecord";
	$.ajax({
		type: "get",
		url: url,
		data :{mode:mode,format:"html"},
		success: function(data, textStatus){
			$(mode).html("");
			$(mode).html(data);	
		}
	});	
}
function complaintOneAjax(){
		$(".complaint_content").hide(); //Hide all content
		$("ul.complainttabs li:first").addClass("active").show(); 
		$(".complaint_content:first").show(); //Show first tab content
		var activeTab = $("ul.complainttabs li:first").find("a").attr("name");
		complaintAjax(activeTab);
		//loading("cloading");
}
function scomplaintOneAjax(){
		$(".scomplaint_content").hide(); //Hide all content
		$("ul.scomplainttabs li:first").addClass("active").show(); 
		$(".scomplaint_content:first").show(); //Show first tab content
		var activeTab = $("ul.scomplainttabs li:first").find("a").attr("name");
		complaintAjax(activeTab);
		//loading("sloading");
}
function complaintTwoAjax(){
		$(".complaint_content").hide(); //Hide all content
		$("ul.complainttabs li:first").next().addClass("active").show(); 
		$(".complaint_content:first").next().show(); //Show first tab content
		var activeTab = $("ul.complainttabs li:first").next().find("a").attr("name");
		complaintAjax(activeTab);
		//loading("cloading");
}
function scomplaintTwoAjax(){
		$(".scomplaint_content").hide(); //Hide all content
		$("ul.scomplainttabs li:first").next().addClass("active").show(); 
		$(".scomplaint_content:first").next().show(); //Show first tab content
		var activeTab = $("ul.scomplainttabs li:first").next().find("a").attr("name");
		complaintAjax(activeTab);
		//loading("sloading");
}
// 历史纪录/评价ajax请求
function gameOneAccount(){
		var accountid = document.getElementById("accountid").value;
		var activeTab = $("ul.historytabs li:first").find("a").attr("name");
		var tabObj = $(activeTab);
		gameAccountAjax(accountid,tabObj,activeTab);
		//loading();
}

function gameAccountAjax(accountid,obj,mode){
	var url = '/accountview/info';
	$.ajax({
		type: "get",
		url: url,
		data :{accountid:accountid,mode:mode,format:"html"},
		success: function(data, textStatus){
			//alert(data);
			obj.html(data);	
		}
	});	
}
// loading游戏
//function loading(objId){
//	 var objId = "#"+objId;
//	 $(objId).ajaxStart(function(){
//		 $(objId).show();
//	 }).ajaxComplete(function(){
//	 	$(objId).hide();
//	 });
//}
function shiwanTabs(){
	// 首页游戏分类选项卡JS
	if($("ul.gametabs")){
		$(".tab_content").hide();
		$("ul.gametabs li:first").addClass("active");
		$("ul.gametabs li.abc").show();
		$("#gametype_container").show();
		//$("ul.gametabs li:first").addClass("active").show();
		$(".tab_content:first").show();//Show first tab content
		
		//On Click Event
		$("ul.gametabs li.bigkind").click(
			function(){
				if ( $(this).hasClass("active") ){
					$(".tab_content").hide();
					$(this).removeClass("active");
					$("ul.gametabs li.abc").hide();
				}else{
					$("ul.gametabs li.bigkind").removeClass("active");
					$(".tab_content").hide();
					$(this).addClass("active");
					$("ul.gametabs li.abc").show();
					$("ul.gametabs li.abc").removeClass("abcactive");
					$("ul.gametabs li#abc_default_tab").addClass("abcactive");
					$("div#gametype_container").fadeIn();
					var activeTab = $(this).find("a").attr("name");
					$(activeTab).show();
					var abckind = $("ul.gametabs li.abcactive").find("a").attr("class");
					var bigkind = $("ul.gametabs li.active").find("a").attr("class");
					$("#gametype_container #"+bigkind).fadeIn();
					$("#gametype_container #"+bigkind +" ul").hide();
					$("#gametype_container ul."+abckind).show();
				}
			}						  
		);
		$("ul.gametabs li").click(
			function(){
				$("ul.gametabs li").removeClass("active");
				$(".tab_content").hide();
				$(this).addClass("active");
				var abckind = $("ul.gametabs li.active").find("a").attr("name");
				var abcspell = $("ul.gametabs li.active").find("a").attr("class");
				$(abckind).fadeIn();
				$("#gametype_container ul."+abcspell).show();
			}						  
		);
		
//		$("ul.gametabs li").click(
//			function(){
//				if ( $(this).hasClass("active") ){
//					$("ul.gametabs li").removeClass("active");
//					$(".tab_content").hide();
//					$(this).removeClass("active");
//					$("ul.gametabs li.abc").hide();
//					var activeTab = $(this).find("a").attr("name"); 
//					$(activeTab).fadeOut(); 
//				}else{
//					$("div#gametype_container").fadeIn();
//					$("ul.gametabs li.abc").fadeIn();
//					var thisLiClass = $(this).attr("class");
//					if (thisLiClass == "bigkind")
//					{
//						$("ul.gametabs li").removeClass("active");	
//						$("ul.gametabs li#abc_default_tab").addClass("active");
//						$("div#gametype_container div").hide();
//					}
//					else
//					{
//						$("ul.gametabs li.abc").removeClass("active");
//					}
//					$(this).addClass("active");
//					var activeTab = $(this).find("a").attr("name"); 
//					var thisBigKindLi = $("ul.gametabs li.bigkind.active");
//					var thisAbcLi = $("ul.gametabs li.abc.active");
//					
//					if (thisAbcLi)
//					{
//						var spellTab = thisAbcLi.find("a").attr("class"); 
//						var thisBigKindLiId = thisBigKindLi.find("a").attr("class");
//						$("ul.gametabs li.abc a").css({"color":"#777","background":"none"});
//						$("ul.gametabs li.abc.active a").css({"color":"#000","background":"#DFDFDF"});
//						$("div#gametype_container div#"+thisBigKindLiId+" ul").hide();
//						$("div#gametype_container div#"+thisBigKindLiId+" ul."+spellTab+"").fadeIn();	
//						$(activeTab).fadeIn();				
//					}
//				}
//
//			});
	}
	// 首页游戏列表选项卡JS
	if($("ul.homegametabs")){
		$(".game_content").hide(); //Hide all content
		$("ul.homegametabs li:first").addClass("active").show(); 
		$(".game_content:first").show(); //Show first tab content
		
		//On Click Event
		$("ul.homegametabs li").click(function() {
			$("#loading").show();
			$("ul.homegametabs li").removeClass("active"); 
			$(this).addClass("active"); 
			$(".game_content").hide(); 
			var activeTab = $(this).find("a").attr("name");
			var tabHtml = $(activeTab).html();
			var tabObj = $(activeTab);
			var first = activeTab;
			var current = $(this);
			if(tabHtml =='' && activeTab != '#homegame1'){
				gameAjax(tabObj,activeTab);
			}
			$(activeTab).fadeIn();
		});
	}
	// 首页游戏列表AJAX请求
	function gameAjax(obj,id){
		var url = '/index/getlist';
		$.ajax({
			type: "get",
			url: url,
			data :{a:id,format:"html"},
			success: function(data, textStatus){
				//alert(data);
				obj.html(data);
				$("#loading").hide();
			}
		});	
	}
	// 二级页面游戏列表选项卡JS
	if($(".listgame_content")){
		$(".listgame_content").hide(); //Hide all content
		$("ul.listgametabs li:first").addClass("active").show(); 
		$(".listgame_content:first").show(); //Show first tab content
		
		//On Click Event
		$("ul.listgametabs li").click(function() {
			$("ul.listgametabs li").removeClass("active"); 
			$(this).addClass("active"); 
			$(".listgame_content").hide(); 
			var activeTab = $(this).find("a").attr("name");
			var tabHtml = $(activeTab).html();
			var tabObj = $(activeTab);
			var first = activeTab;
			var serverid = document.getElementById("serverid").value;
			var userid = document.getElementById("userid").value;
			var current = $(this);
			if(tabHtml ==''){
				gameListAjax(userid,serverid,tabObj,activeTab);
				$("#loading").show();
			}
			$(activeTab).fadeIn();
		});
		
		//On Click Event
		$("ul.listgametabs_subject li").click(function() {
			$("ul.listgametabs_subject li").removeClass("active"); 
			$(this).addClass("active"); 
		});
	}
	//分页
	if($(".pages_num")){
		$(".pages_num a").click(function() {
			$(".pages_num a").removeClass("active"); 
			$(this).addClass("active"); 
		});
	}
	//历史记录/评论区选项卡样式
	if($("ul.historytabs")){
		$(".history_content").hide(); //Hide all content
		$("ul.historytabs li:first").addClass("active").show(); 
		$(".history_content:first").show(); //Show first tab content
		
		//On Click Event
		$("ul.historytabs li").click(function() {
			$("ul.historytabs li").removeClass("active"); 
			$(this).addClass("active"); 
			$(".history_content").hide(); 
			var activeTab = $(this).find("a").attr("name");
			var tabHtml = $(activeTab).html();
			var tabObj = $(activeTab);
			var first = activeTab;
			var accountid = document.getElementById("accountid").value;
			var current = $(this);
			if(tabHtml ==''){
				gameAccountAjax(accountid,tabObj,activeTab);
				//loading();
			}
			$(activeTab).fadeIn();
		});
	}
	//评价
	if($("ul.appraisetabs")){
		$(".history_content").hide(); //Hide all content
		$("ul.appraisetabs li:first").addClass("active").show(); 
		$(".history_content:first").show(); //Show first tab content
		
		//On Click Event
		$("ul.appraisetabs li").click(function() {
			$("ul.appraisetabs li").removeClass("active"); 
			$(this).addClass("active"); 
			$(".history_content").hide(); 
			var activeTab = $(this).find("a").attr("name");
			$(activeTab).fadeIn();
		});
	}
	//我收到的投诉选项卡样式
	if($("ul.complainttabs")){
		//On Click Event
		$("ul.complainttabs li").click(function() {
			$("ul.complainttabs li").removeClass("active"); 
			$(this).addClass("active"); 
			$(".complaint_content").hide(); 
			var activeTab = $(this).find("a").attr("name");
			var tabHtml = $(activeTab).html();
			var tabObj = $(activeTab);
			if(tabHtml ==''){
				complaintAjax(activeTab);
				//loading("cloading");
			}
			$(activeTab).fadeIn();
		});
	}
	//我作出的投诉选项卡样式
	if($("ul.scomplainttabs")){		
		//On Click Event
		$("ul.scomplainttabs li").click(function() {
			$("ul.scomplainttabs li").removeClass("active"); 
			$(this).addClass("active"); 
			$(".scomplaint_content").hide(); 
			var activeTab = $(this).find("a").attr("name"); 
			var tabHtml = $(activeTab).html();
			var tabObj = $(activeTab);
			if(tabHtml ==''){
				complaintAjax(activeTab);
				//loading("sloading");
			}
			$(activeTab).fadeIn();
		});
	}
}

// 试玩网表格列表JS (隔行换色) ----------------------------------------------------------
function shiwanTables(){
	if($(".console_list_tab")){
		//一般表格JS
		$(".console_list_tab").attr("bgColor","#ffffff");
		$(".console_list_tab tbody tr").attr("bgColor","#F9FDFF");　 
		$("td").append(" ");　　//为所有单元格添加一个空格 
		$(".console_list_tab tbody tr:even").addClass("white_bg");
		$(".console_list_tab tbody tr").hover(
		function(){
			$(this).removeClass("white_bg");
			$(this).addClass("yellow_bg");
		},function(){
			$(this).removeClass("yellow_bg");
			$(".console_list_tab tbody tr:even").addClass("white_bg");
		})
	}
	if($(".console_tab")){
		//一般表格JS
		$(".console_tab").attr("bgColor","#ffffff");　
		$(".console_tab_th tr").attr("bgColor","#F1FAFF");
		$(".console_tab_body tr").attr("bgColor","#F9FDFF");　 
		$("td").append(" ");　　//为所有单元格添加一个空格 
		$(".console_tab_body tr:even").css("background-color","#fff");
	}
	if($(".console_bid_over")){
		//结束竞标的表格样式
		$(".console_bid_over").attr("bgColor","#ffffff");
		$(".console_bid_over_th tr").attr("bgColor","#DADEE7");
		$(".console_bid_over tbody tr").attr("bgColor","#F5F5F5"); 
		$(".console_bid_over tbody tr:even").css("background-color","#fff");
	}
	if($(".console_bid")){
	//竞标中的表格样式
		$(".console_bid").attr("bgColor","#ffffff"); 
		$(".console_bid_th tr").attr("bgColor","#F7DAC8");
		$(".console_bid_body tr").attr("bgColor","#fff8f4"); 
		$(".console_bid_body tr:even").css("background-color","#fff");
	}
	if($(".bid_tab")){
		//竞标中的表格样式
		$(".bid_tab").attr("bgColor","#ffffff"); 
		$(".bid_tab thead tr").attr("bgColor","#F7DAC8");
		$(".bid_tab tbody tr").attr("bgColor","#FCF8F5"); 
		$(".bid_tab tbody tr:even").css("background-color","#FCF3EE");
	}
	if($(".history_tab")){
		//试玩历史记录表格样式
		$(".history_tab").attr("bgColor","#ffffff"); 
		$(".history_tab thead tr").attr("bgColor","#CEEDFF");
		$(".history_tab tbody tr").attr("bgColor","#F9FDFF"); 
		$(".history_tab tbody tr:even").css("background-color","#F1FAFF");
	}
	if($(".remark_tab")){
		//评论表格样式
		//评论表格样式
		$(".remark_tab").attr("bgColor","#ffffff"); 
		$(".remark_tab thead tr").attr("bgColor","#CEEDFF");
		$(".remark_tab tbody tr").attr("bgColor","#F9FDFF"); 
		$(".remark_tab tbody tr:even").css("background-color","#F1FAFF");
	}
	if($(".confer_msg_tab") || $(".user_credit_tab")){
		//协商留言记录表格
		$(".confer_msg_tab").attr("bgColor","#ffffff"); 
		$(".confer_msg_tab thead tr").attr("bgColor","#CEEDFF");
		$(".confer_msg_tab tbody tr").attr("bgColor","#F9FDFF"); 
		$(".confer_msg_tab tbody tr:even").css("background-color","#F1FAFF");	
	}
	if($(".user_credit_tab")){
		//用户信誉表格样式
		$(".user_credit_tab").attr("bgColor","#ffffff"); 
		$(".user_credit_tab thead tr").attr("bgColor","#CEEDFF");
		$(".user_credit_tab tbody tr").attr("bgColor","#F9FDFF"); 
		$(".user_credit_tab tbody tr:even").css("background-color","#F1FAFF");
	}
	if($(".gametest_tab")){
		//开测表格样式
		//$(".gametest_tab").attr("bgColor","#ffffff"); 
		//$(".gametest_tab tbody tr").attr("style","background:url(../images/subject/list_td_bg.gif)"); 
		//$(".gametest_tab tbody tr:even").css("background","none");
	}
}
//控制台左边导航菜单JS
function consoleMenu(){
	$(".console_menu dt").click(
	function(){
		$(".console_menu dt").removeClass("arrow");
		$(".console_menu dt").next("dd").slideUp(200);
		$(this).next("dd").slideToggle(200);
		$(this).addClass("arrow");
	},function(){
		$(this).next("dd").slideUp(200);
	}
	)

}
// 游戏搜索匹配
function searchGame(){
	var searchKey = document.loginForm.searchKey.value;
	var searchEnd = "";
	if(searchKey =='' || searchKey == '键入关键字'){
		return false;
	}else{
		searchKey=searchKey.replace(/^\s*|\s*$/g,'');
		$.each($("#searchgamelist").children(),function(i,obj){
			var optionId = obj.value;
			var optionName = obj.text;
			var optionSname = obj.getAttribute("sname");
			var optionFname = obj.getAttribute("fname");
			var searchName = optionName.indexOf(searchKey);
			var searchSname = optionSname.indexOf(searchKey);
			var searchFname = optionFname.indexOf(searchKey);
			if(searchName != -1 || searchSname != -1 || searchFname != -1){
				searchEnd += '<option value=' + optionId+'>' + optionName + '</option> ';
			}
		});
		$("#gameId").html("");
		$("#gameId").html(searchEnd);
		var gameIdObj = document.getElementById("gameId");
		var len = gameIdObj.length;
		setTimeout(function(){
			if(len > 0){
				$("#gameId option:first").attr("selected",true);
				var gameId = $("#gameId option:selected").val();
				getGameQuHtml(gameId);
			}
		},100);
	}
}
//选择好友下拉div
function friendList(){
	$("#select_friend").jHelperTip({
		trigger: "click",
		dC:"#friend_list", 
		autoClose: false, 
		opacity: 0.9
	});
}

// 马上体验ajax请求
function dealAjax(url){
	var accountid = document.accountForm.accountid.value;
	$.ajax({
		type: "get",
		url: url,
		data :{id:accountid,format:"html"},
		success: function(data, textStatus){
			dealDialog(data, textStatus);	
		}
	});	
}
// 手机验证ajax请求
function mobileAjax(id){
	$.ajax({
		type: "get",
		url: "/consolepersonal/mobiletip",
		data :{id:id,format:"html"},
		success: function(data, textStatus){
			if(data == 1){
				location.href = "/consolepersonal/mobilecheck";	
			}else{
				setTimeout("mobileAjax('"+ id +"')",5000);
			}
		}
	});	
}
// 邮箱自动激活帐号ajax请求
function AutoEmailAjax(){
	$.ajax({
		type: "post",
		url: "/autoActive/index",
		dataType: "json",
		data :{format:"json"},
		success: function(data, textStatus){
			if(data["data"] == 1){
				location.href = "/user/autoactive";	
			}else{
				setTimeout("AutoEmailAjax()",30000);
			}
		}
	});	
}
// 竞价出价页面弹出页面提示
function bidTermsDialog(){
	var thickTtitle = "[重要]参与竞价说明";
	var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
	tb_show(thickTtitle,thickAlt,false);
	$("#TB_ajaxContent").html("");
	$("#TB_ajaxContent").html(bidInfo);	
	$("#TB_closeAjaxWindow").html("");
	//bidTimer();
}
function bidformAjax(accountid){
	var money = document.bidform.bidmoney.value;
	var ajaxUrl = "/trade/bidform/id/";
	$.ajax({
		type: "post",
		url: ajaxUrl,
		data :{id:accountid,money:money,format:"html"},
		success: function(data, textStatus){
			if(data == 0) {location.href = "/trade/bidsuccess/id/" + accountid;}
			else{$("#bidError").html(data);}
		}
	});	
}


// 竞价出价Ajax请求
function bidAjax(){
	var accountid = document.accountForm.accountid.value;
	var ajaxUrl = document.accountForm.url.value;
	$.ajax({
		type: "post",
		url: ajaxUrl,
		data :{id:accountid,format:"html"},
		success: function(data, textStatus){
			bidDialog(data, textStatus);	
		}
	});
}
// 竞价出价回调函数
function bidDialog(data, textStatus){
	var accountid = document.accountForm.accountid.value;
	if(data == 0) {location.href = "/trade/bidform/id/"+accountid;}
	else if(data == 1 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(idError_info);
	}
	else if(data == 2 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(tiyanno_info);
	}
	else if(data == 3) {
		var thickTtitle = "用户登录";
		var thickAlt = "#TB_inline?height=150&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(login_info);
	}
	else if(data == 4 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(tiyanmy_info);
	}
	else if(data == 5 ){
		$("#login_error").html("您的用户名或密码不太对吧，请重新登录！");	
	}
	else if(data == 6 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(noReg_info);
	}
	else if(data == 7 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(noLove_info);
	}
	else if(data == 8 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(noCredit_info);
	}
	else if(data == 9 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(overNum_info);
	}
	else if(data == 10 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(blackList_info);
	}
	else if(data == 11 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(whiteList_info);
	}
	else if(data == 12 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		var intime_info = "<p><img src='http://www.shiwanimg.cn/images/tishi_ico.gif' align='absmiddle' /> 您太累了, 不能同时试玩2个以上同一游戏账号，请稍后再试！</p>" + close_btn;
		$("#TB_ajaxContent").html(intime_info);
	}
	else if(data == 13 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		var intime_info = "<p><img src='http://www.shiwanimg.cn/images/tishi_ico.gif' align='absmiddle' /> 该游戏还未开测或暂停！</p>" + close_btn;
		$("#TB_ajaxContent").html(intime_info);
	}
	else if(data == 14 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		var intime_info = "<p><img src='http://www.shiwanimg.cn/images/tishi_ico.gif' align='absmiddle' /> 您已经领过该款游戏帐号了，请稍后再试！</p>" + close_btn;
		$("#TB_ajaxContent").html(intime_info);
	}
	else if(data == 15 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		var intime_info = "<p><img src='http://www.shiwanimg.cn/images/tishi_ico.gif' align='absmiddle' /> 该帐号为预定活动帐号，预定还未开始！</p>" + close_btn;
		$("#TB_ajaxContent").html(intime_info);
	}else if(data == 16 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		var intime_info = "<p><img src='http://www.shiwanimg.cn/images/tishi_ico.gif' align='absmiddle' /> 该账号为预定活动账号，你未预定成功，无法领取！</p>" + close_btn;
		$("#TB_ajaxContent").html(intime_info);
	}else if(data == 17 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		var intime_info = "<p><img src='http://www.shiwanimg.cn/images/tishi_ico.gif' align='absmiddle' /> 该账号为预定活动账号，你没有参与预定，无法领取！</p>" + close_btn;
		$("#TB_ajaxContent").html(intime_info);
	}else if(data == 18 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		var intime_info = "<p><img src='http://www.shiwanimg.cn/images/tishi_ico.gif' align='absmiddle' /> 此快速试玩账号未到发号时间或者已经过期！</p>" + close_btn;
		$("#TB_ajaxContent").html(intime_info);
	}else if(data == 19 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		var intime_info = "<p><img src='http://www.shiwanimg.cn/images/tishi_ico.gif' align='absmiddle' /> 此账号仅对组团的玩家开放，你还未加团！</p>" + close_btn;
		$("#TB_ajaxContent").html(intime_info);
	}else{
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		var data = "<p style='text-align:center;'><img src='http://www.shiwanimg.cn/images/tishi_ico.gif' align='absmiddle' /> "+data+"</p>";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(data);	
	}
}
// 登录的ajax请求
function loginAjax(){
	var accountid = document.accountForm.accountid.value;
	var ajaxUrl = document.accountForm.url.value;
	var username =  document.getElementById("loginuser").value;
	var password =  document.getElementById("loginpassword").value;
	$.ajax({
		type: "post",
		url: ajaxUrl,
		data :{id:accountid,username:username,password:password,format:"html"},
		success: function(data, textStatus){
			if(ajaxUrl == "/trade/bid"){
				bidDialog(data, textStatus);
			}else if(ajaxUrl == '/preorder/preorderlogin' && data == 0){
				tb_remove();thisgotoUrl();
			}else if(ajaxUrl == '/preorder/preorderlogin' && data == 1){
				$("#login_error").html("您的用户名或密码不太对吧，请重新登录！");
			}else if(ajaxUrl == '/accountview/playstorylogin' && data == 0){
				tb_remove();thisgotoUrl();
			}else if(ajaxUrl == '/accountview/playstorylogin' && data == 1){
				$("#login_error").html("您的用户名或密码不太对吧，请重新登录！");	
			}else{
				dealDialog(data, textStatus);
			}
		}
	});	
}
// 预定理由发布登录
function yudingLogin(){
	var thickTtitle = "用户登录";
	var thickAlt = "#TB_inline?height=150&width=500&inlineId=dialogDiv";
	tb_show(thickTtitle,thickAlt,false);
	$("#TB_ajaxContent").html(login_info);
}
// 马上体验回调函数
function dealDialog(data, textStatus){
	var accountid = document.accountForm.accountid.value;
	if(data == 0) {location.href = "/trade/buynowconfirm/id/"+accountid;}
	else if(data == 1 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(idError_info);
	}
	else if(data == 2 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(tiyanno_info);
	}
	else if(data == 3) {
		var thickTtitle = "用户登录";
		var thickAlt = "#TB_inline?height=150&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(login_info);
	}
	else if(data == 4 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(tiyanmy_info);
	}
	else if(data == 5 ){
		$("#login_error").html("您的用户名或密码不太对吧，请重新登录！");	
	}
	else if(data == 6 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(noReg_info);
	}
	else if(data == 7 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(noLove_info);
	}
	else if(data == 8 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(noCredit_info);
	}
	else if(data == 9 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(overNum_info);
	}
	else if(data == 10 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(blackList_info);
	}
	else if(data == 11 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(whiteList_info);
	}
	else if(data == 12 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		var intime_info = "<p><img src='http://www.shiwanimg.cn/images/tishi_ico.gif' align='absmiddle' /> 您太累了, 不能同时试玩2个以上同一游戏账号，请稍后再试！</p>" + close_btn;
		$("#TB_ajaxContent").html(intime_info);
	}
	else if(data == 13 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		var intime_info = "<p><img src='http://www.shiwanimg.cn/images/tishi_ico.gif' align='absmiddle' /> 该游戏还未开测或暂停！</p>" + close_btn;
		$("#TB_ajaxContent").html(intime_info);
	}
	else if(data == 14 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		var intime_info = "<p><img src='http://www.shiwanimg.cn/images/tishi_ico.gif' align='absmiddle' /> 您已经领过该款游戏帐号了，请稍后再试！</p>" + close_btn;
		$("#TB_ajaxContent").html(intime_info);
	}
	else if(data == 15 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		var intime_info = "<p><img src='http://www.shiwanimg.cn/images/tishi_ico.gif' align='absmiddle' /> 该帐号为预定活动帐号，预定还未开始！</p>" + close_btn;
		$("#TB_ajaxContent").html(intime_info);
	}else if(data == 16 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		var intime_info = "<p><img src='http://www.shiwanimg.cn/images/tishi_ico.gif' align='absmiddle' /> 该账号为预定活动账号，你未预定成功，无法领取！</p>" + close_btn;
		$("#TB_ajaxContent").html(intime_info);
	}else if(data == 17 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		var intime_info = "<p><img src='http://www.shiwanimg.cn/images/tishi_ico.gif' align='absmiddle' /> 该账号为预定活动账号，你没有参与预定，无法领取！</p>" + close_btn;
		$("#TB_ajaxContent").html(intime_info);
	}else if(data == 18 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		var intime_info = "<p><img src='http://www.shiwanimg.cn/images/tishi_ico.gif' align='absmiddle' /> 此快速试玩账号未到发号时间或者已经过期！</p>" + close_btn;
		$("#TB_ajaxContent").html(intime_info);
	}else if(data == 19 ){
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		var intime_info = "<p><img src='http://www.shiwanimg.cn/images/tishi_ico.gif' align='absmiddle' /> 此账号仅对组团的玩家开放，你还未加团！</p>" + close_btn;
		$("#TB_ajaxContent").html(intime_info);
	}else{
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		var data = "<p style='text-align:center;'><img src='http://www.shiwanimg.cn/images/tishi_ico.gif' align='absmiddle' /> "+data+"</p>";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(data);	
	}
}
// 显示帐号信息ajax请求
function confirmAjax(){
	var accountid = document.confirmForm.accountId.value;
	$.ajax({
		type: "post",
		url: '/trade/buynowconfirm',
		data :{id:accountid,format:"html"},
		success: function(data, textStatus){
			var thickTtitle = "账号试玩领取";
			var thickAlt = "#TB_inline?height=250&width=500&inlineId=dialogDiv";
			tb_show(thickTtitle,thickAlt,false);
			$("#TB_ajaxContent").html(data);
		}
	});	
}
// 控制台显示帐号信息ajax请求
function showConfirmAjax(id,url){
	$.ajax({
		type: "post",
		url: url,
		data :{id:id,format:"html"},
		success: function(data, textStatus){
			var thickTtitle = "账号密码信息";
			var thickAlt = "#TB_inline?height=250&width=500&inlineId=dialogDiv";
			tb_show(thickTtitle,thickAlt,false);
			$("#TB_ajaxContent").html("");
			$("#TB_ajaxContent").html(data);
			$(".opendiv_btn").html("");
		}
	});	
}
// 控制台显示竞拍原因ajax请求
function showReasonAjax(id,url){
	$.ajax({
		type: "post",
		url: url,
		data :{id:id,format:"html"},
		success: function(data, textStatus){
			var thickTtitle = "选标原因";
			var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
			tb_show(thickTtitle,thickAlt,false);
			$("#TB_ajaxContent").html("");
			$("#TB_ajaxContent").html(data);
		}
	});	
}
// 提前完成交易ajax请求
function dealendAjax(id,url){
	$.ajax({
		type: "post",
		url: url,
		data :{id:id,format:"html"},
		success: function(data, textStatus){
			var thickTtitle = "提前完成交易";
			var thickAlt = "#TB_inline?height=108&width=500&inlineId=dialogDiv";
			tb_show(thickTtitle,thickAlt,false);
			$("#TB_ajaxContent").html(data);
		}
	});	
}
// 领取号码ajax请求
function getCodeAjax(id,url){
	if(document.getElementById('captcha') != null){
		var captcha = document.getElementById("captcha").value;
	}
	else{
		var captcha = '';	
	}
	if(document.getElementById('codeuser') != null){
		var codeuser = document.getElementById("codeuser").value;
	}
	else{
		var codeuser = '';	
	}
	if(document.getElementById('codepassword') != null){
		var codepassword = document.getElementById("codepassword").value;
	}
	else{
		var codepassword = '';	
	}
	if(document.getElementById('captcha_apple') != null){
		var captcha_apple = document.getElementById("captcha_apple").value;
	}
	else{
		var captcha_apple = '';	
	}
	var str = 'id='+id+'&username='+codeuser+'&password='+ codepassword +'&captcha='+ captcha +'&captcha_apple='+ captcha_apple;
	
	callback = function(data, textStatus) 
    {
		var thickTtitle = "系统提示";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html(data);
    };
	preorderCommonFormAjax('', url, str, "html", callback);
	/*
	$.ajax({
		type: "post",
		url: url,
		data :{id:id,username:codeuser,password:codepassword,captcha:captcha,format:"html"},
		success: function(data, textStatus){
			var thickTtitle = "系统提示";
			var thickAlt = "#TB_inline?height=330&width=500&inlineId=dialogDiv";
			tb_show(thickTtitle,thickAlt,false);
			$("#TB_ajaxContent").html(data);
		}
	});	*/
}
// 淘号ajax请求
function taoCodeAjax(id,url){
	if(document.getElementById('captcha') != null){
		var captcha = document.getElementById("captcha").value;
	}
	else{
		var captcha = '';	
	}
	$.ajax({
		type: "post",
		url: url,
		data :{id:id,captcha:captcha,format:"html"},
		success: function(data, textStatus){
			var thickTtitle = "系统提示";
			var thickAlt = "#TB_inline?height=310&width=500&inlineId=dialogDiv";
			tb_show(thickTtitle,thickAlt,false);
			$("#TB_ajaxContent").html(data);
		}
	});	
}
// 领取邀请码ajax
function getRegCode(url){
	$.ajax({
		type: "post",
		url: url,
		data :{format:"html"},
		success: function(data, textStatus){
			var thickTtitle = "领取推广码";
			var thickAlt = "#TB_inline?height=150&width=500&inlineId=dialogDiv";
			tb_show(thickTtitle,thickAlt,false);
			$("#TB_ajaxContent").html(data);
		}
	});	
}
//表单验证js
function regButton(obj){
	if(obj.checked){
		document.loginForm.regSubmit.disabled = false;
		$("#TipXy").html("");
	}else{
		document.loginForm.regSubmit.disabled = true;
		$("#TipXy").html("服务协议必须选择");
	}
}
function putinButton(obj,num){
	if(obj.checked && num==1){
		document.loginForm.putinSubmit.disabled = true;
	}else{
		document.loginForm.putinSubmit.disabled = false;
	}
}
function cardButton(obj,num){
	if(obj.checked && num==1){
		document.cardForm.cardSubmit.readOnly  = true;
	}else{
		document.cardForm.cardSubmit.readOnly  = false;
	}
}
function shiwanReg(){
	$("#loginForm").SetValidateSettings({});
	$("#username").SetValidateSettings({
		FormValidate: {
			Empty: {
				Value: true
			},
			Format: {
				Value: /^[-_a-zA-Z0-9\u4e00-\u9fa5]{4,20}$/,
				Message: "用户名长度错误或者包含有不被允许的字符"
			}
		},
		Message: {
			Text: {
				Show: "用户名由4-20个中文、字母、数字、中划线、下线线组成",
				Success: "",
				Error: "登录名不能为空",
				Focus: "用户名由4-20个中文、字母、数字、中划线、下线线组成"
			},
			MessageSpaceHolderID: "TipUsername"
		}
	});
	$("#nikename").SetValidateSettings({
		FormValidate: {
			Empty: {
				Value: true
			},
			Format: {
				Value: /^[-_a-zA-Z0-9\u4e00-\u9fa5]{2,8}$/,
				Message: "昵称长度错误或者包含有不被允许的字符"
			}
		},
		Message: {
			Text: {
				Show: "昵称由2-8个中文、字母、数字、中划线、下线线组成",
				Success: "",
				Error: "昵称不能为空",
				Focus: "昵称由2-8个中文、字母、数字、中划线、下线线组成"
			},
			MessageSpaceHolderID: "TipNikename"
		}
	});
	$("#email").SetValidateSettings({
		FormValidate: {
			Empty: {
				Value: true
			},
			Format: {
				Value: /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/,
				Message: "邮件格式不正确"
			}
		},
		Message: {
			Text: {
				Show: "请输入您常用的邮箱,方便日后找回密码<br>(建议申请可靠的<a href='http://mail.sina.com.cn/register/reg_freemail.php?r=shiwan' target='_blank' class='blue'><u>新浪邮箱</u></a>)",
				Success: "",
				Error: "邮件地址不能为空",
				Focus: "请输入邮件地址"
			},
			MessageSpaceHolderID: "TipEmail"
		}
	});
	 $("#password").SetValidateSettings({
		FormValidate: {
			Empty: {
				Value: true
			},
			Format:{
				Value: /^(?![a-zA-Z]$)(?![0-9]$)[a-zA-Z0-9]{6,15}$/,
				Message: "错误！密码应大于6位和小于15位！"
			}
		},
		Message: {
			Text: {
				Show: "请输入6-15位登录密码",
				Success: "正确！",
				Error: "登录密码不能为空",
				Focus: "请输入6-15位登录密码"
			},
			MessageSpaceHolderID: "TipPassword"
		}
	});
	$("#confirmPassword").SetValidateSettings({
		FormValidate: {
			Empty: {
				Value: true
			},
			EqualTo: {
				Value: "password",
				Message: "两次输入密码不一致"
			}
		},
		Message: {
			Text: {
				Show: "请输入确认密码",
				Success: "正确！",
				Error: "确认密码必须输入",
				Focus: "请输入确认密码"
			},
			MessageSpaceHolderID: "TipConfirmPassword"
		}
	});
//	$("#registercode").SetValidateSettings({
//		FormValidate: {
//			Empty: {
//				Value: true
//			}
//		},
//		Message: {
//			Text: {
//				Show: "请输入邀请码",
//				Success: "",
//				Error: "邀请码为必填",
//				Focus: "请输入邀请码"
//			},
//			MessageSpaceHolderID: "Tipregistercode"
//		}
//	});
}
function shiwanPass(){
	if(document.getElementById('loginForm') != null){
		$("#loginForm").SetValidateSettings({});
		$("#password").SetValidateSettings({
			FormValidate: {
				Empty: {
					Value: true
				},
				Format:{
					Value: /^(?![a-zA-Z]$)(?![0-9]$)[a-zA-Z0-9]{6,15}$/,
					Message: "错误！密码应大于6位和小于15位！"
				}
			},
			Message: {
				Text: {
					Show: "请输入6-15位登录密码",
					Success: "正确！",
					Error: "登录密码不能为空",
					Focus: "请输入6-15位登录密码"
				},
				MessageSpaceHolderID: "TipPassword"
			}
		});
		$("#confirmPassword").SetValidateSettings({
			FormValidate: {
				Empty: {
					Value: true
				},
				EqualTo: {
					Value: "password",
					Message: "两次输入密码不一致"
				}
			},
			Message: {
				Text: {
					Show: "请输入确认密码",
					Success: "正确！",
					Error: "确认密码必须输入",
					Focus: "请输入确认密码"
				},
				MessageSpaceHolderID: "TipConfirmPassword"
			}
		});
	}
}
function shiwanEmail(){
	if(document.getElementById('loginForm') != null){
		$("#loginForm").SetValidateSettings({});
		$("#email").SetValidateSettings({
			FormValidate: {
				Empty: {
					Value: true
				},
				Format: {
					Value: /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/,
					Message: "邮件格式不正确"
				}
			},
			Message: {
				Text: {
					Show: "请输入您常用的邮箱,方便日后找回密码<br>(建议申请可靠的<a href='http://mail.sina.com.cn/register/reg_freemail.php?r=shiwan' target='_blank' class='blue'><u>新浪邮箱</u></a>)",
					Success: "正确！",
					Error: "邮件地址不能为空",
					Focus: "请输入您需要更换的邮箱地址，用于接收验证邮件"
				},
				MessageSpaceHolderID: "TipEmail"
			}
		});
		$("#password").SetValidateSettings({
			FormValidate: {
				Empty: {
					Value: true
				},
				Format:{
					Value: /^(?![a-zA-Z]$)(?![0-9]$)[a-zA-Z0-9]{6,15}$/,
					Message: "错误！密码应大于6位和小于15位！"
				}
			},
			Message: {
				Text: {
					Show: "请输入6-15位登录密码",
					Success: "正确！",
					Error: "登录密码不能为空",
					Focus: "请输入6-15位登录密码"
				},
				MessageSpaceHolderID: "TipPassword"
			}
		});
	}
}
// 游戏截图展示效果JS
function showImg(){
	if($('a[rel*=facebox]').facebox != undefined){
		$('a[rel*=facebox]').facebox({
			loading_image : 'http://www.shiwanimg.cn/images/loading.gif',
			close_image   : 'http://www.shiwanimg.cn/images/closelabel.gif'
    	})
	}
	jQuery.fn.loadthumb = function(options) {
		options = $.extend({
			 src : ""
		},options);
		var _self = this;
		_self.hide();
		var img = new Image();
		$(img).load(function(){
			_self.attr("src", options.src);
			_self.fadeIn("slow");
		}).attr("src", options.src);  //.atte("src",options.src)要放在load后面，
		return _self;
	}
	
	$(function(){
	  var i = 3;  //已知显示的<a>元素的个数
	  var m = 3;  //用于计算的变量
	  var $content = $("#myImagesSlideBox .scrollableDiv");
	  var count = $content.find("a").length;//总共的<a>元素的个数
	  //下一张
	  $(".next").live("click",function(){
			var $scrollableDiv = $(this).siblings(".items").find(".scrollableDiv");
			if( !$scrollableDiv.is(":animated")){  //判断元素是否正处于动画，如果不处于动画状态，则追加动画。
				if(m<count){  //判断 i 是否小于总的个数
					m++;
					$scrollableDiv.animate({left: "-=58px"}, 600);
				}
			}
			return false;
	  });
	   //上一张
	  $(".prev").live("click",function(){
			var $scrollableDiv = $(this).siblings(".items").find(".scrollableDiv");
			if( !$scrollableDiv.is(":animated")){
				if(m>i){ //判断 i 是否小于总的个数
					m--;
					$scrollableDiv.animate({left: "+=58px"}, 600);
				}
			}
			return false;
	  });
	
	  $(".scrollableDiv a").live("click",function(){
			var src = $(this).find("img").attr("imgb");
			var bigimgSrc = $(this).find("img").attr("bigimg");
			$(this).parents(".myImagesSlideBox").find(".myImgs").loadthumb({src:src}).attr("bigimg",bigimgSrc);
			$(this).addClass("active").siblings().removeClass("active");
			return false;
	  });
	  $(".scrollableDiv a:nth-child(1)").trigger("click");
		
	  $(".myImgs").live("click",function(){
			var bigimgSrc =$(this).attr("bigimg");
			var newImg=new Image();//新建立一个图片图象
			newImg.src=bigimgSrc;
			var imgWidth = newImg.width;
			var imgHeight = newImg.height;
			if(imgWidth > 1024)
				imgWidth = 1024;
			if(imgHeight > 768)
				imgHeight = 768;
			popZoom( bigimgSrc , imgWidth , imgHeight);
			return false;
	  });
	
		//以新窗口的方式打开图片
		var windowWidth  =$(window).width();
		var windowHeight  =$(window).height();
		function popZoom(pictURL, pWidth, pHeight) {
			var sWidth = windowWidth;
			var sHeight = windowHeight;
			var x1 = pWidth;
			var y1 = pHeight;
			var opts = "height=" + y1 + ",width=" + x1 + ",left=" + ((sWidth-x1)/2) +",top="+ ((sHeight-y1)/2)+",scrollbars=auto,menubar=0,Resizable=yes";
			pZoom = window.open("","", opts);
			pZoom.document.open();
			pZoom.document.writeln("<html><body  onblur='self.close();' style='margin:0;padding:0;'>");
			pZoom.document.writeln("<img src=\"" + pictURL + "\" >");
			pZoom.document.writeln("</body></html>");
			pZoom.document.close();
		}
	})
}
function copyToClipBoard(id){
	var clipBoardContent=document.getElementById(id).value || document.getElementById(id).innerHTML;
	//IE           
	if(window.clipboardData)
	{
		window.clipboardData.clearData();
		window.clipboardData.setData("Text", clipBoardContent);
		alert("复制成功");
	}
	//FireFox
	else if (window.netscape)
	{
		try
		{
		  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
		}
		catch (e)
		{
		  alert("您的firefox安全限制限制您进行剪贴板操作，请打开'about:config'将 signed.applets.codebase_principal_support'设置为true'之后重试");
		  return false;
		}
		var clip = Components.classes["@mozilla.org/widget/clipboard;1"].createInstance(Components.interfaces.nsIClipboard);
		if (!clip)
		  return;
		var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
		if (!trans)
		  return;
		trans.addDataFlavor('text/unicode');
		var str = new Object();
		var len = new Object();
		var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
		var copytext = clipBoardContent;
		str.data = copytext;
		trans.setTransferData("text/unicode",str,copytext.length*2);
		var clipid = Components.interfaces.nsIClipboard;
		if (!clip)
		return false;
		clip.setData(trans,null,clipid.kGlobalClipboard);
		alert("复制成功");
	}
	// other
	else{
		prompt('按Ctrl+C复制号码',clipBoardContent);
	}

}
// 评论插入图片JS
function commentUploadImg(url){
	if(url == undefined || url.length == 0)
	{
		url = 'http://www.shiwan.com/file/comment';
	}
	var button = $('#upload_button'), interval;
	var imgNum = 1;
	var imgId = "imgId";
	new AjaxUpload(button,{
		action: url, 
                name: 'myfile',
		onSubmit : function(file, ext){
			var imgId = "imgId" + imgNum;
			$("<div style='float:left;width:80px;margin:6px;'></div>").appendTo('#upload_state').html("正上传图"+ imgNum +"...");	
			imgNum = imgNum + 1;
		},
	
		onComplete: function(file, response){
			$('#upload_state div').html('');
			window.clearInterval(interval);
			$('<div></div>').appendTo('#files').html(response);						
		}
	});
}
// 上传图片JS
function uploadImg(){
	var button = $('#upload_button'), interval;
	new AjaxUpload(button,{
		//action: 'upload-test.php', // I disabled uploads in this example for security reasons
		action: '/file/accpic', 
                name: 'myfile',
		onSubmit : function(file, ext){
			// change button text, when user selects file			
			button.text('上传中');
			
			// If you want to allow uploading only 1 file at time,
			// you can disable upload button
			this.disable();
			
			// Uploding -> Uploading. -> Uploading...
			interval = window.setInterval(function(){
				var text = button.text();
				if (text.length < 13){
					button.text(text + '.');					
				} else {
					button.text('上传中');				
				}
			}, 200);
		},
		onComplete: function(file, response){
			button.text('上传图片');
						
			window.clearInterval(interval);
						
			// enable upload button
			this.enable();
			// add file to the list
			$('<div></div>').appendTo('#files').html(response);						
		}
	});
	var button1 = $('#upload_spicture'), interval1;
	new AjaxUpload(button1,{
		//action: 'upload-test.php', // I disabled uploads in this example for security reasons
		action: '/file/accspic', 
        name: 'myfile',
		onSubmit : function(file, ext){
			// change button text, when user selects file			
			button1.text('上传中');
			
			// If you want to allow uploading only 1 file at time,
			// you can disable upload button
			this.disable();
			
			// Uploding -> Uploading. -> Uploading...
			interval1 = window.setInterval(function(){
				var text = button1.text();
				if (text.length < 13){
					button1.text(text + '.');					
				} else {
					button1.text('上传中');				
				}
			}, 200);
		},
		onComplete: function(file, response){
			button1.text('上传密保卡');
						
			window.clearInterval(interval1);
						
			// enable upload button
			this.enable();
			/* add file to the list */
            $('#spicture').html(response);
		}
	});	
}

//upload spicture
function uploadSpic(button_id, input_id) {
	var button1 = $(button_id), interval1;
	new AjaxUpload(button1,{
		//action: 'upload-test.php', // I disabled uploads in this example for security reasons
		action: '/admin/file/adminaccspic', 
        name: 'myfile',
        data: {'format':'json'},
		onSubmit : function(file, ext){
			// change button text, when user selects file			
			button1.text('上传中');
			
			// If you want to allow uploading only 1 file at time,
			// you can disable upload button
			this.disable();
			
			// Uploding -> Uploading. -> Uploading...
			interval1 = window.setInterval(function(){
				var text = button1.text();
				if (text.length < 13){
					button1.text(text + '.');					
				} else {
					button1.text('上传中');				
				}
			}, 200);
		},
		onComplete: function(file, response){
			button1.text('上传密保卡');
						
			window.clearInterval(interval1);
						
			// enable upload button
			this.enable();
			/* add file to the list */
            $(input_id).val(response);
		}
	});	
}

function AdminUploadImgs(){
	var button = $('#upload_button'), interval;
	var imgNum = 1;
	var imgId = "imgId";
	new AjaxUpload(button,{
		//action: 'upload-test.php', // I disabled uploads in this example for security reasons
		action: '/admin/file/accpic', 
                name: 'myfile',
		onSubmit : function(file, ext){
			// change button text, when user selects file			
			// $('#upload_state').html("上传中");
			var imgId = "imgId" + imgNum;
			$("<div style='float:left;width:80px;margin:6px;'></div>").appendTo('#upload_state').html("正上传图"+ imgNum +"...");	
			// Uploding -> Uploading. -> Uploading...
			//interval = window.setInterval(function(){
//				var text = $('#upload_state').html();
//				if (text.length < 13){
//					$('#upload_state').html(text + '.');					
//				} else {
//					$('#upload_state').html('上传中');				
//				}
//			}, 200);
			imgNum = imgNum + 1;
		},
	
		onComplete: function(file, response){
			$('#upload_state div').html('');
			window.clearInterval(interval);
			$('<div></div>').appendTo('#files').html(response);						
		}
	});
}
// 同时可上传多张图片JS
function uploadImgs(){
	var button = $('#upload_button'), interval;
	var imgNum = 1;
	var imgId = "imgId";
	new AjaxUpload(button,{
		//action: 'upload-test.php', // I disabled uploads in this example for security reasons
		action: '/file/accpic', 
                name: 'myfile',
		onSubmit : function(file, ext){
			// change button text, when user selects file			
			// $('#upload_state').html("上传中");
			var imgId = "imgId" + imgNum;
			$("<div style='float:left;width:80px;margin:6px;'></div>").appendTo('#upload_state').html("正上传图"+ imgNum +"...");	
			// Uploding -> Uploading. -> Uploading...
			//interval = window.setInterval(function(){
//				var text = $('#upload_state').html();
//				if (text.length < 13){
//					$('#upload_state').html(text + '.');					
//				} else {
//					$('#upload_state').html('上传中');				
//				}
//			}, 200);
			imgNum = imgNum + 1;
		},
	
		onComplete: function(file, response){
			$('#upload_state div').html('');
			window.clearInterval(interval);
			$('<div></div>').appendTo('#files').html(response);						
		}
	});
	var button1 = $('#upload_spicture'), interval1;
	new AjaxUpload(button1,{
		//action: 'upload-test.php', // I disabled uploads in this example for security reasons
		action: '/file/accspic', 
        name: 'myfile',
		onSubmit : function(file, ext){
			// change button text, when user selects file			
			button1.text('上传中');
			
			// If you want to allow uploading only 1 file at time,
			// you can disable upload button
			this.disable();
			
			// Uploding -> Uploading. -> Uploading...
			interval1 = window.setInterval(function(){
				var text = button1.text();
				if (text.length < 13){
					button1.text(text + '.');					
				} else {
					button1.text('上传中');				
				}
			}, 200);
		},
		onComplete: function(file, response){
			button1.text('上传密保卡');
						
			window.clearInterval(interval1);
						
			// enable upload button
			this.enable();
			/* add file to the list */
            $('#spicture').html(response);
		}
	});	
}
function delImg(obj){
	var delobj = $(obj).parent();
	delobj.html("");
	delobj.hide();
}
// 显示、隐藏协商赔偿细节
function conferDetail(){
	var obj = document.getElementById("conferChk");
	if(obj.checked == true){
		$("#confer_detail").show();	
	}else{
		$("#confer_detail").hide();	
	}
}
// 验证是否为手机号码
function checkMobile(){   
	var mobileNO = document.mobileForm.mobile.value;
	if(mobileNO == ""){  
		$("#mobileTip").html("手机号码不能为空！");
		return false;
	}  
	var regu =/^[1]([3][0-9]{1}|59|58|50|51|52|53|82|88|89|57|55|56|86|87|85|80)[0-9]{8}$/;  
	var re = new RegExp(regu);  
	if (re.test(mobileNO)) {  
		 document.mobileForm.submit(); 
	}else{  
		 $("#mobileTip").html("手机号码错误！");
		 return false;  
	}  
}
// 站内短消息提示ajax请求
var webtitle = document.title;
var title_status_stop = false; 
function messageAjax(){
	var step = 0;
	var url = document.domain == "bbs.shiwan.com" ? "http://bbs.shiwan.com/msg/msgcall" : "http://www.shiwan.com/msg/msgcall";
	title_status_stop = true;
	
	callback_func = function(data, textStatus)
	{
		title_status_stop = false;
		if(data["count"] > 0){
			showTitle(step);
			$("#msgNum").html(data["count"]);
			$("#msgImg").removeClass("un_msg");
			$("#msgImg").addClass("new_msg");
		}else{
			stopTitle();
			$("#msgNum").html(data["count"]);
			$("#msgImg").removeClass("new_msg");
			$("#msgImg").addClass("un_msg");
		}
		var timer = setTimeout( "messageAjax()", 10000 );
		timer = null;
	};
	
	if (isCrossDomain(url)) 
    {
        crossDomainRequest("get", url, {format:"json"}, callback_func, "json");
    } 
	else 
    {
		$.ajax({
			type: "get",
			url: url,
	        dataType: "json",
			data :{format:"json"},
			success: callback_func
		});	
    }
}
function showTitle(step){
	if (title_status_stop)
	{
		return false;
	}
	
	step++
	if (step==3) {step=1;}
	if (step==1) {document.title="【　　　】"+webtitle;}
	if (step==2) {document.title="【新消息】"+webtitle;}
	var timer = setTimeout("showTitle('"+ step +"')",500);
	timer = null;
}
function stopTitle(){
	step = 0;
	title_status_stop = true;
    document.title=webtitle;
}
function commonCallbackDialog(data, textStatus, fun, isShowDialog)
{
	var html = data["html"];
	var type = data["type"];
	var title = data["title"];
	var button = data["button"];
	var need_refresh = data["refresh"];
	var showDialog = false;
	if (typeof(isShowDialog) == "undefined")
	{
		showDialog = true;
	}
	if(title == ""){
		title = "系统提示"	
	}
	if (button == 1){
		if(need_refresh == 1){
			var html = html + "<div class='opendiv_btn' style='margin-top:20px;'><input name='' type='button' value='确定' class='small_submit_btn' onclick= 'tb_remove();goNowUrl(\""+fun+"\");' /></div>";
		}else{
			var html = html + "<div class='opendiv_btn' style='margin-top:20px;'><input name='' type='button' value='确定' class='small_submit_btn' onclick= 'tb_remove();' /></div>";
		}
	}
	if(textStatus == "success"){
		var thickTtitle = title;
		var thickAlt = "#TB_inline?height=50&width=400&inlineId=dialogDiv";
		if (showDialog)
		{
			tb_show(thickTtitle,thickAlt,false);
		}
		$("#TB_ajaxContent").html(html);
	}
	if(textStatus == "error"){
		var thickTtitle = "错误提示";
		var error = "<p align=center><img src='http://www.shiwanimg.cn/images/tishi_ico.gif' align='absmiddle' /> 抱歉，页面出错啦！</p><div class='opendiv_btn' style='margin-top:20px;'><input name='' type='button' value='确定' class='TB_closeWindowButton small_submit_btn' onclick= 'tb_remove();' /></div>"
		var thickAlt = "#TB_inline?height=50&width=400&inlineId=dialogDiv";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html("");
		$("#TB_ajaxContent").html(error);
	}
}
function commonCallbackNoShowDialog(data, textStatus, fun)
{
	commonCallbackDialog(data, textStatus, fun, true);
}

function commonFormAjaxCallback(data, textStatus) {
	if (data["callback"] != undefined){
		for (var key in data["callback"]){
			eval(data["callback"][key] + "(data, textStatus)");
		}
	}else{
		commonCallbackDialog(data, textStatus);
	}
}

function commonFormAjax(buttonId,formId,url,fun){
	$(buttonId).click(function(){
		$(buttonId).attr("disabled","disabled");
		if(fun != undefined && fun.length == 0){
			var checkFun = eval(fun);
			if (checkFun == false){
				return false;
			}
		}
		dataString = $(formId).serialize();
		callback = function(data, textStatus) {
			$(buttonId).removeAttr("disabled");
			if (data["callback"] != undefined){
				for (var key in data["callback"]){
					eval(data["callback"][key] + "(data, textStatus)");
				}
			}else{
				commonCallbackDialog(data, textStatus);
			}
		};
		if (isCrossDomain(url)) {
			crossDomainRequest("post", url, dataString, callback, "json");
		} else {
			$.ajax({
				type: "post",
				url: url,
				data: dataString,
				dataType: "json",
				success: callback
			});	
		}
		return false;
    });
}

function redirect_to_url(data) {
    var url = data["args"]['redirect_url'];
    window.location = url;
}

function inner_to_div_flush(data){
	var html = data["args"]['add_div_html'];
	var div_id = data["args"]["add_div_id"];
	$("#" + div_id).html("");
	$("#" + div_id).html(html);
    setTimeout(function(){$("#" + div_id).html("");}, 10000);
}

function inner_to_div(data){
	var html = data["args"]['add_div_html'];
	var div_id = data["args"]["add_div_id"];
	$("#" + div_id).html("");
	$("#" + div_id).html(html);
}

function add_to_div(data){
	var html = data["args"]['add_div_html'];
	var div_id = data["args"]["add_div_id"];
	$("#" + div_id).append(html);
}

function add_to_div_before(data){
	var html = data["args"]['add_div_html'];
	var div_id = data["args"]["add_div_id"];
	if ($("#" + div_id).find("li").length > 0)
	{
		$("#" + div_id).find("li:first").before(html);
	}
	else
	{
		$("#" + div_id).append(html);
	}
}

function clear_form_by_class(data){
	var clear_form_input = data["args"]["class_name"];
	$("." + clear_form_input).attr('value','');
}

function add_to_input(data){
	for (var key in data["args"]['add_div_html']){
		var tags = data["args"]['add_div_html'][key];
		$("#tag_input").val($("#tag_input").val() + " " + tags);
	}
}

function addTags(tagsId){
	var tags = $("#"+tagsId).html();
	$("#tag_input").val($("#tag_input").val() + " " + tags);
}

// 刷新本页面
function goNowUrl(fun){
	if (fun == null || fun == "undefined")
	{
		window.location =window.location.href;
	}
	else
	{
		eval(fun);
	}
}

// 预定页面Tab标签切换ajax
function yudingTabAjax(tabnum,url,gameid,page){
	if (tabnum == 0 ){
		$("#type0").addClass("active");	
		$("#type1").removeClass("active");
		$("#type2").removeClass("active");
		$("#yudingTab_content0").removeClass("none");
		$("#yudingTab_content1").addClass("none");
		$("#yudingTab_content2").addClass("none");
	}else if(tabnum == 1){
		$("#type0").removeClass("active");
		$("#type1").addClass("active");	
		$("#type2").removeClass("active");
		$("#yudingTab_content0").addClass("none");
		$("#yudingTab_content1").removeClass("none");
		$("#yudingTab_content2").addClass("none");
	}else{
		$("#type0").removeClass("active");
		$("#type1").removeClass("active");	
		$("#type2").addClass("active");
		$("#yudingTab_content0").addClass("none");
		$("#yudingTab_content1").addClass("none");
		$("#yudingTab_content2").removeClass("none");
	}
	$("#yudingTab_content" + tabnum).html("<div style='padding:30px;text-align:center;'><img src='http://www.shiwanimg.cn/images/loading.gif'/></div>");
	$.ajax({
		type: "get",
		url: url,
		data :{gameid:gameid,page:page,format:"html"},
		success: function(data, textStatus){
			$("#TabContent div").html("");
			$("#yudingTab_content" + tabnum).html(data);
		}
	});
}
// 试玩心得Tab标签切换ajax
function xindeTabAjax(tabnum,url,gameid,page){
	if (tabnum == 0 ){
		$("#type0").addClass("active");	
		$("#type1").removeClass("active");
		$("#xindeTab_content0").removeClass("none");
		$("#xindeTab_content1").addClass("none");
	}else{
		$("#type0").removeClass("active");
		$("#type1").addClass("active");	
		$("#xindeTab_content0").addClass("none");
		$("#xindeTab_content1").removeClass("none");
	}
	$("#xindeTab_content" + tabnum).html("<div style='padding:30px;text-align:center;'><img src='http://www.shiwanimg.cn/images/loading.gif'/></div>");
	$.ajax({
		type: "get",
		url: url,
		data :{gameid:gameid,page:page,format:"html"},
		success: function(data, textStatus){
			$("#TabContent div").html("");
			$("#xindeTab_content" + tabnum).html(data);
		}
	});
}
// -------- 新试玩评论JS begin ---------
// 1、显示和隐藏回复
function toggleCommentReply(divObj){
	$(".comment_reply_div:not(" +"#" + divObj + ")").hide(); 
	$("#"+divObj).toggle();
}
// 2、插入图片
	function insertImg(title,url,imglistId){
		$('#weibo_face').hide();
		var thickTtitle = "插入图片";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		
		callback_func = function(data, textStatus)
		{
			tb_show(thickTtitle,thickAlt,false);
			$("#TB_ajaxContent").html(data);
		};
		
		if (isCrossDomain(url)) 
	    {
	        crossDomainRequest("get", url, {format:"html"}, callback_func, "html");
	    } 
		else 
	    {
			if(imglistId == undefined || imglistId.length == 0)
			{
				imglistId = "showimglist";
			}
			$.ajax({
				type: "get",
				url: url,
				data :{"format":"html","imglistId":imglistId},
				success: callback_func
			});	
	    }
	}
	
	function clearInfo(){
		$('#imgError').html('');	
	}
	
	function insertImgSubmit(imglistId){
		if(imglistId == undefined || imglistId.length == 0)
		{
			imglistId = "showimglist";
		}
		var imgInput = $("#imgInput").val();
		var imgInput = imgInput.replace(/(^\s*)|(\s*$)/g, ""); //去空格
		var imgType = imgInput.substring(imgInput.length-4,imgInput.length); //图片类型
		if(imgInput == "http://" || imgInput==""){
			$("#imgError").html("图片链接不能为空!");
		}else if(imgType != ".gif" && imgType !=".jpg" && imgType !=".bmp" && imgType != ".png"){
			$("#imgError").html("输入链接有误，请重试!");
		}else{
			var html = "<li><img src=" + imgInput + " width=62 height=45/><img border='0' style='cursor: pointer;border:none;' title='删除此图片' onclick='delImg(this);' src='http://www.shiwanimg.cn/images/del_ico.gif'><input type='hidden' value='" + imgInput + "' name='picture[]'></li>";
			$("#"+imglistId).append(html);
			tb_remove();
		}				  
	}
	
	function insertUploadImgSubmit(callback, imglistId)
	{
		var imgsUrl = "";
		var html = "";
		var hiddenUrl = "";
		var url = "";
		if ($("#files .uploadpic"))
		{
			$.each($("#files .uploadpic"),function(i,obj){
				imgsUrl = obj.src;
				hiddenUrl = $(obj).attr("ret");
				url = $(obj).attr("rett");
				html += "<li><img src=" + imgsUrl + " width=62 height=45/><img border='0' style='cursor: pointer;border:none;' title='删除此图片' onclick='delImg(this);' src='http://www.shiwanimg.cn/images/del_ico.gif'><input type='hidden' value='" + hiddenUrl + "' name='picture[]'></li>";
			});
		}
		if (hiddenUrl == "")
		{
			alert("请插入图片！");
			return;
		}
		
		if (typeof(callback) == "undefined" || callback.length == 0)
		{
			if(imglistId == undefined || imglistId.length == 0)
			{
				imglistId = "showimglist";
			}
			$("#" + imglistId).append(html);
			tb_remove();
		}
		else
		{
			eval(callback(url));
		}
	}
	
// 3、插入视频
	function insertVideo(videolistId, customFunc){
		if(videolistId == undefined || videolistId.length == 0)
		{
			videolistId = "showimglist";
		}
		var appendStr = '';
		if (customFunc != undefined)
		{
			appendStr = ', ' + '"' + customFunc + '"';
		}
		$('#weibo_face').hide();
		var thickTtitle = "插入视频";
		var thickAlt = "#TB_inline?height=100&width=500&inlineId=dialogDiv";
		var imgInfo = "<div align='center' style='padding-top:10px;'>视频地址：<input value='http://' id='videoInput' type='text' size='45' onfocus='this.select();clearVideoInfo();'/><br/><p style='color:#888'>请输入优酷、土豆、新浪视频、酷6等视频播放页的网址<br />(暂不支持wmv，avi，rmvb，mov，swf，flv等视频格式)</p><div align='center' style='height:13px;padding-top:6px;' class='red' id='videoError'></div></div><div class='opendiv_btn' style='margin-top:20px;'><input name='' type='button' value='插入视频' class='small_submit_btn' id='insertSubmit' onclick='insertVideoSubmit(\"" + videolistId + '"' + appendStr + ");' /></div";
		tb_show(thickTtitle,thickAlt,false);
		$("#TB_ajaxContent").html("");
		$("#TB_ajaxContent").html(imgInfo);	
	}
	
	function clearVideoInfo(){
		$('#videoError').html('');	
	}
	
	function insertVideoSubmit(videolistId, customFunc){
		if(videolistId == undefined || videolistId.length == 0)
		{
			videolistId = "showimglist";
		}
		var videoInput = $("#videoInput").val();
		var videoInput = videoInput.replace(/(^\s*)|(\s*$)/g, ""); //去空格
		var videoType = videoInput.substring(videoInput.length-4,videoInput.length); //视频类型
		if(videoInput == "http://" || videoInput==""){
			$("#videoError").html("视频链接不能为空!");
		}else{
			var html = "<li><img src='http://www.shiwanimg.cn/images/pinglun/video_img.gif' width=62 height=45/><img border='0' style='cursor: pointer;border:none;' title='删除此视频' onclick='delImg(this);' src='http://www.shiwanimg.cn/images/del_ico.gif'><input type='hidden' value='" + videoInput + "' name='video'></li>";
			if (customFunc != undefined)
			{
				$.globalEval(customFunc + '("'+ videoInput + '");');
			} else {
				$("#"+videolistId).append(html);
			}
			tb_remove();
		}				  
	}

// 4、改变图片大小
function drawImage(ImgD,iwidth,iheight){
	var image=new Image();   
	image.src=ImgD.src;   
	if(image.width>0 && image.height>0){   
		if(image.width/image.height>= iwidth/iheight){   
			if(image.width>iwidth){     
				ImgD.width=iwidth;   
				ImgD.height=(image.height*iwidth)/image.width;   
			}else{   
				ImgD.width=image.width;     
				ImgD.height=image.height;   
			}   
		}else{   
			if(image.height>iheight){     
				ImgD.height=iheight;   
				ImgD.width=(image.width*iheight)/image.height;           
			}else{   
				ImgD.width=image.width;     
				ImgD.height=image.height;   
			}   
		}   
	}   
}   
// -------- 新试玩评论JS end ---------

// 链接到快速试玩帐号/试玩帐号标签
function linkToTabs(tabId,contentId){
	$("ul.listgametabs li").removeClass("active"); 
	$("#"+tabId).addClass("active"); 
	$(".listgame_content").hide(); 
	var activeTab = "#"+contentId;
	var tabHtml = $(activeTab).html();
	var tabObj = $(activeTab);
	var first = activeTab;
	var serverid = document.getElementById("serverid").value;
	var userid = document.getElementById("userid").value;
	var current = $(this);
	if(tabHtml ==''){
		gameListAjax(userid,serverid,tabObj,activeTab);
		$("#loading").show();
	}
	$(activeTab).fadeIn();
}

// 新版专区链接到快速试玩帐号/试玩帐号标签
function linkToNewTabs(tabId){
	$("ul.listgametabs_subject li").removeClass("active"); 
	$("#"+tabId).addClass("active"); 
}

// 投票JS  ----------
// 1、添加印象
function addImpression(obj){
	if(obj == "vote_input"){
        impress = $("#vote_input").val();
        impress = $.trim(impress);
        if(impress.length == 0)
            return false;
		var impression = $("#vote_input").val();
	}else{
		var impression = $(obj).html();
	}
	var html = "";
	html = "<tt>"+ impression +"<img src='http://www.shiwanimg.cn/images/del_ico.gif' border='0'  onclick='delImg(this);' /><input name='word[]' type='hidden' value='"+ impression +"' /></tt>"; 
	var exist = false;
    $('#keywords tt').each(function(){
        if($(this).html()==$(html).html() || impression=='')
        {
             exist = true;
             return false;
        }
    });
    
    if(exist == false)
    {
        $('#keywords').html($(html));
		$("#vote_input").val("");
    }
}

function commonAjaxPost(url, dataString, method){
    callback = function(data, textStatus) {
	    if (data["callback"] != undefined){
		    for (var key in data["callback"]){
			    eval(data["callback"][key] + "(data, textStatus)");
		    }
	    }else{
		    commonCallbackDialog(data, textStatus);
	    }
    };
    var _method = method;
    if (typeof(method) == "undefined")
	{
    	_method = "post";
	}
	if (isCrossDomain(url)) {
		crossDomainRequest(_method, url, dataString, callback, "json");
	} else {
		$.ajax({
			type: _method,
			url: url,
			data: dataString,
			dataType: "json",
			success: callback
		});	
	}
    return false;            
}

/* 首页游戏分类控制游戏个数js */
function fitString(html, max_width) {
   var temp_div = $('<div id="temp_div" style="display:none;"></div>')
   $("body").append(temp_div);
   temp_div.html(html);
   var width = temp_div.width()+42;
   if (width < max_width) {
	   temp_div.remove();
	   return html;
   } else {
	   $('a:last-child', temp_div).remove()
	   html = temp_div.html();
	   temp_div.remove();
	   return fitString(html, max_width);
   }
}
function fitWidth(div,max_width) {
	 if(max_width == undefined){
		max_width = $(div).width();
	 }
	 html = fitString($(div).html(), max_width);
	 $(div).html(html);
}
/* 
 * js兼容性扩展方法
 * outerHTML
 * outerHTML（*）
 * canHaveChildren
 * */
if(typeof(HTMLElement)!="undefined" && !window.opera) 
{ 
    HTMLElement.prototype.__defineGetter__("outerHTML",function() 
    { 
        var a=this.attributes, str="<"+this.tagName, i=0;for(;i<a.length;i++) 
        if(a[i].specified) 
            str+=" "+a[i].name+'="'+a[i].value+'"'; 
        if(!this.canHaveChildren) 
            return str+" />"; 
        return str+">"+this.innerHTML+"</"+this.tagName+">"; 
    }); 
    HTMLElement.prototype.__defineSetter__("outerHTML",function(s) 
    { 
        var r = this.ownerDocument.createRange(); 
        r.setStartBefore(this); 
        var df = r.createContextualFragment(s); 
        this.parentNode.replaceChild(df, this); 
        return s; 
    }); 
    HTMLElement.prototype.__defineGetter__("canHaveChildren",function() 
    { 
        return !/^(area|base|basefont|col|frame|hr|img|br|input|isindex|link|meta|param)$/.test(this.tagName.toLowerCase()); 
    }); 
}

/* 点评打分方法 */
function shiwanRatying(){
	$('#form0 :radio.star').rating();
	$('#form0 div').click(function(){
		$('.ratying_num0').html('');
		$('#form0 input').each(function(){
			if(this.checked) $('.ratying_num0').html(this.value);
		});
	});
	$('#form0 div').mouseover(function(){
		$('.ratying_num0').html('');
		var cur_ratying = $(this).find("a").html();
		$('.ratying_num0').html(cur_ratying);
	});
	$('#form0 div').mouseout(function(){
		$('.ratying_num0').html('');
		$('#form0 input').each(function(){
			if(this.checked) $('.ratying_num0').html(this.value);
		});
	});
	
	$('#form1 :radio.star').rating();
	$('#form1 div').click(function(){
		$('.ratying_num1').html('');
		$('#form1 input').each(function(){
			if(this.checked) $('.ratying_num1').html(this.value);
		});
	});
	$('#form1 div').mouseover(function(){
		$('.ratying_num1').html('');
		var cur_ratying = $(this).find("a").html();
		$('.ratying_num1').html(cur_ratying);
	});
	$('#form1 div').mouseout(function(){
		$('.ratying_num1').html('');
		$('#form1 input').each(function(){
			if(this.checked) $('.ratying_num1').html(this.value);
		});
	});
	
	$('#form2 :radio.star').rating();
	$('#form2 div').click(function(){
		$('.ratying_num2').html('');
		$('#form2 input').each(function(){
			if(this.checked) $('.ratying_num2').html(this.value);
		});
	});
	$('#form2 div').mouseover(function(){
		$('.ratying_num2').html('');
		var cur_ratying = $(this).find("a").html();
		$('.ratying_num2').html(cur_ratying);
	});
	$('#form2 div').mouseout(function(){
		$('.ratying_num2').html('');
		$('#form2 input').each(function(){
			if(this.checked) $('.ratying_num2').html(this.value);
		});
	});
	
	$('#form3 :radio.star').rating();
	$('#form3 div').click(function(){
		$('.ratying_num3').html('');
		$('#form3 input').each(function(){
			if(this.checked) $('.ratying_num3').html(this.value);
		});
	});
	$('#form3 div').mouseover(function(){
		$('.ratying_num3').html('');
		var cur_ratying = $(this).find("a").html();
		$('.ratying_num3').html(cur_ratying);
	});
	$('#form3 div').mouseout(function(){
		$('.ratying_num3').html('');
		$('#form3 input').each(function(){
			if(this.checked) $('.ratying_num3').html(this.value);
		});
	});	
}

// 选择特色 
function ch_features(obj){
	var ft_Id = obj.id;
	if(obj.className != "uncur"){
		var ft_len = $(".features_list span.cur").length;
		if(obj.className == "cur") {
			ft_len = ft_len-2;
			var cur_input = $(obj).find("input");
			$(cur_input).remove();
		}else{
			var cur_input_val = $(obj).text();
			$(obj).append("<input type=hidden name=ft[] value="+ cur_input_val +" />");	  
		}
		$(obj).toggleClass("cur");
		if(ft_len >1){
			var active_span = $(".features_list").find("span.cur");
			$(".features_list span").attr("class","uncur");
			$(active_span).attr("class","cur");
			//$(".feature_btn").attr("disabled","disabled");
			return false;
		}else{
			 $(".features_list span.uncur").attr("class","");
			 //$(".feature_btn").removeAttr("disabled");
		}
	}
}
// 显示更多特色
function show_features(obj){
	$(obj).remove();
	$("#features1 span:last").after($("#features2").html());
	$("#features2").remove();
}
function open_ft(obj){
	$(obj).hide();
	var new_html = $("#raty_list1").html();
	$("#close_ft").show();
	$("#raty_list1").append($("#raty_list2").html());
	$("#close_ft").click(function(){
		$(this).hide();
		$(obj).show();
		$("#raty_list1").html(new_html);
	});
}

// 添加特色
function add_feature(){
	var ft_val = $(".feature_input").val();
	ft_val = ft_val.replace(/(^\s*)|(\s*$)/g, "");
	var ft_val_len = ft_val.length;
	var ft_len = $(".features_list span.cur").length;

		if(ft_val_len <2 || ft_val_len >10)
		{
				$("#feature_mess").html("特色的字数为2－10！");
		}
		else if(ft_len >2){
			$("#feature_mess").html("最多选择三个特色！");
		}else
		{
			if(exist_ft()){
				$("#feature_mess").html("添加成功！");
				var html = "<span onclick='ch_features(this);' class='cur'>"+ ft_val +"<input type='hidden' name='ft[]' value="+ ft_val +" /></span>";
				$("#features1 #mark").before(html);
				//$(".add_features").hide();
				isallowChange();
			}
		}
}
// 判断是否大于3个判断
function isallowChange(){
	var ft_len = $(".features_list span.cur").length;
	if(ft_len >2)
	{
		var active_span = $(".features_list").find("span.cur");
		$(".features_list span").attr("class","uncur");
		$(active_span).attr("class","cur");	
	}	
}

// 遍历特色 判断是否存在
function exist_ft(){
	var len = $(".features_list span").length;
	var n = 0;
	$(".features_list span").each(function(i,obj){
		var ft_val = $(".feature_input").val();
		var ft_txt = $(obj).text();
		if(obj.className != "cur" && ft_txt == ft_val){
			$("#feature_mess").html("特色已存在！");
			var new_obj = obj;
			$("#features1 #mark").before(new_obj);
			$(new_obj).addClass("cur");
			isallowChange();
			return false; 
		}else if(obj.className == "cur" && ft_txt == ft_val)
		{
			$("#feature_mess").html("特色已存在！");
			return false; 
		}
		n = n+1;
	});
	if(n == len)
	{
		return true;
	}
	else{
		return false;
	}
}
// 评论框判断还可以输入的字数
function test_num(num,typeName){
	if(typeName == "dianping"){
		$("#showNum").show();
		var comment_val = $(".comment_textarea").val();
		comment_val = comment_val.replace(/(^\s*)|(\s*$) | \s* |，*/g, "");
		comment_val = comment_val.replace(/\./g,"");
		var len = comment_val.length;  
		var slen = num - len; 
		if(num - len < 1){
			$("#showNum").hide();
		}else{
			$("#comment_num").html(slen);
		}
	}
	if(typeName == "feature"){
		var feature_val = $(".feature_input").val();
		feature_val = feature_val.replace(/(^\s*)|(\s*$)/g, "");
		var len = feature_val.length;
		var slen = len - num;
		if(slen > 0){
			$("#feature_mess").html("超出"+slen+"个字");
		}else{
			$("#feature_mess").html("");	
		}
	}
	if(typeName == "publish"){
		var for_val = $("#title").val();
		for_val = for_val.replace(/(^\s*)|(\s*$)/g, "");
		var len = for_val.length;
		var slen = num - len; 		
		if(slen < 0){			
			for_val = for_val.substring(0,99);			
			$("#publish_num").html('已超出字数限制!');
		}else{
			$("#publish_num").parent().show();
			$("#publish_num").html(slen);
		}
	}
	if(typeName == "weibo"){
		var weibo_val = $("#post_editor").val();
		weibo_val = weibo_val.replace(/(^\s*)|(\s*$)/g, "");
		var len = weibo_val.length;
		var slen = num - len;
		var clen = len -num ;
		if(clen > 0){
			$(".post_info").html("你已超出<span id='weiboNum'>"+clen+"</span>字");
		}else{
			$(".post_info").html("你还可以输入<span id='weiboNum'>"+slen+"</span>字");
		}
	}
	if(typeName == "forward"){
		var forward_val = $(".forward_input").val();
		forward_val = forward_val.replace(/(^\s*)|(\s*$)/g, "");
		var len = forward_val.length;
		var slen = num - len;
		var clen = len -num ;
		if(clen > 0){
			$(".forward_num").html("已超出<b id='forwardNum'>"+clen+"</b>字");
		}else{
			$(".forward_num").html("还可以输入<b id='forwardNum'>"+slen+"</b>字");
		}
	}
	if(typeName == "msg"){
		var msg_val = $("#post_msg").val();
		msg_val = msg_val.replace(/(^\s*)|(\s*$)/g, "");
		var len = msg_val.length;
		var slen = num - len;
		var clen = len -num ;
		if(clen > 0){
			$("#leaveWord").html("你已超出<b class='num'>"+clen+"</b>字");
		}else{
			$("#leaveWord").html("你还可以输入<b class='num'>"+slen+"</b>字");
		}
	}
}

//提交点评后按钮不可用
function checkclick(id){
	var tmpBtValue=document.getElementById(id).value;
	document.getElementById(id).disabled = true;
	document.getElementById(id).value = "3";
	setTimeout("document.getElementById(\""+id+"\").value = '2'",1000);
	setTimeout("document.getElementById(\""+id+"\").value = '1'",2000);
	setTimeout("document.getElementById(\""+id+"\").value = '"+tmpBtValue+"'",3000);
	setTimeout("document.getElementById(\""+id+"\").disabled = false",3000);
}

// 首页游戏目录……显示更多特色
function moreFeaturesIndex(){
	$(".dir_ft2").show();
	$("#open_features_index").hide();
	$("#close_features_index").show();
	$("#close_features_index").click(function(){
		$("#open_features_index").show();
		$("#close_features_index").hide();
		$(".dir_ft2").hide();
	});
}

// 首页游戏目录……显示更多厂商
function moreGameCompany(){
	$("#open_gameCompany").remove();
	$("#gameCompany span:last").after($("#gameCompany2").html());
}

// 首页游戏目录……游戏搜索匹配
function shiwanSearch(){
	var searchKey = $(".search_key").val();
	searchKey=searchKey.replace(/^\s*|\s*$/g,'');
	var searchEnd = "";
	if(searchKey =="" || searchKey == "游戏名"){
		$("#game_search_result").hide();
	}else{
		$.each($("#searchgamelist").children(),function(i,obj){
			var optionId = obj.value;
			var optionName = obj.text;
			var optionSname = obj.getAttribute("sname");
			var optionFname = obj.getAttribute("fname");
			var optionUrl = obj.getAttribute("url");
			var searchName = optionName.indexOf(searchKey);
			var searchSname = optionSname.indexOf(searchKey);
			var searchFname = optionFname.indexOf(searchKey);
			if(searchName != -1 || searchSname != -1 || searchFname != -1){
				searchEnd += '<option value=' + optionId+'>' + optionName + '</option> ';
			}
		});
		if(searchEnd == ""){
			$("#game_search_result").html();
			$("#game_search_result").hide();	
		}else{
			$("#game_search_result").show();
			$("#gameId").html("");
			$("#gameId").html(searchEnd);
		}
	}
}

// 首页游戏目录……游戏搜索匹配
var highlightindex = -1;
function shiwanAutoSearch(event){
	var myEvent = event || window.event;
    var keyCode = myEvent.keyCode;//获得键值
	var searchKey = $("#autoSearch_key").val();
	searchKey=searchKey.replace(/^\s*|\s*$/g,'');
	var searchEnd = "";
	var id = 0;
	if (keyCode >= 65 && keyCode <= 90 || keyCode == 8 || keyCode == 46 || keyCode == 32){
		if(searchKey =="" || searchKey == "游戏名"){
			$("#autoSearch_result").hide();
			highlightindex = -1;
		}else{
			$.each($("#autosearchgamelist").children(),function(i,obj){
				var optionId = obj.value;
				var optionName = obj.text;
				var optionSname = obj.getAttribute("sname");
				var optionFname = obj.getAttribute("fname");
				var optionUrl = obj.getAttribute("url");
				var searchName = optionName.indexOf(searchKey);
				var searchSname = optionSname.indexOf(searchKey);
				var searchFname = optionFname.indexOf(searchKey);
				if(searchName != -1 || searchSname != -1 || searchFname != -1){
					searchEnd += '<li id='+ id +'>'+optionName+'</li> ';
					id ++;
				}
			});
			if(searchEnd == ""){
				$("#autoSearch_result").html();
				$("#autoSearch_result").hide();	
				highlightindex = -1;
			}else{
				var xleft = $("#autoSearch_key").offset().left;
				var xtop = 	$("#autoSearch_key").offset().top;
				$("#autoSearch_result").css({left:xleft,top:xtop+30});
				$("#autoSearch_result").show();
				$("#autoGameId").html("");
				$("#autoGameId").html(searchEnd);
				var newDivNode = $("#autoGameId li");
				
				newDivNode.click(function(){
					$("#autoSearch_key").val($(this).html());
					$("#autoSearch_result").hide();
					highlightindex = -1;
					autoGo();
				});
				
				newDivNode.mouseover(function(){
					if (highlightindex != -1) {
						$("#autoGameId").children("li").eq(highlightindex).removeClass("active");
					}
					highlightindex = $(this).attr("id");
					$(this).addClass("active");									  
				});
				
				newDivNode.mouseout(function() {
					if (keyCode == 13) {
						if (highlightindex != -1) {
							highlightindex = -1;
						} else {
							autoHide();
							$("#autoSearch_key").get(0).blur();//让文本框失去焦点
						}
					}
				});

//				$("#autoSearch_key").blur(function(){
//					setTimeout($("#autoSearch_result").hide(),10000);
//				});				
		
			}
		}
	}
	else if (keyCode == 38 || keyCode == 40){
		if (keyCode == 38) {
			var autoNodes = $("#autoGameId").children("li").removeClass("active");
			if (highlightindex != -1) {
				autoNodes.eq(highlightindex).removeClass("active");
				highlightindex--;
			} else {
				highlightindex = autoNodes.length - 1;
			}
			if (highlightindex == -1) {
				highlightindex = autoNodes.length - 1;//如果改变索引值后index变成-1，则将索引值指向最后一个元素
			}
			autoNodes.eq(highlightindex).addClass("active");
		}
		if (keyCode == 40) {
			var autoNodes = $("#autoGameId").children("li");
			if (highlightindex != -1) {
				autoNodes.eq(highlightindex).removeClass("active");
			}
			highlightindex = highlightindex+1;
			if (highlightindex == autoNodes.length) {
				highlightindex = 0;//如果改变索引值等于最大长度，则将索引值指向第一个元素
			}
			autoNodes.eq(highlightindex).addClass("active");
		}
	}
	else if (keyCode == 13){
		var nodeActive = $("#autoGameId").find("li.active");
		var autoNodes = $("#autoGameId").children("li").eq(highlightindex);
		if(nodeActive.length != 0){
			$("#autoSearch_key").val(autoNodes.html());
		}
		autoGo();

	}
}

function autoGo(){
	if($("#autoSearch_key").val() == "输入游戏名，快速找到游戏的点评" || $("#autoSearch_key").val() == "输入应用名，快速找到应用的点评"){
		$("#autoSearch_key").val("");	
	}
	var cateId = $("#cateId").val();
	self.location = "http://www.shiwan.com/gamedir/index/c1/"+cateId+"?g=" + $("#autoSearch_key").val();		
}

// 首页游戏目录……回车响应搜索
function EnterShiwanSearch(){
	var searchKey = $(".search_key").val();
	searchKey=searchKey.replace(/^\s*|\s*$/g,'');
	var searchEnd = "";
	if(searchKey =="" || searchKey == "游戏名"){
		return false;
	}else{
		$.each($("#searchgamelist").children(),function(i,obj){
			var optionId = obj.value;
			var optionName = obj.text;
			var optionSname = obj.getAttribute("sname");
			var optionFname = obj.getAttribute("fname");
			var optionUrl = obj.getAttribute("url");
			var searchName = optionName.indexOf(searchKey);
			var searchSname = optionSname.indexOf(searchKey);
			var searchFname = optionFname.indexOf(searchKey);
			if(optionName == searchKey || optionSname == searchKey || optionFname == searchKey){
				searchEnd = optionName;
				self.location = "http://www.shiwan.com/gamedir/index/gameId/" + optionId;
			}
		});
		if(searchEnd ==""){alert("请输入完整的游戏名");}
	}
}

// 首页游戏目录……搜索关键字
function getSearchKey(){
	var select_url= $("#gameId").val();
	var select_key= $("#gameId option:selected").text();
	$("#searchUrl").val(select_url);
	$(".search_key").val(select_key);
	$("#game_search_result").hide();
	eval("parent.location='http://www.shiwan.com/gamedir/index/gameId/"+ select_url +"'");
}
// 首页游戏目录……搜索跳转
function gotoSubject(){
	var url = $("#searchUrl").val();
	if(url == ""){
		alert("请输入完整游戏名");
	}else{
		self.location = "http://www.shiwan.com/gamedir/index/gameId/" + url;
	}
}

// 试玩微博js …………转发微博
function tForward(id,oid,url,ishtml,title){
	$.ajax({
		type: "get",
		url: url,
		dataType: "json",
		data :{ishtml:ishtml,id:id,oid:oid,format:"json"},
		success: function(data, textStatus){
			if(typeof(title) == "undefined"){
				var thickTtitle = "转发到我的微博";
			}else{
				var thickTtitle = title;	
			}
			var thickAlt = "#TB_inline?height=100&width=400&inlineId=dialogDiv";
			tb_show(thickTtitle,thickAlt,false);
			$("#TB_ajaxContent").html(data["html"]);
		}
	});	
}

//转发微博回调js
function tForwardCallback(data)
{
	// 转发...
	var div_id = data["args"]["span_id"];
	var div_id_value = parseInt($("."+div_id).find("a.forward").find("label").html()) + 1;
	$("."+div_id).find("a.forward").find("label").html(div_id_value);
}

// 试玩微博js …………加关注
/*function tFollow(uid,url,type,obj, isLogin){
	if (url == 0)
	{
		url = "http://www.shiwan.com/weibo/concernadd";
	}
	var attObj = $(obj).parent().parent();
	var attClass = $(obj).attr("class");
	
	if (typeof(isLogin) == "undefined")
	{
		attObj.html("<img src='http://www.shiwanimg.cn/images/weibo/loading.gif' style='margin-top:4px;' />");
		callback = function(data, textStatus) 
		{
			if(type == 0 || type == 1){
				attObj.html("<span id='concern_cancel'>已关注 <a href='javascript:void(0);' class='wblue' onclick=\"tFollow("+uid+",'"+url+"',2,this)\">取消</a></span>");
			}else{
				attObj.html("<span><a href='javascript:void(0);' class='concern_add' onclick=\"tFollow("+uid+",'"+url+"',0,this)\">+ 加关注</a></span>");	
			}
		};
	}
	else
	{
		callback = function(data, textStatus) 
		{
			if (data["callback"] != undefined){
				for (var key in data["callback"]){
					eval(data["callback"][key] + "(data, textStatus)");
				}
			}else{
				commonCallbackDialog(data, textStatus);
			}
		};
	}
	if (isCrossDomain(url)) 
	{
		formatType = "json";
		dataString = "type="+type+"&uid="+uid+"&format="+formatType;
		crossDomainRequest("get", url, dataString, callback, formatType);
	}
	else
	{
		$.ajax({
			type: "get",
			url: url,
			dataType: "json",
			data :{type:type,uid:uid,format:"json"},
			success: callback
		});	
	}
}
*/

// 试玩微博js …………加关注
function tFollow(uid,url,type,obj, isLogin){
	//var attObj = $(obj);
	if (url == 0)
	{
		url = "http://www.shiwan.com/weibo/concernadd";
	}
	
	if (typeof(isLogin) == "undefined")
	{
		callback = function(data, textStatus) 
		{
			if(type == 0 || type == 1){
				$(obj).hide();
				//alert($(obj).parent().html());
				$(obj).parent().find("div.list_cancle").show();
			}else{  
				$('.concern_add').show();
				$(obj).parent().hide();
				$(obj).parent().parent().find("div.list_add").show();
			
			}	
		};
	}
	else
	{
		callback = function(data, textStatus) 
		{
			if (data["callback"] != undefined){
				for (var key in data["callback"]){
					eval(data["callback"][key] + "(data, textStatus)");
				}
			}else{
				commonCallbackDialog(data, textStatus);
			}
		};
	}
	if (isCrossDomain(url)) 
	{
		formatType = "json";
		dataString = "type="+type+"&uid="+uid+"&format="+formatType;
		crossDomainRequest("get", url, dataString, callback, formatType);
	}
	else
	{
		$.ajax({
			type: "get",
			url: url,
			dataType: "json",
			data :{type:type,uid:uid,format:"json"},
			success: callback
		});	
	}
}

//试玩微博js …………加关注
function tFollowConfirm(uid,type, id){
	url = "http://www.shiwan.com/weibo/concernadd";
	callback = function(data, textStatus) 
	{
		if(type != 1)
		{
			commonAjaxPost('http://www.shiwan.com/trade/buynow', 'format=json&id='+id, 'get');
		}
		else
		{
			commonCallbackDialog(data, textStatus);
		}
	};
	if (isCrossDomain(url)) 
	{
		formatType = "json";
		dataString = "type=1&uid="+uid+"&format="+formatType;
		crossDomainRequest("get", url, dataString, callback, formatType);
	}
	else
	{
		$.ajax({
			type: "get",
			url: url,
			dataType: "json",
			data :{type:"1",uid:uid,format:"json"},
			success: callback
		});	
	}
}

function tFollowGameConfirmWithNextStep(gameid){
	url = "http://www.shiwan.com/weibo/concernadd";
	callback = function(data, textStatus) 
	{
		gtc_id = $("#gameFllowNotice").attr('gtc_id');
		getCodeAjax(gtc_id,'http://www.shiwan.com/testcode/get');
	};
	if (isCrossDomain(url)) 
	{
		formatType = "json";
		dataString = "type=1&uid="+gameid+"&format="+formatType;
		crossDomainRequest("get", url, dataString, callback, formatType);
	}
	else
	{
		$.ajax({
			type: "get",
			url: url,
			dataType: "json",
			data :{type:"1",uid:gameid,format:"json"},
			success: callback
		});	
	}
}
// 试玩微博js …………检查发布微博
function checkPostWeibo(url){
	var weibo_val = $("#post_editor").val();
	weibo_val = weibo_val.replace(/(^\s*)|(\s*$)/g, "");
	var len = weibo_val.length;
	if(len == 0 || len > 600){
		setTimeout("$('#post_editor').css({background: '#FBD0D0' });",200);
		setTimeout("$('#post_editor').css({background: '#FBDDDD' });",400);
		setTimeout("$('#post_editor').css({background: '#FEF0F0' });",600);
		setTimeout("$('#post_editor').css({background: '#fff' });",800);
	}else{
		$("#comment_post_btn").attr("disabled","disabled");
		commonFormAjax2("#comment_post_btn","#comment_form",url);
	}
}
function commonFormAjax2(buttonId,formId,url,callback){
	if(typeof(callback) == "undefined")
	{
		callback = function(data, textStatus) {
			$(buttonId).removeAttr("disabled");
			if (data["callback"] != undefined){
				for (var key in data["callback"]){
					eval(data["callback"][key] + "(data, textStatus)");
				}
			}else{
				commonCallbackDialog(data, textStatus);
			}
		};
	}
	dataString = $(formId).serialize();
	
	if (isCrossDomain(url)) {
		crossDomainRequest("post", url, dataString, callback, "json");
	} else {
		$.ajax({
			type: "post",
			url: url,
			data: dataString,
			dataType: "json",
			success: callback
		});	
	}
	return false;
}
// 试玩微博……首页获取最新微博信息
function getNewWeibo(talkid){
	var url = "/weibo/gettalk/id/" + talkid;
	$.ajax({
		type: "get",
		url: url,
		dataType: "json",
		data :{format:"json"},
		success: function(data, textStatus){
			if (data['callback']['id'] != talkid)
			{
				$("#weibo_mod_list").find("li:first").before(data["html"]);
				$("#weibo_mod_list").find("li:first").hide();
				$("#weibo_mod_list").find("li:first").fadeIn(2000);
				
				$("#weibo_mod_list").find("li:last").remove();
				
			}
			
			window.setTimeout("getNewWeibo("+data['callback']['id']+")",5000);
		}
	});
}

var clearTipString = '';

// 试玩微博……ajax获取最新微博动态信息
function weiboNewAjax(){
	var url = document.domain == "bbs.shiwan.com" ? "http://bbs.shiwan.com/msg/weibo" : "http://www.shiwan.com/msg/weibo" ;
	callback_func = function(data, textStatus)
	{
		var isShow = false;
		var str = '';
		$("#fansNew").html(str);
		$("#replyNew").html(str);
		$("#atNew").html(str);
		$("#msgNew").html(str);
		$("#jifenNew").html(str);
		$("#bbsUvNew").html(str);
		if(data["fans"] > 0){
			str = data['fans'] +"位新粉丝，<a href='http://www.shiwan.com/weibo/idols/type/fans' class='umore'>查看我的粉丝</a>";
			$("#fansNew").html(str);
			isShow = true;
			clearTipString += "&fans=" + data['fans'];
		}
		if(data["reply"] > 0){
			str = data['reply'] +"条新评论，<a href='http://www.shiwan.com/weibo/replylist/type/to' class='umore'>查看评论</a>"
			$("#replyNew").html(str);
			isShow = true;
			clearTipString += "&reply=" + data['reply'];
		}
		if(data["at"] > 0){
			str = data['at'] +"条微博提到我，<a href='http://www.shiwan.com/weibo/forwardme' class='umore'>查看@我</a>"
			$("#atNew").html(str);
			isShow = true;
			clearTipString += "&at=" + data['at'];
		}
		if(data["msg"] > 0){
			str = data['msg'] +"条私信，<a href='http://www.shiwan.com/weibo/msg' class='umore'>查看私信</a>"
			$("#msgNew").html(str);
			isShow = true;
			clearTipString += "&msg=" + data['msg'];
		}
		if(data["jifen"] > 0){
			str = data['jifen'] +"条积分变化，<a href='http://www.shiwan.com/consolejifen/index#jifenhistory' class='umore'>查看积分记录</a>"
			$("#jifenNew").html(str);
			isShow = true;
			clearTipString += "&jifen=" + data['jifen'];
		}
		if(data["bbs_u_v"]){
			$.each(data["bbs_u_v"],function(n,value){
				$("#bbsUvNew").append("<li>" + value + "</li>");
				isShow = true;
			});
			$('#bbsUvNew li a').click(function(){
				return clearBbsUvNew(this);
		    });
			
			clearTipString += "&bbsuv=1";
		}
		if(isShow){
			$(".weibo_notice").show();			
		}
		else
		{
			$(".weibo_notice").hide();
		}
		var timer = setTimeout( "weiboNewAjax()", 10000 );
		timer = null;
	};
	
	if (isCrossDomain(url)) 
    {
        crossDomainRequest("get", url, {format:"json"}, callback_func, "json");
    } 
	else 
    {
		$.ajax({
			type: "get",
			url: url,
	        dataType: "json",
			data :{format:"json"},
			success: callback_func
		});	
    }
}

function clearTip()
{
    var url = document.domain == "bbs.shiwan.com" ? "http://bbs.shiwan.com/msg/cleartip" : "http://www.shiwan.com/msg/cleartip";
    var postData = "format=json" + clearTipString;
    $.ajax({
            type: "post",
            url: url,
            dataType: "json",
            data : postData
        });
}

//试玩微博……获取我的最新的weibo
function getMyNewWeibo(talkid){
	var url = "/msg/newtalk/id/" + talkid;
	$.ajax({
		type: "get",
		url: url,
		dataType: "json",
		data :{format:"json"},
		success: function(data, textStatus){
			if (data["sum"] > 0)
			{
				$(".weibo_msg").html("<a href=\"javascript:addNewWeibo("+talkid+")\" class=\"weibo_new\">有新微博，点击查看</a>");
			}
			else
			{
				$(".weibo_msg").html("");
				window.setTimeout("getMyNewWeibo("+talkid+")",10000);
			}
		}
	});	
	
}

//填充weibo内容...
function addNewWeibo(talkid)
{
	$(".weibo_msg").html("<img src='http://www.shiwanimg.cn/images/weibo/loading.gif' style='margin-top:4px;' />");
	var url = "/weibo/newtalk/id/" + talkid;
	$.ajax({
		type: "get",
		url: url,
		dataType: "json",
		data :{format:"json"},
		success: function(data, textStatus){
			$(".weibo_list").find("li:first").before(data['html']);
			$(".weibo_msg").html("");
			talkid = $(".lastId").attr("value");
			window.setTimeout("getMyNewWeibo("+talkid+")",10000);
		}
	});	
}
// 试玩微博……插入图片JS
function weiboUploadImg(url){
	if (typeof(url) == "undefined")
	{
		url = document.domain == "bbs.shiwan.com" ? 'http://bbs.shiwan.com/file/comment' : 'http://www.shiwan.com/file/comment';
	}
	var button = $('#upload_button'), interval;
	var imgNum = 1;
	var imgId = "imgId";
	new AjaxUpload(button,{
		action: url, 
        name: 'myfile',
		onSubmit : function(file, ext){
			$('#upload_state').html("<div style='text-align:left;'><img src='http://www.shiwanimg.cn/images/weibo/loading.gif' border=0 align='absmiddle' /> 正在上传，请等待……</div>");	
		},
	
		onComplete: function(file, response){
			//setTimeout(callLater(showLater,response),5000);
			//callLater(showLater,response);
			//$('<div></div>').appendTo('#files').html(response);
			
			$('#upload_state div').html('');
			$("#upload_button").hide();
			$('<div></div>').appendTo('#files').html(response);	
		}
	});
}
function callLater(func,response)
{
	return (function(){
	func(response);
	});
}

function showLater(response){
	$('#upload_state div').html('');
	//window.clearInterval(interval);
	$("#upload_button").hide();
	$('<div></div>').appendTo('#files').html(response);
}

// 游戏吧，推荐weibo JS
function recommend_comment(data){
	add_to_div_before(data);
	// 加1 ， 变红。
	var love_id = "#comment_love_" + data["args"]["comment_id"];
	$(love_id).removeClass("v_love");
	$(love_id).addClass("v_loved");
	$(love_id).removeAttr("tip");
	$(love_id).attr("tip","你已经推荐过此微博");
	var love_num = parseInt($(love_id).find("span").html()) + 1;
	$(love_id).find("span").html(love_num);
	$(love_id).find("span:last").html("0");
	$('#div_reply_'+data["args"]["comment_id"]).show();
}
function recommend_post(id)
{
	var love_id = "#comment_love_" + id;
	var isAllowRecommend = parseInt($(love_id).find("span:last").html());
	if (isAllowRecommend == 0)
	{
		return false;
	}
	var url = "http://www.shiwan.com/weibo/recommend";
	
	var dataString = "format=json&comment_id=" + id;
	callback = function(data, textStatus) {
		if (data["callback"] != undefined){
			for (var key in data["callback"]){
				eval(data["callback"][key] + "(data, textStatus)");
			}
		}else{
			commonCallbackDialog(data, textStatus);
		}
	};
	if (isCrossDomain(url)) {
		crossDomainRequest("get", url, dataString, callback, "json");
	} else {
		$.ajax({
			type: "get",
			url: url,
			data: dataString,
			dataType: "json",
			success: callback
		});	
	}
}

// 游戏吧 …………官方微博加关注
function youxibaFollow(uid,url,type,obj, isLogin){
	if (url == 0)
	{
		url = "http://www.shiwan.com/weibo/concernadd";
	}
	
	if (typeof(isLogin) == "undefined")
	{
		$(obj).parent().html("<img src='http://www.shiwanimg.cn/images/weibo/loading.gif' style='margin-top:4px;' />");
		callback = function(data, textStatus) 
		{
			if(type == 0 || type == 1){
				$(".gameba_concern").hide();
				$(".gameba_post").show();
				selectTopic();
			}else{
				$(".gameba_concern").show();
				$(".gameba_post").hide();
			}
		};
	}
	else
	{
		callback = function(data, textStatus) 
		{
			if (data["callback"] != undefined){
				for (var key in data["callback"]){
					eval(data["callback"][key] + "(data, textStatus)");
				}
			}else{
				commonCallbackDialog(data, textStatus);
			}
		};
	}
	
	$.ajax({
		type: "post",
		url: url,
		dataType: "json",
		data :{type:type,uid:uid,format:"json"},
		success: callback
	});	
}

// 游戏吧 …………展开更多话题
function openTopic(obj){
	$(obj).hide();
	var new_html = $("#topic_1").html();
	$("#close_topic").show();
	$("#topic_1").append($("#topic_2").html());
	$("#close_topic").click(function(){
		$(this).hide();
		$(obj).show();
		$("#topic_1").html(new_html);
	});
}

// 游戏吧……文本框文字选中效果
var textSelect = function(o, a, b){
	var a = parseInt(a, 10), b = parseInt(b, 10);
	var o = document.getElementById(o);
	var l = o.value.length;
	if(l){
		//如果非数值，则表示从起始位置选择到结束位置
		if(!a){
			a = 0;	
		}
		if(!b){
			b = l;	
		}
		//如果值超过长度，则就是当前对象值的长度
		if(a > l){
			a = l;	
		}
		if(b > l){
			b = l;	
		}
		//如果为负值，则与长度值相加
		if(a < 0){
			a = l + a;
		}
		if(b < 0){
			b = l + b;	
		}
		if(o.createTextRange){//IE浏览器
			var range = o.createTextRange();         
			range.moveStart("character",-l);              
			range.moveEnd("character",-l);
			range.moveStart("character", a);
			range.moveEnd("character",b-1);
			range.select();
		}else{
			o.setSelectionRange(a, b);
			o.focus();
		}
	}
};
function selectTopic(){
	var tlen = $("#post_editor").text().length-1;
	textSelect("post_editor",1,tlen);
}

// 试玩微博……显示视频
function showVideo(vUrl,vid){
	var video_html = "<embed width='440' height='356' wmode='transparent' type='application/x-shockwave-flash' src='"+ vUrl +"' quality='hight' allowfullscreen='true' flashvars='playMovie=true&amp;auto=1&amp;adss=0' pluginspage='http://get.adobe.com/cn/flashplayer/' style='visibility: visible;' allowscriptaccess='always'>";
	$("#weibo_small_video_"+vid).hide();
	$("#weibo_video_"+vid).show();
	$("#weibo_video_"+vid +" .video_div").html(video_html);
}
function closeVideo(vid){
	$("#weibo_small_video_"+vid).show();
	$("#weibo_video_"+vid).hide();
	$("#weibo_video_"+vid +" .video_div").html("");	
}

// 批量关注功能...
function cheakAllAtt(id){
	var obj = "#all_att_input_"+id;
	if($(obj).attr("checked")){
		$("#star_list_"+id+" li .headpic a").attr("class","curr");
	}else{
		$("#star_list_"+id+" li .headpic a").removeAttr("class");
	}
}
function batchAttention(id, fun){
	var i = 0;
	$('#star_list_'+id+' li .headpic').each(function(){
		if($(this).find("a").attr("class") != "curr"){
			$(this).find("input").remove();
		}
		else
		{
			i++;
		}
	});
	
	if (i == 0)
	{
		var thickAlt = "#TB_inline?height=100&width=300&inlineId=dialogDiv";
		tb_show("系统提示",thickAlt,true);
		$("#TB_ajaxContent").html("您未选择该分组下任何用户!" + close_btn);
		return;
	}
	
	if (typeof(fun) != "undefined")
	{
		commonFormAjax2("#follow_btn_"+id+"","#vuser_form_"+id+"","http://www.shiwan.com/weibo/concernadd", fun);
	}
	else
	{
		commonFormAjax2("#follow_btn_"+id+"","#vuser_form_"+id+"","http://www.shiwan.com/weibo/concernadd");
	}
}

// 游戏频道下拉菜单
$(function(){
	$(".channel a.a_1").mouseover(function(){
		var xleft = $(this).offset().left;
		var xtop = $(this).offset().top;
		$("#channel_nav").show();
		$("#channel_nav").css({left:xleft,top:xtop+30});
	});
	$(".channel a.a_1").mouseleave(function(){
		$("#channel_nav").hide();
	});
	$("#channel_nav li").mouseover(function(){
		$("#channel_nav").show();
		$(this).addClass("cur");
		$("div.i_list").hide();
		$(this).find("div.i_list").show();
	});
	$("#channel_nav li").mouseleave(function(){
		$(this).removeClass("cur");
		$(this).find("div.i_list").hide();;
	});
	$("#channel_nav").mouseleave(function(){
		$(this).hide();
	});
	$("#home_channel_nav li").mouseover(function(){
		$(this).addClass("cur");
		$("div.i_list").hide();
		$(this).find("div.i_list").show();
	});
	$("#home_channel_nav li").mouseleave(function(){
		$(this).removeClass("cur");
		$(this).find("div.i_list").hide();;
	});
});

// 微博表情……ajax
function weiboFace(url,inputId,faceId){
	callback_func = function(data, textStatus){	
		$("#"+faceId).show();
		$("#"+faceId).html(data['html']);
    };
    
    dataString = {inputId:inputId,format:"json"};
    
	if (isCrossDomain(url)) {
		crossDomainRequest("get", url, dataString, callback_func, "json");
	}
	else
	{
		$.ajax({
			type: "get",
			url: url,
			dataType: "json",
			data : dataString,
			success: callback_func
		});	
	}
}
// 微博表情……intsert
function insertFace(id,str){
	var pe=document.getElementById(id);
    var pel=pe.value.length;
    pe.focus();
    if(typeof document.selection !="undefined")
    {
        document.selection.createRange().text=str;
    }
    else
    {
    	pe.value=pe.value.substr(0,pe.selectionStart)+str+pe.value.substring(pe.selectionStart,pel);
    } 
    $('.face_box').hide();
}

// 专区想玩/玩过……ajax
function playStatus(obj,typeId,gameId){
	callback = function(data, textStatus) 
	{
		if (data['html'] == "1"){
			if ($("#TB_window"))
			{
				tb_remove();
			}
			/*
			$(obj).attr("disabled","disabled");
			$(".game_basic .play input").removeClass("clicked");
			$(obj).addClass("clicked");
			*/
			$('#main_b').hide();
			
			if( typeId == 0){
				$('#main_b_like').hide();
				$('#main_b_over').show();
			} else {
				$('#main_b_over').hide();
				$('#main_b_like').show();
			}
		}
		else
		{
			commonCallbackDialog(data, textStatus);
		}
	};
	
	$.ajax({
		type: "get",
		url: "http://www.shiwan.com/subject/userplaygame",
		dataType: "json",
		data :{typeId:typeId,gameId:gameId,format:"json"},
		success: callback
	});	
}

function insertBarImgSubmit(type)
{
    html = "";
	var success = false;
    if(type == "1")
    {
        var imgInput = $("#imgInput").val();
        var imgInput = imgInput.replace(/(^\s*)|(\s*$)/g, ""); //去空格
        var imgType = imgInput.substring(imgInput.length-4,imgInput.length); //图片类型
        if(imgInput == "http://" || imgInput=="")
        {
            $("#imgError").html("图片链接不能为空!");
        }else if(imgType != ".gif" && imgType !=".jpg" && imgType !=".bmp" && imgType != ".png")
        {
            $("#imgError").html("输入链接有误，请重试!");
        }else
        {
            html = '<img src="' + imgInput + '" style="max-width:500px;">';
            tinymce.execCommand('mceInsertContent', 0, html);
			success = true;
        } 
    }
    else if(type == 2)
    {
        $.each($("#files .uploadpic"),function(i,obj){
            imgsUrl = $(obj).attr("ret");
            html += "<img src=" + imgsUrl + " />";
        });
        tinymce.execCommand('mceInsertContent', 0, html);
		success = true;
    }
	if (success) {
		tb_remove();
	}
}

// 开放平台账号登录弹窗函数
function op_window(opname){
	var url = "";
	if( opname=="qq" ){
		url = "/user/oalogin/redirect/qq/";
	}else if( opname=="sina" ){
		url = "/user/oalogin/redirect/sina/";
	}
	var iWidth = 585; //弹出窗口的宽度;
	var iHeight = 462; //弹出窗口的高度;
	var iTop = (window.screen.availHeight-30-iHeight)/2; //获得窗口的垂直位置;
	var iLeft = (window.screen.availWidth-10-iWidth)/2; //获得窗口的水平位置;
	childwin = window.open(url,'loginwindow','height='+iHeight+',width='+iWidth+',top='+iTop+',left='+iLeft+',toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=yes,status=no'); 
}
function evalGlobal(strScript){
        with(window) eval(strScript);
}
var op_callbackdo = new Array();
var op_callbackdo_runitem = "";
function op_callbackdo_set_item(item,item_content){
	op_callbackdo[item] = item_content;
}
function op_callbackdo_set_run(item){
	op_callbackdo_runitem = item;
}
function op_callbackdo_run(){
	evalGlobal(op_callbackdo[op_callbackdo_runitem]);
}








