function OpenPoker(loc) {
    var w = 820;
    var h = 565;
    var l = (window.screen.width-w)/2;
    var t = (window.screen.height-h)/2; 
    
    //if NOT from landing page (out of the frame)
    if (window.name != "") {                 
        setDownloadStatus();
    }
    
    var filename = "http://ndl.888.com/poker/flashpoker_real/application/RLFlashPoker.html?" + sCut + "&dl=" + loc;
    if (sLang == 'ar' || sLang == 'mx'  || sLang == 'la')
        filename = "http://ndl.888.com/poker/flashpoker_real/application/RLFlashPoker.html?lang=es&" + sCutLang + "&dl=" + loc;
    else if (sLang == 'br')    
        filename = "http://ndl.888.com/poker/flashpoker_real/application/RLFlashPoker.html?lang=es&" + sCutLang + "&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 setDownloadStatus() {   
    parent.isDownload = true;
}

function OpenDownPoker(loc) {     
    try {
        ntptAddPair("dl",loc);
        ntptEventTag("ev=download_poker_from_"+sLang);
    }catch(err){}
    
    if (sLang == 'en') {    
        var url="http://www.pacificpoker.com/PokerInstaller?" +sCut + "&dl="+loc;
        var origcid = getCookieValue(origCoockieName);
        var username = getCookieValue(userCoockieName);
        if (origcid != null)
            url = url + "&originalcid=" + origcid;
        if (username != null)
            url = url + "&username=" + username;
    }   
    else if (sLang == 'it') 
        url="http://" + ItalyDomainPoker + "/PokerInstaller?" +sCut + "&dl="+loc;
    else if (sLang == 'ar' || sLang == 'mx'  || sLang == 'la')
        url="http://es.pacificpoker.com/PokerInstaller?lang=es&" +sCutLang + "&dl="+loc;       
    else if (sLang=='cz')
        url="http://cs.pacificpoker.com/PokerInstaller?lang=cs&" +sCutLang + "&dl="+loc;       
    else if (sLang == 'br') 
        url="http://pt.pacificpoker.com/PokerInstaller?" +sCutLang + "&dl="+loc;       
    else if (sLang == 'cns') 
        url="http://www.pacificpoker.com/PokerInstaller?" +sCutLang + "&lang=en&dl="+loc;       
    else if (sLang == 'ee') 
        url="http://et.pacificpoker.com/PokerInstaller?" +sCutLang + "&lang=et&dl="+loc;       
	else    
        url="http://" + sLang + ".pacificpoker.com/PokerInstaller?" +sCut + "&dl="+loc;
    window.open(url,"popDown","width=1,height=1,top=0,left=0");
    //if arrived from landing page (out of the frame)
    if (window.name == "") {
        document.location.href = "/?page=download_short_poker&" + sCut;        
    }
    else {    
        setDownloadStatus();
        if (sLang == 'de')
            document.location.href = "/de/poker/download_short.htm?" + sCut + "&dl="+loc;       
        else if (sLang == 'bg'  || sLang == 'el'  || sLang == 'hu'  || sLang == 'pl'  || sLang == 'ro' || sLang == 'ee' || sLang == 'lt') 
            document.location.href = "/new888/home.htm?page=download_short_poker&" + sCut + "&dl="+loc; 
        else if ( sLang =='jp' )  
            document.location.href = "/?page=download_short_poker&" + sCut + "&dl="+loc; 
        else
            document.location.href = "/new888/home.htm?page=download_short_poker&" + sCut + "&dl="+loc;         
    }
    
}

function OpenPokerDownload(loc) {
    OpenDownPoker(loc);
} 

function getCookieValue(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) 
            return null;
    }
    else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
    
}
