﻿function showPhoneType(id)
{
    hidePhoneType();
    document.getElementById("pt" + id).style.display = "block";
    for(var i =1; i <= 6; i++)
    {
        document.getElementById("pb" + i).className = "";
    }
    document.getElementById("pb" + id).className = "overpb";
}

function hidePhoneType()
{
    for(var i =1; i <= 6; i++)
    {
        document.getElementById("pt" + i).style.display = "none";
    }
}
function showCategoryGame(gc)
{
    hideCategoryGame();
    var obj = document.getElementById("cglist");
    var xmlObj = createXmlObj();
    xmlObj.open("GET", "Ajax/Ajax_IndexCategoryGame.aspx?gc=" + gc, true);
    xmlObj.onreadystatechange = function()
    {
        if(xmlObj.readyState == 4)
        {
            var str = xmlObj.responseText;
            obj.innerHTML = str;
        }
    }
    xmlObj.send(null);
}
function hideCategoryGame()
{
    for(var i =1; i <= 13; i++)
    {
        document.getElementById("gc" + i).className = "noclickli";
    }
}
function showGameList(id)
{
    hideGameList();
    document.getElementById(id).style.display = "block";
}

function hideGameList()
{
    for(var i =1; i <= 2; i++)
    {
        document.getElementById("gl" + i).style.display = "none";
    }
}
function showPhoneTypeGame(id)
{
    var obj = document.getElementById("pt" + id);
    var objico = document.getElementById("pbico" + id);

    if (obj.style.display == "none")
    {
        obj.style.display = "block";
        objico.innerHTML = "-";
    }
    else
    {
        obj.style.display = "none";
        objico.innerHTML = "+";
    }
}
function startSearch()
{
    var search_key = document.getElementById("s").value;

    if (search_key == '请输入关键字' || search_key == '')
    {
        alert('请输入关键字。');
        return false;
    }
    else
    {
        var search_key = encodeURIComponent(search_key.replace(/[\/_]/g,' '));
        location.href='/Game/?s='+search_key;
	}
}
var timeout;
function showScreen(startIndex,count)
{
    if (count > 1)
    {
        for (var i = 1; i <= count; i++)
        {
            if (document.getElementById("gs" + i) != null)
            {
                document.getElementById("gs" + i).style.display = "none";
            }
        }
        if (document.getElementById("gs" + startIndex) != null)
        {
            document.getElementById("gs" + startIndex).style.display = "block";
        }
        document.getElementById("screenpage").innerHTML = startIndex + "/" + count;
        startIndex++;
        if (startIndex > count || document.getElementById("gs" + startIndex) == null){startIndex = 1;}
        timeout = window.setTimeout("showScreen("+ startIndex + "," + count +")", 3000);
    }
}
function createXmlObj()
{
    var xmlObj = false;
    try
    {
        xmlObj = new XMLHttpRequest;
    }
    catch(e)
    {
        try
        {
            xmlObj = new ActiveXObject("MSXML2.XMLHTTP");
        }
        catch(e2)
        {
            try
            {
                xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e3)
            {
                xmlObj = false;
            }
        }
    }
    if (!xmlObj)
    {
        alert("XMLHttpRequest init Failed!");
    }
    
    return xmlObj;
}
function copyToClipboard()
{
    var txt= document.title + "\r\n" + this.location.href;

    if(window.clipboardData)
    {
        window.clipboardData.clearData();
        window.clipboardData.setData("Text", txt);
        alert("已复制成功，请按ctrl+V分享给你的好友吧！")
    }
}
function showAllPhoneType()
{
    document.getElementById("list_ptlist").style.height = "auto";
}
function addFav()
{
   if (document.all)
   {
      window.external.addFavorite("http://www.52xyx.com",document.title);
   }
   else if (window.sidebar)
   {
      window.sidebar.addPanel(document.title, "http://www.52xyx.com", "");
   }
} 
function setHomepage()   
{   
 if (document.all)   
    {   
        document.body.style.behavior='url(#default#homepage)';   
        document.body.setHomePage("http://www.52xyx.com");   
    }   
    else if (window.sidebar)   
    {   
    if(window.netscape)   
    {   
         try  
         {     
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");     
         }     
         catch (e)     
         {     
            alert( "该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true" );     
         }   
    }    
    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);   
    prefs.setCharPref('browser.startup.homepage',"http://www.52xyx.com");   
 }   
}
var IsChange = false;
function moveChinaGame()
{
    var obj = document.getElementById("chinagamelist");
    if (IsChange)
    {
        obj.style.margin = "0px";
        IsChange = false;
    }
    else
    {
        obj.style.marginLeft = "-805px";
        IsChange = true;
    }
}