﻿// JScript 文件
var Invoke=null;
var cHWND=0;

function startAuto(entertype,gameid,roomid,username,userpwd)
{
    //alert(Invoke);
	try
	{ 
	
	
			if(Invoke==null)
			{
				Invoke = new ActiveXObject("InVokerTGGame.InvokerTG.1");
			}
			Invoke.SetParameters(entertype);
			Invoke.SetUserName(username);
			Invoke.SetUserPwd(userpwd);
			Invoke.SetAutoEnterRoom(gameid,roomid);
			Invoke.SetRecvHwnd(cHWND);
			Invoke.Start();

	}
	catch(e)
	{
			// 如果未安装 转入安装页 
			alert("您尚未安装,请先下载游戏客户端...");  
  			location.href="http://www.91555.com/download.aspx";
  			return;
	}				
}


function PostMac()
{
    //alert(Invoke);
	try
	{ 
	
	
			if(Invoke==null)
			{
				Invoke = new ActiveXObject("InVokerTGGame.InvokerTG.1");
			}
			var uid="";
			var mac="";
			mac=Invoke.JS_GetUserMac();
			uid=Invoke.JS_GetUserTGID();
			postServer(mac,uid);

	}
	catch(e)
	{
			// 如果未安装 转入安装页 
			//alert("您还未安装,现转入安装页面!");  
  			//window.parent.location.href("cu2007.htm");
  			return;
	}				
}


function regPostMac()
{
    //alert(Invoke);
	try
	{ 
	
	
			if(Invoke==null)
			{
				Invoke = new ActiveXObject("InVokerTGGame.InvokerTG.1");
			}
			var uid="";
			var mac="";
			mac=Invoke.JS_GetUserMac();
			uid=Invoke.JS_GetUserTGID();
			regPostServer(mac,uid);

	}
	catch(e)
	{
			// 如果未安装 转入安装页 
			//alert("您还未安装,现转入安装页面!");  
  			//window.parent.location.href("cu2007.htm");
  			return;
	}				
}

function startGame(gameid,roomid,chatZoneid,zoneHost,zoneport)
{
    if(gameid==0 && roomid==0)
    {
        alert("当前房间已满，只有VIP用户才能进人满房间！");
        return;
    }
    else if(chatZoneid>0)
    {
    EnterChatRoom(chatZoneid,roomid,zoneHost,zoneport);
    }
    else
    {
    startAuto(3,gameid,roomid,'','');
    }
}


function postServer(mac,uid)
{
        var _url="/PostMac.aspx?mac="+mac+"&uid="+uid+"&t="+Math.random();
        new Ajax().get(_url,
            function(res){
                //alert("adfasd");
            });
}



function regPostServer(mac,uid)
{
        var _url="/regPostMac.aspx?mac="+mac+"&uid="+uid;
        new Ajax().get(_url,
            function(res){
                //alert("adfasd");
            });
}

function EnterChatRoom(zoneID,roomid,zoneHost,zoneport)
    {
         try
    { 
        if(Invoke==null)
        {
	        Invoke = new ActiveXObject("InVokerTGGame.InvokerTG.1");
        }
        Invoke.SetParameters(2);
	Invoke.SetUserName("");
	Invoke.SetUserPwd("");
	Invoke.SetAutoEnterChatZone(zoneID,roomid,zoneHost,zoneport);
	Invoke.SetRecvHwnd(cHWND);
	Invoke.Start();
    }
    catch(e)
    {	        		     
    }				
    }
