﻿function ShowNav(type)
{
    $("#ul_Nav a").each(function(i,n)
    {
        if(type == $(n).html())
        {
            $(n).attr("class","current") ;
        }
        else
        {
            $(n).attr("class","") ;
        }
    }
    );
}
function ChkAll(id)
{
    $("#"+id+" input[type='checkbox']").each(function(i,n)
    {
        if($(n).attr("checked"))
        {
            $(n).attr("checked", false); 
        }
        else
        {
            $(n).attr("checked", true); 
        }
    });
}
function Getghlist(id,type,typeid,orderby)
{
    $.ajax(
    {
        type: "POST",
        url: "/ajax/gh.php",
        data: 'type='+type+'&orderby='+orderby+'&typeid='+typeid,
        success: function(result)
        {
            var html = "<table width=\"250px\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"tb_newgameB\" >"+result+"</table>";
            $("#"+id).html(html);
        },
        error:function()
        {
            alert('数据加载错误！');
        }
    });
}
function Showghlist(obj,id,type,typeid,orderby)
{
    $("#ph_menu").children("a").attr("class","AA")
    $(obj).attr("class","AAon") ;
    Getghlist(id,type,typeid,orderby) ;
}
function gp_upd(id)
{
	var saveid = GetCookie('diggid');
	if(saveid != null)
	{
		var saveids = saveid.split(',');
		var hasid = false;
		saveid = '';
		j = 1;
		for(i=saveids.length-1;i>=0;i--)
		{
			if(saveids[i]==id && hasid) continue;
			else {
				if(saveids[i]==id && !hasid) hasid = true;
				saveid += (saveid=='' ? saveids[i] : ','+saveids[i]);
				j++;
				if(j==20 && hasid) break;
				if(j==19 && !hasid) break;
			}
		}
		if(hasid) 
		{ 
		    alert("您已经投过票了，请不要重复投票 ！"); 
		    return; 
		}
		else 
		    saveid += ','+id;
		SetCookie('diggid',saveid,1);
	}
	else
	{
		SetCookie('diggid',id,1);
	}
    $.ajax(
    {
        type: "POST",
        url: "/ajax/gp_upd.php",
        data: 'id='+id,
        success: function(result)
        {
            gp_get(id) ;
        },
        error:function()
        {
            //alert('数据加载错误！');
        }
    });
}
function gp_get(id)
{
    $.ajax(
    {
        type: "POST",
        url: "/ajax/gp_get.php",
        data: 'id='+id,
        success: function(result)
        {
            $("#a_gp").html(result) ;
        },
        error:function()
        {
            alert('数据加载错误！');
        }
    });
}
function ShowGH(obj,id)
{
    $("#div_ghlist").children("a").attr("class","AA")
    $(obj).attr("class","Ahov") ;
    $("#div_ghul").children("ul").hide() ;
    $("#ul_gh_"+id).show() ;
}
function addFav() {     var url = location.href ; ;    title = document.title ;    var ua = navigator.userAgent.toLowerCase();     if (ua.indexOf("msie 8") > -1)     {         try         {             external.AddToFavoritesBar(url, title)         }         catch (e)         {             alert("您的浏览器不支持此功能，请使用快捷键 Ctrl+D 手动加入收藏夹")         }     }     else     {         try         {             window.external.AddFavorite(url, title)         }         catch (e)         {             try             {                 window.sidebar.addPanel(title, url, "")             }             catch (e)             {                 alert("您的浏览器不支持此功能，请使用快捷键 Ctrl+D 手动加入收藏夹")             }         }     } } 

function SetHome(obj)
{
    var vrl="http://www.99mc.com" ;
    try
    {
        obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
    }
    catch(e)
    {
        if(window.netscape) 
        {
            try
            {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
            } 
            catch (e) 
            {
                alert("此操作被浏览器拒绝！请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
            }
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage',vrl);
        }
        else
        {
            alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
        }
    }
}
