var ShowPopup = true;

function OpenDown()
{
        var location = "/PokerInstaller? " +sCut + "&dl=730";
        document.location.href = "../en/download_short.htm?dl=730";
        setDownloadStatus();
        window.open(location,"popDown","width=1,height=1,top=0,left=0");
}

function OpenCasino(loc)
{
        setDownloadStatus() ;
        var w = 820;
        var h = 565;
        var l = (window.screen.width-w)/2;
        var t = (window.screen.height-h)/2; 
        var filename = "http://flash.888.com/start.asp?mode=1&" + sCut + "&dl="+loc+"&";
        window.open(filename   ,null, "height=" + h + ",width=" + w + ",status=no,toolbar=no,menubar=no,location=no,resize=no,left="+l+",top="+t);
}

function ContactUs()
{
        var w = 793;
        var h = 517;
        var LocationString = "../en/contactusform/contactus.htm?" + sCut;
        var l = 1; //(window.screen.width-w)/2;
        var t = 1; //(window.screen.height-h)/2;
        window.open(LocationString,"contactUsWnd","status=no,toolbar=no,menubar=no,location=no,left=" + l + ",top=" + t + ",width=" + w + ",height=" + h)
}
function OpenPoker()
{
        var w = 820;
        var h = 565;
        var l = (window.screen.width-w)/2;
        var t = (window.screen.height-h)/2; 
        
        setDownloadStatus();
        var filename = "http://ndl.888.com/poker/?Real=1&" + sCut + "&dl=730";
        window.open(filename ,null, "height=" + h + ",width=" + w + ",status=no,toolbar=no,menubar=no,location=no,resize=no,left="+l+",top="+t);
}

function OpenInfo()
{
        var w = 405;
        var h = 252;
        var LocationString;
        var l = (window.screen.width-w)/2 - 12;
        var t = (window.screen.height-h-155);
        var windowprops = "location=no,status=no,scrollbars=no,menubars=no,toolbars=no,resizable=no,left=" + l + ",top=" + t + ",width=" + w + ",height=" + h;
        var pokerinfo = window.open("../pokerinfo.htm","PokerInfo",windowprops);
}

function setDownloadStatus()
{
    setCookie("downloaded","1","/");
}

function setCookie(name,value)
{
    var argv = setCookie.arguments;
    var argc = setCookie.arguments.length;
    var path = (argc > 2) ? argv[2] : null;
    var expires = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;

    document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain))
}
function parseTableInfo(tree)
{      
    var TYPE_HOLDEM = "100";
    var TYPE_OMAHA = "102";
    var TYPE_OMAHAHL = "104";
    var TYPE_7STUD = "106";
    var TYPE_7STUDHL = "108";
    var game = null;
    var objectElement = null;
    var totalData = null;
    var totalPlayers = "";
    var totalTables  = "";
    var isValidData = true;
    
    objectElement = tree.getElementsByTagName("PI")[0];
    if(objectElement!=null)
    {
        game = objectElement.getElementsByTagName("g");
        totalData = objectElement.getElementsByTagName("a")[0];
    }
    var nTexas = "";
    var nOmaha = "";
    var nOmahaHL = "";
    var n7Cards = "";
    var n7CardsHL = "";
    if(game!=null)
    {
        for(i=0;i<game.length;i++)
        {

            if(game[i].getAttribute("n")==TYPE_HOLDEM)
                nTexas = game[i].getAttribute("p");
            if(game[i].getAttribute("n")==TYPE_OMAHA)
                nOmaha = game[i].getAttribute("p");
            if(game[i].getAttribute("n")==TYPE_OMAHAHL)
                nOmahaHL = game[i].getAttribute("p");
            if(game[i].getAttribute("n") == TYPE_7STUD)
                n7Cards = game[i].getAttribute("p");
            if(game[i].getAttribute("n") == TYPE_7STUDHL)
                n7CardsHL = game[i].getAttribute("p");
        }
        
        totalPlayers = totalData.getAttribute("p");
        totalTables = totalData.getAttribute("t");

    }
    else
    {
        isValidData=false;
    }
    
    if(isValidData)
    {
        
        if(nTexas==null) nTexas="0";
            document.getElementById("texas").innerHTML = "<a href='javascript:OpenPoker()' class='payerNumber'><b>" + nTexas + "</b> <br> <u>players</u> </a>";
        if(nOmaha==null)nOmaha="0";
            document.getElementById("omaha").innerHTML = "<a href='javascript:OpenPoker()' class='payerNumber'><b>" + nOmaha + "</b> <br><u>players</u> </a>";
        if(nOmahaHL==null)nOmahaHL="0";
            document.getElementById("omahaHL").innerHTML = "<a href='javascript:OpenPoker()' class='payerNumber'><b>" + nOmahaHL + "</b> <br><u>players</u> </a>";
        if(n7Cards==null)n7Cards="0";
            document.getElementById("cards").innerHTML = "<a href='javascript:OpenPoker()' class='payerNumber'><b>" + n7Cards + "</b> <br><u>players</u> </a>";
        if(n7CardsHL==null)n7CardsHL="0";
            document.getElementById("cardsHL").innerHTML = "<a href='javascript:OpenPoker()' class='payerNumber'><b>" + n7CardsHL + "</b> <br><u>players</u> </a>";
       
        document.getElementById("total").innerHTML =  "Currently <font color='#fdfffc;'>" + totalPlayers + "</font> players on <font color='#fdfffc;'>" + totalTables +"</font> tables";   
    }
    
    
}

function getJacks(tree)
{
   
    var game = null;
    var objectElement = null;

    objectElement = tree.getElementsByTagName("jackpots")[0];
    
    if(objectElement!=null)
        var game = objectElement.getElementsByTagName("jackpot");

    var jackpotString = " ";
    var i=0;

    for(i=0;i<game.length;i++)
    {
        //remove the '!' from the end of the name
      if(game[i].getAttribute("name")!=null)
      {
        var name="";
        jacky_name = game[i].getAttribute("name");
        ind = jacky_name.indexOf('!');
        if(ind==jacky_name.length-1)
            jacky_name = jacky_name.substr(0,jacky_name.length-1)
        
        jacky_name += " jackpot"

        jackpotString += jacky_name + ": ";
        
      }     
      if(game[i].getAttribute("sum")!=null)
         jackpotString += game[i].getAttribute("sum") + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        
    }
    //if we have less than 4 jackpots we want to duplicate them
    if(i>0 && i<4)
    {
        jackpotString += " " + jackpotString;
    }
    document.getElementById("jackpotText").innerHTML = "<a style='text-decoration:none;font-family:verdana;font-size:11px;font-weight:bold;color:fdfffc;'>" + jackpotString + "</a>";
}
