//本地化
var www_dns='';
if(sys_version==2){
	var posi_top=233;
}else{
	var posi_top=195;
}
function select_game_class(){
	if(show_game_class==null){alert('数据加载中，请稍稍候...');return false;}else{};
		  show_divbox("请选择游戏(点击游戏名称选择游戏)",show_game_class,980,200,1,"",posi_top);
}

var is_load_type=false;
var is_load_area=false;
function select_class(title,id){
	is_load_type=false;
	include_js('s1.asp?id=' + id + "&r=" + Math.random());
	is_load_area=false;
	include_js('s2.asp?id=' + id + "&r=" + Math.random());
	var obj_id=$('game_class');
	obj_id.value=id;
	var obj_title=$('game_class_title');
	obj_title.value=title;
	var obj_id=$('game_type');
	a=obj_id.value='';
	var obj_title=$('game_type_title');
	obj_title.value='全部物品';
	var obj_id=$('game_area');
	obj_id.value='';
	var obj_title=$('game_area_title');
	obj_title.value='游戏区';
	var obj_id=$('game_server');
	obj_id.value='';
	var obj_title=$('game_server_title');
	obj_title.value='游戏服务区';
	cls('sub_win_'+(index-4));
}

function select_type_1(title,id){
	if(id==0)
	{
			is_load_area=false;
			var obj_title=$('game_type_title');
			obj_title.value="全部物品";
			cls('sub_win_'+(index-4));	
		}
	else
	{
			is_load_area=false;
			var obj_id=$('game_type');
			obj_id.value=id;
			var obj_title=$('game_type_title');
			obj_title.value=title;
			cls('sub_win_'+(index-4));
		}
}
function select_area_1(title,id){
	if(id==0)
	{
			is_load_area=false;
			include_js('s3.asp?id=' + id + "&r=" + Math.random());
			var obj_title=$('game_area_title');
			obj_title.value="游戏区";
			cls('sub_win_'+(index-4));	
	}
	else
	{
			is_load_type=false;
			include_js('s3.asp?id=' + id + "&r=" + Math.random());
			var obj_id=$('game_area');
			obj_id.value=id;
			var obj_title=$('game_area_title');
			obj_title.value=title;
			cls('sub_win_'+(index-4));
	}
}

function select_server_1(title,id)
{
	if(id==0)
	{
			is_load_area=false;
			var obj_id=$('game_server');
			is_load_area=false;
			var obj_title=$('game_server_title');
			obj_title.value="游戏服务器";
			cls('sub_win_'+(index-4));
	}
	else
	{
			is_load_area=false;
			var obj_id=$('game_server');
			obj_id.value=id;
			var obj_title=$('game_server_title');
			obj_title.value=title;
			cls('sub_win_'+(index-4));
			
	}

}



var type_arr;
function select_game_type(){
	if(is_load_type==false){
		var type_str='';
	}else{
		
		var type_str="<div class='homeGameListBox'>"
		+"<ul>";
		type_str+="<li>| <a href='javascript:void(null);' onclick='select_type(\"全部物品\",\"\")' ><b>全部不限</b></a></li>";

		for( var rows in type_arr ) {
			//alert(rows);
			type_str+="<li>| <a href='javascript:void(null);' onclick='select_type(\""+type_arr[rows].substr(0,7)+"\","+rows+")' >"+type_arr[rows]+"</a></li>";
		}
		type_str+="</ul>"
		+"</div>";
		
	}

	show_divbox('请选择物品',type_str,980,200,1,'',posi_top);
}

function select_type(title,id){
	cls('sub_win_'+(index-4));
	var obj_id=$('game_type');
	obj_id.value=title;
	var obj_title=$('game_type_title');
	obj_title.value=title;
}

var area_arr;
function select_game_area(){
	if(is_load_area==false){
		var area_str='';
	}else{
		
		var area_str="<div class='homeGameListBox'>"
		+"<ul>";
		area_str+="<li>| <a href='javascript:void(null);' onclick='select_area(\"游戏区\",\"\")' ><b>全部不限</b></a></li>";

		for( var rows in area_arr ) {
			//alert(rows);
			area_str+="<li>| <a href='javascript:void(null);' onclick='select_area(\""+area_arr[rows].substr(0,7)+"\","+rows+")' >"+area_arr[rows]+"</a></li>";
		}
		area_str+="</ul>"
		+"</div>";
	}
	show_divbox('请选择游戏区',area_str,980,200,1,'',posi_top);
}

var is_load_server=false;
function select_area(title,id){
	cls('sub_win_'+(index-4));
	var obj_id=$('game_area');
	obj_id.value=id;
	var obj_title=$('game_area_title');
	obj_title.value=title;
	
	is_load_server=false;
	include_js('s3.asp?id=' + id + "&r=" + Math.random());
	var obj_id=$('game_server');
	obj_id.value='';
	var obj_title=$('game_server_title');
	obj_title.value='游戏服务器';
}

var server_arr;
function select_game_server(){
	if(is_load_server==false){
		var server_str='';
	}else{
		
		var server_str="<div class='homeGameListBox'>"
		+"<ul>";
		server_str+="<li>| <a href='javascript:void(null);' onclick='select_server(\"游戏区\",\"\")' ><b>全部不限</b></a></li>";

		for( var rows in server_arr ) {
			//alert(rows);
			server_str+="<li>| <a href='javascript:void(null);' onclick='select_server(\""+server_arr[rows].substr(0,7)+"\","+rows+")' >"+server_arr[rows]+"</a></li>";
		}
		server_str+="</ul>"
		+"</div>";
		
	}
	show_divbox('请选择游戏服务器',server_str,980,200,1,'',posi_top);
}

function select_server(title,id){
	cls('sub_win_'+(index-4));
	var obj_id=$('game_server');
	obj_id.value=id;
	var obj_title=$('game_server_title');
	obj_title.value=title;
}





function include_js(path) 
{
  var url = www_dns+"/"+path;
  
  var req;
	  
  if(window.XMLHttpRequest) {
    try { req = new XMLHttpRequest();
    } catch(e) { req = false; }
  } else if(window.ActiveXObject) {
    try { req = new ActiveXObject('Msxml2.XMLHTTP');
    } catch(e) {
    try { req = new ActiveXObject('Microsoft.XMLHTTP');
    } catch(e) { req = false; }
  } }
  
  //alert(url);
  
  if(req) {
	  //alert('a');
    req.onreadystatechange = function(){
	  if (req.readyState == 4 && req.status == 200 ) {
	
		var data = req.responseText;
		eval(data);
	  }
		  

	};
	
		req.open('GET', url, true);
		req.send('');
	

  }else{//跨域
	  //include_js2(url);
  }
}


function include_bbs_js(path) //跨域
{
	//alert(path);
	var url = www_dns+"/"+path;
	
	//alert(url);
	
	var head = document.getElementsByTagName("head")[0];        
	var js = document.createElement("script");        
	js.src = url;        
	js.onload = js.onreadystatechange = function()        
	{        
		if (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")        
		{    
			 head.removeChild(js);    
			 //JS加载完毕了. 类似于ajax请求完成.    
			 //执行是否登陆成功的判断    
		}        
	}        
	head.appendChild(js);
}





//初始化所有导航标签的样式
function initializeTags(id)
{
	//var frmObj = getOje(id).childNodes[0];
	//var len = frmObj.childNodes.length;
	
	var frmObj = getOje(id).getElementsByTagName("li");
	var len = frmObj.length;
	
	for(i=0; i<len; i++)
	{
		if(i==0)
		{
			frmObj[i].className="list2_Off";
		}
		else if(i==len-1)
		{
			frmObj[i].className="list2_Off";
		}
		else if(i==len-2)
		{
			frmObj[i].className="list_Off rightLine";
		}
		else
		{
			frmObj[i].className="list_Off";
		}
	}
}

//初始化所有详情层
function inializeDetailsLayers(id)
{
	//var detailsContainer = getOje(id).childNodes;
	var detailsContainer = getOje(id).getElementsByTagName("div");
	var len = detailsContainer.length;
	//var len = detailsContainer.length;
	
	for(i=0; i<len; i++)
	{
	    if(detailsContainer[i].className != 'clear')
		{
		    detailsContainer[i].style.display="none";
		}   
	}
}

////////搜索栏

//应用相对应的标签样式
function search_showTagDetail(_event)
{
	//1.初始化所有外围标签的样式
	//2.应用当有的标签的样式
	//3.初始化所有详情层
	//4.显示相对应的详细层的内容的显示
	var tagSuffix;
	
	initializeTags("search_tagFrame");
	
	
	//兼容firefox
	_event = window.event || _event;
	var tagObj = _event.srcElement || _event.target;
	//var tagObj = _event.srcElement;
	var tagValue =trim(tagObj.innerText);
	switch(tagValue)
	{
		case "热门游戏":
			tagObj.className="list2_On";
			tagSuffix = "hg";
			getOje("search_companyTagContainer").style.display="block";
			clearTagColor();
			break;
		case "Z":
			tagObj.className="list_On";
			tagSuffix = "Z";
			getOje("search_companyTagContainer").style.display="none";
			break;
		case "免费游戏":
			tagObj.className="list2_On";
			tagSuffix = "wg";
			getOje("search_companyTagContainer").style.display="none";
			break;
		default:
			tagObj.className="list_On";
			tagSuffix = tagValue;
			//getOje("search_companyTagContainer").style.display="none";
			break;
	}
	inializeDetailsLayers("search_gContainer");
	//inializeDetailsLayers("search_companyGContainer");
	if(getOje("search_Div" + trim(tagSuffix)) != null)
	{
	    getOje("search_Div" + trim(tagSuffix)).style.display="block";
	}
}

function search_clearTagColor()
{
    try{
        var m_li = getOje("search_companyTagContainer").getElementsByTagName("li");
	    var liCount = m_li.length;
    	
	    for(i=0; i<liCount; i++)
	    {
		    m_li[i].style.color = '#0066cc';
		    m_li[i].setAttribute('style','color:#0066cc;cursor:pointer;');
	    }
	}
	catch(e)
	{}
}

function search_showCompanyDetail(suffix,_event)
{
	//1.初始化所有公司游戏详情和字母游戏详情
	//2.指定应用
	//3.改变公司标签的样式
	inializeDetailsLayers("search_gContainer");
	inializeDetailsLayers("search_companyGContainer");
	
	getOje("search_Div" + suffix).style.display = "block";
	
	try
	{
		var m_li = getOje("search_companyTagContainer").getElementsByTagName("li");
		var liCount = m_li.length;
		
		for(i=0; i<liCount; i++)
		{
			m_li[i].style.color = '#0066cc';
			m_li[i].setAttribute('style','color:#0066cc;cursor:pointer;');
		}
		
		//firefox
		_event = window.event || _event;
		var eve = _event.srcElement || _event.target;
		
		eve.style.color='#ff6600';
		eve.setAttribute('style','color:#ff6600;cursor:pointer;');
		
		//_event.srcElement.style.color='#ff6600';
	}
	catch(e)
	{}
}



////////搜索栏------------------------------------end



//应用相对应的标签样式
function showTagDetail(_event)
{
	//1.初始化所有外围标签的样式
	//2.应用当有的标签的样式
	//3.初始化所有详情层
	//4.显示相对应的详细层的内容的显示
	var tagSuffix;
	
	initializeTags("tagFrame");
	
	
	//兼容firefox
	_event = window.event || _event;
	var tagObj = _event.srcElement || _event.target;
	//var tagObj = _event.srcElement;
	var tagValue =trim(tagObj.innerText);
	switch(tagValue)
	{
		case "热门游戏":
			tagObj.className="list2_On";
			tagSuffix = "hg";
			getOje("companyTagContainer").style.display="block";
			clearTagColor();
			break;
		case "Z":
			tagObj.className="list_On";
			tagSuffix = "Z";
			getOje("companyTagContainer").style.display="none";
			break;
		case "免费游戏":
			tagObj.className="list2_On";
			tagSuffix = "wg";
			getOje("companyTagContainer").style.display="none";
			break;
		default:
			tagObj.className="list_On";
			tagSuffix = tagValue;
			getOje("companyTagContainer").style.display="none";
			break;
	}
	inializeDetailsLayers("gContainer");
	inializeDetailsLayers("companyGContainer");
	if(getOje("Div" + trim(tagSuffix)) != null)
	{
	    getOje("Div" + trim(tagSuffix)).style.display="block";
	}
}

function clearTagColor()
{
    try{
        var m_li = getOje("companyTagContainer").getElementsByTagName("li");
	    var liCount = m_li.length;
    	
	    for(i=0; i<liCount; i++)
	    {
		    m_li[i].style.color = '#0066cc';
		    m_li[i].setAttribute('style','color:#0066cc;cursor:pointer;');
	    }
	}
	catch(e)
	{}
}

function showCompanyDetail(suffix,_event)
{
	//1.初始化所有公司游戏详情和字母游戏详情
	//2.指定应用
	//3.改变公司标签的样式
	inializeDetailsLayers("gContainer");
	inializeDetailsLayers("companyGContainer");
	
	getOje("Div" + suffix).style.display = "block";
	
	try
	{
		var m_li = getOje("companyTagContainer").getElementsByTagName("li");
		var liCount = m_li.length;
		
		for(i=0; i<liCount; i++)
		{
			m_li[i].style.color = '#0066cc';
			m_li[i].setAttribute('style','color:#0066cc;cursor:pointer;');
		}
		
		//firefox
		_event = window.event || _event;
		var eve = _event.srcElement || _event.target;
		
		eve.style.color='#ff6600';
		eve.setAttribute('style','color:#ff6600;cursor:pointer;');
		
		//_event.srcElement.style.color='#ff6600';
	}
	catch(e)
	{}
}

function trim(str)
{  
	//删除左右两端的空格
 	return str.replace(/(^\s*)|(\s*$)/g, "");
}

function getOje(id)
{
	return document.getElementById(id);	
}
