//this function used to switch language
function goToLang(lang)
{
      var currentDomain = location.host;
      var pathname = (location.pathname).split("/"); 

      window.location.href = "http://" + currentDomain + "/" + pathname[1] + "/" + lang + "/" + pathname[3] +"?" + sCutLang +"&lang=" + lang;   
}

//this function downlads poker client with 8$ bonus (ver- 5.75) also an Unica event is invoked
function openDownPoker(location, unicaMsg)
{
   try {ntptEventTag("ev=wsop888poker_"+sLang+"_DOWNLOAD_" + unicaMsg);} catch(err) {} 
   
   //since  WsopInstaller is only in En no need to pass language to the installer servlet
   var url="/WsopInstaller?" + sCutLang + "&wsopLang=" + sLang + "&dl="+location;
    window.open(url,"popDown","width=1,height=1,top=0,left=0");    
}

//this function downlads pacific poker client also an Unica event is invoked
function DownloadPoker (location, unicaMsg)
{
   try {ntptEventTag("ev=wsop888poker_"+sLang+"_DOWNLOAD_" + unicaMsg);} catch(err) {} 
   
    var url="";
    var page = "";
    
    if (sLang == "en")
    {
         url="http://www.888poker.com/downloadclient.htm?downloadbrand=888poker&" + sCut + "&dl=" +location;
         page =  "http://www.888poker.com/download/download.htm?" + sCut + "&dl=" +location; 
    }
    else if (sLang == "es" || sLang == "fr" || sLang == "da" || sLang == "sv" || sLang == "pt" || sLang == "nl" || sLang == "de")
    {   
         url="http://" + sLang + ".888poker.com/downloadclient.htm?downloadbrand=888poker&" + sCut + "&dl=" +location;
         page =  "http://" + sLang + ".888poker.com/download/download.htm?" + sCut + "&dl=" +location;
    }    
     else if (sLang == "cz")    
    {
         url="http://cs.pacificpoker.com/PokerInstaller?" + sCutLang + "&lang=cs&dl=" +location;
         page =  "http://cs.pacificpoker.com/cs/download_short.htm?" + sCutLang + "&lang=cs&dl=" +location;
    }
    else if (sLang == "ee")
    {
        url="http://et.pacificpoker.com/PokerInstaller?" +sCutLang + "&lang=et&dl=" +location;
        page =  "http://et.pacificpoker.com/et/download_short.htm?" +sCutLang + "&lang=et&dl=" +location;
    }
    else
    {    
        url="http://" + sLang + ".pacificpoker.com/PokerInstaller?" +sCut + "&dl="+location;
        page =  "http://" + sLang + ".pacificpoker.com/" + sLang + "/download_short.htm?" + sCut + "&dl=" +location;
    }
    window.open(url,"popDown","width=1,height=1,top=0,left=0");
    document.location.href = page;
}

//this function open the NDL poker client (flahs) also an Unica event is invoked
function openPoker(location, unicaMsg)
{
    var w = 801;
    var h = 571;

     var filename = "";
     if (sLang == "es" || sLang == "de")
         filename = "http://ndl.888.com/poker/flashpoker_real/application/RLFLashPoker.html?langid=" + sLang + "&brand=1&skin=4&" + sCutLang + "&dl=" + location; 
     else
         filename = "http://ndl.888.com/poker/flashpoker_real/application/RLFLashPoker.html?langid=" + sLang + "&brand=1&skin=0&" + sCutLang + "&dl=" + location; 

    var l = (window.screen.width-w)/2;
    var t = (window.screen.height-h)/2;
    try {ntptEventTag("ev=wsop888poker_"+sLang+"_NDL_" + unicaMsg);} catch(err) {}
    window.open(filename,"Offline","resizable=no,status=no,scrollbars=no,toolbar=no,menubar=no,left=" + l + ",top=" + t + ",width=" + w + ",height=" + h);
}

//this function open/close the T&C expendable div
function showHideTerms() {	
	var terms = document.getElementById("terms");
	var expander = document.getElementById("expander");
	
	if(terms.style.display == "none" || terms.style.display == "")
	{		
		terms.style.display = "block";
		expander.innerHTML = "&#8211;";
	}
	else
	{
		terms.style.display = "none";
		expander.innerHTML = "+";
	}
}

function ChangeIMG(IMG,name){
    var index = name.indexOf("_o.gif");
    var sPicName="";
    if (index!=-1){
        sPicName= name.substr(0,index);
        sPicName = sPicName + ".gif"
    }
    else{
        index = name.indexOf(".gif");
        sPicName= name.substr(0,index);
        sPicName = sPicName + "_o.gif";
    }
    IMG.src = sPicName;
}

function ChangeImgJpg(IMG,name){
    var index = name.indexOf("_o.jpg");
    var sPicName="";
    if (index!=-1){
        sPicName= name.substr(0,index);
        sPicName = sPicName + ".jpg"
    }
    else{
        index = name.indexOf(".jpg");
        sPicName= name.substr(0,index);
        sPicName = sPicName + "_o.jpg";
    }
    IMG.src = sPicName;
}

function ChangeBgIMG(element){
	var imgPath = element.style.backgroundImage;
	
	if(imgPath.indexOf("_s.gif") != -1)
	{
		return;
	}
	
	var index = imgPath.indexOf("_o.gif");
    if (index!=-1){
        imgPath = imgPath.replace("_o.gif", ".gif");
    }
    else
	{
		imgPath = imgPath.replace(".gif", "_o.gif");
    }
	
	element.style.backgroundImage = imgPath;
}

function setSelectedBgImg(element, selected)
{
	var imgPath = element.style.backgroundImage;
	if(selected)
	{
		imgPath = imgPath.replace("_o.gif", "_s.gif");	
	}
	else
	{
		imgPath = imgPath.replace("_s.gif", ".gif");
	}		
	
	element.style.backgroundImage = imgPath;
}
