
function closeWin()
{
    if(PopupWindow){PopupWindow.close();}
}
function JavaRedirect()
{
	NoDownUK('../','0');
}
function OpeneCogra()
{
	var w = 496;
	var h = 506;
	//if( sLang == "fr" ){w = 530;	h = 557;}	
	//else if( sLang == "it" ){w = 530;h = 565;}
	//else if( sLang == "es" ){w = 525;h = 585;}
	var l = (window.screen.width-w)/2;
	var t = (window.screen.height-h)/2;
        //if (sLang =="jp")
        //    window.open("ecogra.htm","eCogra","resizable=yes,status=no,scrollbars=no,toolbar=no,menubar=no,left=" + l + ",top=" + t + ",width=" + w + ",height=" + h);
        //else if  (sLang =="tr")
        //          window.open("lang/"+ sLang +"/texts/ecogra.htm","eCogra","resizable=yes,status=no,scrollbars=no,toolbar=no,menubar=no,left=" + l + ",top=" + t + ",width=" + w + ",height=" + h);
        //else
            window.open("/new888/lang/" + sLang + "/texts/ecogra.htm","eCogra","resizable=yes,status=no,scrollbars=no,toolbar=no,menubar=no,left=" + l + ",top=" + t + ",width=" + w + ",height=" + h);
}
function addParams(a)
{
    
    //because players club opens in a new window we must not
    //concatinate parameters if it already has ones.
    if(a.href.indexOf("playersclub.888")==-1 ||  a.href.indexOf("?")==-1)
    {
        if(a.href.lastIndexOf("/") ==  a.href.length -1 || a.href.lastIndexOf("htm") ==  a.href.length -3)
            a.href+="?" +sCut;
        else
            a.href+="&" + sCut;
    }
    
}


function window_onscroll()
{
    if(sLang != "jp")
    {
        if(document.all && document.getElementById) //added for IE4
        {
            if(window.document.getElementById("scrollPict"))
                window.document.getElementById("scrollPict").style.top=document.body.scrollTop+pictTop;
        }
        else if(document.all && !document.getElementById) //added for IE4
        {
            if(document.all['scrollPict'])
                document.all['scrollPict'].style.top=document.body.scrollTop+pictTop;
        }
    }
    else
    {

        if (navigator.appName=="Netscape")
        {
           if(document.getElementById(scrollID))
            {
                    var newTop=document.body.scrollTop+50;
                    if (newTop>pictTop)
                    {
                            if (newTop>maxTop) 
                            {
                                    newTop=maxTop;
                            }
                            document.getElementById(scrollID).style.top=newTop;
                            document.getElementById(scrollID).style.position="absolute"
                    }
                    else
                    {
                            window.document.getElementById(scrollID).style.top=pictTop;
                    }
            } 
        }
        else
        {
            if(document.all && document.getElementById) //added for IE4
            {
                if(document.getElementById(scrollID))
                        {
                                var newTop=document.body.scrollTop+20;
                                if (newTop>pictTop)
                                {
                                        if (newTop>maxTop) 
                                        {
                                                newTop=maxTop;
                                        }
                                        //document.getElementById("download").alt=newTop;
                                        document.getElementById(scrollID).style.top=newTop;
                                }
                                else
                                {
                                        window.document.getElementById(scrollID).style.top=pictTop;
                                }
                        }
            }
            else if(document.all && !document.getElementById) //added for IE4
            {
                if(document.all[scrollID])
                    document.all[scrollID].style.top=document.body.scrollTop+pictTop;
            }
        }
    }

  

}

function HandCursor(obj)
{
    obj.style.cursor='hand';
}

function OpenPopUp()
{
    var w = 314;
    var h = 459;
    var l = (window.screen.width-w)/2;
    var t = (window.screen.height-h)/2; 
    var filename = "/new888/popupgames.htm";
  
    window.open(filename + "?" + sCut,null,
    "height=" + h + ",width=" + w + ",status=no,toolbar=no,menubar=no,location=no,resize=no,left="+l+",top="+t);
}

function PopPhone(Content)
{
    var PhoneWindow
    if(window.document.FrmPhone.SupportPhones.selectedIndex!=0)
    {
        PhoneWindow = window.open('','',"toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=360,height=140,left=300,top=240");
        PhoneWindow.document.write('<html><head><title>Contact Support by Telephone - Casino-on-Net</title></head><body bgcolor="#4b9e3b"><table width="100%" align="center"><tr><td valign="middle"><br><a style="color:#ffffff;FONT-FAMILY: Verdana;FONT-WEIGHT: bold;FONT-SIZE: 12px;">' + Content + '</a></td></tr></table></body></html>');
    }
}

function OpenPop(address)
{
    var w = 480; 
    var h = 350;
    var l = (window.screen.width-w)/2;
    var t = (window.screen.height-h)/2;
    var windowprops = "location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=no,left=" + l + ",top=" + t + ",width=" + w + ",height=" + h;
    window.open(address,"Flash",windowprops);
}

function openPromWindow(num)
{
    var url = "";
    if (sLang == "en")
    {
        url= "http://news.casino-on-net.com/" + sLang;	
    }
    else
    {
        url= "http://playersclub.888.com/Default.asp?" + sCut;
    }
    if(num != 0)
    {
        url = url + "&TN=" + num;
    }
    nwin=window.open(url, "nwin","scrollbars=yes,resizable=yes,toolbar=yes,location=yes,status=yes,menubar=yes,height=450,width=650");
    nwin.focus();
}

function ChangePic(PicName,imgFile)
{
	document[PicName].src=imgFile
}

function OpenBJSchool(dl)
{
	var w = 794;
	var h = 517;
	//var l = (window.screen.width-w)/2;
	//var t = (window.screen.height-h)/2;
	var Location;
	//204.92.99.140
	Location = "http://standalone.888.com/bjschool/bjschool.htm?lang=" + sLang + "&s=" + sSession + "&sr=" + sSerial + "&st=" + sSiteTest + "&bc=" + sBC + "&anid=" + sANID + "&dl=" + dl;
	window.open(Location,"","resizable=yes,status=no,scrollbars=no,toolbar=no,menubar=no,left=0,top=0,width=" + w + ",height=" + h);
}

function ContactUs()
{
    var w = 793;
    var h = 517;
    var LocationString = "/new888/lang/en/texts/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 ContactUsVIP()
{
    var w = 793;
    var h = 517;
    var LocationString = "lang/" + sLang + "/texts/contactusform/contactus.htm?" + sCut + "&status=1";
    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 ContactUsPoker()
{
    var w = 793;
    var h = 517;
    var LocationString = "http://www.pacificpoker.com/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 check_mail(str)
{
        var myRegExp = /^([a-zA-Z0-9_\-])+([a-zA-Z0-9_\.\-])*\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})$/
        if( ! str.match( myRegExp ) )
        {
                return false
        }
        return true
}

function check_name(str)
{
        var myRegExp = /^[^;~\^&\*!<>"\/|%\?@$0-9\+=\{\}\(\)\[\]\\]*$/ 
        if( ! str.match( myRegExp ) )
                return false

        return true
}


function check_str(str)
{
        var myRegExp = /^[^;~\^&\*!<>"\/|%\?@$\+=\{\}\(\)\[\]\\]*$/
        if( ! str.match( myRegExp ) )
                return false
        return true
}

function check_num(str)
{
        var myRegExp = /^[0-9]{4,9}$/
        if( ! str.match( myRegExp ) )
                return false
        return true
}

function check_phonenum(str)
{
if(str ==  "")
    return  true
 else
 {
                var myRegExp = /^[0-9\-]{1,20}$/
                if( ! str.match( myRegExp ) )
                        return false
 }
return true
}

function ContactUsSv()
{
    var w = 793;
    var h = 517;
    var LocationString = "lang/en/texts/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 PopPhonePoker(Content)
{
    var PhoneWindow
   
    if(window.document.FrmPhonePoker.SupportPhonesPoker.selectedIndex!=0)
    {
        PhoneWindow = window.open('','',"toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=360,height=170,left=320,top=320");
        PhoneWindow.document.write('<html><head><title>Contact Support by Telephone - Pacific Poker</title></head><body bgcolor="#4b9e3b"><table width="100%" align="center"><tr><td valign="middle"><br><a style="color:#ffffff;FONT-WEIGHT: bold;FONT-SIZE: 12px;FONT-FAMILY: Verdana;" >' + Content + '</a></td></tr></table></body></html>');
    }
}

function iafImages(elementID,newPic)
{
   var thePic = document.getElementById(elementID);
   thePic.src = newPic;
}

function iafInitializePage()
{
    document.getElementById('step1').display="block";
    document.getElementById('step2').display="none";
    document.getElementById('step3').display="none";
}

function getPosX(obj)
{
	var curleft = 0;
	while (obj.offsetParent)
	{
	  curleft += obj.offsetLeft;
	  obj = obj.offsetParent;
	}
	return curleft;

}
function getPosY(obj)
{
	var curtop = 0;
	while (obj.offsetParent)
	{
	  curtop += obj.offsetTop;
	  obj = obj.offsetParent;
	}
	return curtop;

}
function iafShowHelp(helpType)
{
    
    if(helpType == 'emailHelpDiv')
    {
        var referencePoint = document.getElementById('emailInfoImage');
        var x = getPosX(referencePoint) + referencePoint.width + 5;
        var y = getPosY(referencePoint);
        var theHelpDiv = document.getElementById(helpType);
        theHelpDiv.style.position = "absolute";
        theHelpDiv.style.top = y;
        theHelpDiv.style.left = x;
        theHelpDiv.style.display = "block";
    }
    else if(helpType == 'nameHelpDiv')
    {
        var referencePoint = document.getElementById('nameInfoImage');
        var x = getPosX(referencePoint) + referencePoint.width + 5;
        var y = getPosY(referencePoint);
        var theHelpDiv = document.getElementById(helpType);
        theHelpDiv.style.position = "absolute";
        theHelpDiv.style.top = y;
        theHelpDiv.style.left = x;
        theHelpDiv.style.display = "block";
    }
    else if(helpType == 'whyHelpDiv')
    {
        var referencePoint = document.getElementById('whyDivPoint');
        var x = getPosX(referencePoint) + 5;
        var y = getPosY(referencePoint) + 5;
        var theHelpDiv = document.getElementById(helpType);
        theHelpDiv.style.position = "absolute";
        theHelpDiv.style.top = y;
        theHelpDiv.style.left = x;
        theHelpDiv.style.display = "block";
    }
    else if(helpType == 'personalEmailHelp')
    {
        var referencePoint = document.getElementById('emailClientInfo');
        var x = getPosX(referencePoint) - 50;
        var y = getPosY(referencePoint) - 222;
        var theHelpDiv = document.getElementById(helpType);
        theHelpDiv.style.position = "absolute";
        theHelpDiv.style.top = y;
        theHelpDiv.style.left = x;
        theHelpDiv.style.display = "block";
    }
    else if(helpType == 'webMailHelp')
    {
        var referencePoint = document.getElementById('systemInitationHelp');
        var x = getPosX(referencePoint) - 50;
        var y = getPosY(referencePoint) - 5;
        var theHelpDiv = document.getElementById(helpType);
        theHelpDiv.style.position = "absolute";
        theHelpDiv.style.top = y;
        theHelpDiv.style.left = x;
        theHelpDiv.style.display = "block";
    }
    else if(helpType == 'emailClientOptionHelp')
    {
        var referencePoint = document.getElementById('emailClientOptionInfo');
        var x = getPosX(referencePoint) + referencePoint.width - 100;
        var y = getPosY(referencePoint) - 5;
        var theHelpDiv = document.getElementById(helpType);
        theHelpDiv.style.position = "absolute";
        theHelpDiv.style.top = y;
        theHelpDiv.style.left = x;
        theHelpDiv.style.display = "block";
    }
    else if(helpType == 'webBasedEmailOptionHelp')
    {
        var referencePoint = document.getElementById('webBasedEmailOptionInfo');
        var x = getPosX(referencePoint) + referencePoint.width - 100;
        var y = getPosY(referencePoint) - 5;
        var theHelpDiv = document.getElementById(helpType);
        theHelpDiv.style.position = "absolute";
        theHelpDiv.style.top = y;
        theHelpDiv.style.left = x;
        theHelpDiv.style.display = "block";
    }

}
function iafHideHelp(helpType)
{
          document.getElementById(helpType).style.display="none";
}
function iafExtendEmailBoxes()
{
    
    var i=1;
    for(i=1;i<=5;i++)
    {
        var rowToShow = "row" + i;
        if(navigator.userAgent.indexOf("MSIE")!=-1)
            document.getElementById(rowToShow).style.display="block";
        else
            document.getElementById(rowToShow).style.display="table-row";
    }
    document.getElementById('extendEmails').style.display="none";
    
    if(navigator.userAgent.indexOf("MSIE")!=-1)
        document.getElementById('hideEmails').style.display="block";
    else
        document.getElementById('hideEmails').style.display="table-cell";

    window.scrollTo(0,450);

}
function iafShrinkEmailBoxes()
{
    var i=1;
    for(i=1;i<=5;i++)
    {
        var rowToShow = "row" + i;
        document.getElementById(rowToShow).style.display="none";
    }
    if(navigator.userAgent.indexOf("MSIE")!=-1)
        document.getElementById('extendEmails').style.display="block";
    else
        document.getElementById('extendEmails').style.display="table-cell";
 
    document.getElementById('hideEmails').style.display="none";
    window.scrollTo(0,150);
}
function iafHandleRadio(id)
{
    var radioClicked = document.getElementById(id);
    if(id == 'sendMailChoiceWeb')
    {
        document.getElementsByName('emailChoice')[0].checked = false;
        document.getElementsByName('emailChoice')[1].checked = false;
    }
    else if(id == 'emailChoiceWeb' || id == 'emailChoiceClient')
    {
        document.getElementById('sendMailChoiceWeb').checked = false;
        document.getElementById('sendMailChoicePersonal').checked = true;
    }
    else if(id == 'sendMailChoicePersonal')
    {
        if(document.getElementsByName('emailChoice')[1].checked == false)
            document.getElementsByName('emailChoice')[0].checked = true;
    }
}
function copyToClipBoard(id)
{
    var message = "";
    var newMessage = "";
    var tempArray = "";
    var theUserName = "";
    var theUserEmail = "";
    var isIE = false;
    if(navigator.appName.indexOf("Microsoft")!=-1)
    {
        isIE = true;
    }
    
    if(isIE)
    {
        var x = document.getElementById(id);
        x.select();
        var y = x.createTextRange();
        y.execCommand('copy');
    }
    else
    {
         var x = document.getElementById(id);
         x.setSelectionRange(0,x.value.length);
         x.focus();
    }
   
   

    //if(id == 'invitationWebMailText')
    //{
    //    theUserName = document.getElementById('userName').value;
    //    theUserEmail = document.getElementById('userEmail').value;

    //    message = document.getElementById('invitationWebMailText').innerText;
    //   tempArray = message.split('#webMailFirstName#');
    //    newMessage = tempArray[0] + document.getElementById('userFirstName').value;
    //    newMessage += tempArray[1] + "&username=" + theUserName + "&useremail=" + theUserEmail;
    //    document.getElementById('tempTextArea').innerText= newMessage
    //    id = 'tempTextArea';
    //}
    //var x = document.getElementById(id).createTextRange();
    //x.execCommand('copy');
}
function iaf_checkEmail(el,elName)
{
        //alert(el.value);
	if (/^\w+([\.-]\w+)*@\w+([\.-]\w+)*(\.\w{2,3})+$/.test(el.value)&& el.value.length <= 50){

		return true;
	}
	alert("Invalid email address")
	el.focus();
	el.select();
	return false;
}
function iaf_checkUserName(el,elName)
{
	var check = /^[^;~\$\^&\*!<>|%\?@]*$/.test(el.value);
	var check1 = /^[a-zA-Z0-9_]*$/.test(el.value);
	if (check && check1 && el.value.length <= 10){
		return true;
	}
	alert("Invalid " + elName)
	el.focus();
	el.select();
	return false;
}
function iaf_checkNames(el,elName)
{
	var check = /^[^;:~\$\^&,\#\/\\\*!<>|%\?@]*$/.test(el.value);
	var check1 = /^[a-zA-Z]+[a-zA-Z\s-]*$/.test(el.value);
	if (check && check1 && el.value.length <= 50){
		return true;
	}
	alert("Invalid " + elName)
	el.focus();
	el.select();
	return false;
}
function iaf_checkPasswd(el,elName)
{
	var check = /^[^;:~\$\^&,\#\/\\\*!<>|%\?@]*$/.test(el.value);
        if (check && el.value.length <= 50 && el.value.length > 0){
		return true;
	}
	alert("Invalid " + elName)
	el.focus();
	el.select();
	return false;
}
function iaf_checkRequired(el,elName)
{
	if (el.value == "")
	{
		alert("Please enter your " + elName);
		el.focus();
		el.select();
		return false;
	}
	else return true;
}
function iafShowStep(currentStep,targetStep)
{
    var i=0;
    var nextStep="";
    var inivitationEmailText="";
    var theUserName = "";
    var theUserEmail = "";
    var theForm = "";

    if(targetStep == 'step3')
    {
        
        if(document.getElementById('sendMailChoicePersonal').checked == true)
        {
    
            submitStatus = "";
            document.getElementById('step2userNameHidden').value = document.getElementById('userName').value;
            document.getElementById('step2userFirstNameHidden').value = document.getElementById('userFirstName').value;
            document.getElementById('step2userEmailHidden').value = document.getElementById('userEmail').value;
            document.getElementById('step2userPasswordHidden').value = document.getElementById('userPassword').value;
            document.getElementById('step2iafst').value = 1;
            document.getElementById('step2uc').value = 1;

            theForm = document.getElementById('step2form');
            theForm.target = "DBResponse";
            theForm.submit();
            uc_submitted = 1;
            
            

        }
 /*      
        else if(document.getElementsByName('emailChoice')[1].checked == true)
        {
            
            submitStatus = "";
            document.getElementById('step2userNameHidden').value = document.getElementById('userName').value;
            document.getElementById('step2userFirstNameHidden').value = document.getElementById('userFirstName').value;
            document.getElementById('step2userEmailHidden').value = document.getElementById('userEmail').value;
            document.getElementById('step2userPasswordHidden').value = document.getElementById('userPassword').value;
            document.getElementById('step2iafst').value = 1;
            document.getElementById('step2uc').value = 2;
            theForm = document.getElementById('step2form');
            theForm.target = "DBResponse";
            theForm.submit();
            uc_submitted = 2;
        }
*/
        else
        {

            nextStep = "systemMail";
            document.getElementById('step2').style.display = "none";
            document.getElementById('step3a').style.display = "block";
            window.document.all("friendName1").focus();
        }
    }

    else if(targetStep == 'step3Submit')                    //Relevant for the old IAF test ?
    {
        var DBAnswer = window.DBResponse.document.getElementById('yaniva').value; 
        //alert(DBAnswer);
        if(DBAnswer == "true")
        {
           window.location.href='home.htm?page=iafthanks2&' + sCut; 
        }
        else if(DBAnswer == "false")
        {
            window.location.href='home.htm?page=iafthanks2&' + sCut; 
        }
    }

    else if(targetStep == 'step2' && currentStep == 'step1')
    {
        var validEntry=true;
        if(!iaf_checkNames(document.getElementById('userFirstName'),'Name'))
        {
            validEntry = false;
        }
        else if(!iaf_checkEmail(document.getElementById('userEmail'),'Email'))
        {
            validEntry = false;
        }
        else if(document.getElementById('userName').value != "")
        {
            if(!iaf_checkUserName(document.getElementById('userName'),'Username'))
            {
               validEntry = false; 
            }
            else if(!iaf_checkPasswd(document.getElementById('userPassword'),'Password'))
            {
                validEntry = false;
            }
        }
        if(validEntry)
        {
            document.getElementById('step2').style.display= "block";
            document.getElementById('step1').style.display= "none";
            document.getElementById('step3a').style.display= "none";
            //document.getElementById('step3').style.display= "none";
            window.document.all("sendMailChoicePersonal").focus();
        }
    }
    else if(targetStep == 'step2' && (currentStep == 'step3' || currentStep == 'step3a'))
    {
 
            document.getElementById('step2').style.display= "block";
            document.getElementById('step3a').style.display= "none";
            //document.getElementById('step3').style.display= "none";
            window.document.all("sendMailChoicePersonal").focus();
    }
    else if(targetStep == 'step2Submit' && currentStep == 'step2' )
    {
        
    }
    else if(targetStep == 'step1')
    {
        
        document.getElementById('step2').style.display= "none";
        document.getElementById('step1').style.display= "block";
        document.getElementById('userFirstName').focus();
    }
    else if(targetStep == 'step3a')
    {
        
        document.getElementById('step3a').style.display= "block";
        document.getElementById('step2').style.display= "none";
        window.document.all("friendName1").focus();
    }
}
function iafSubmit()
{
    var friendAmount = 10;
    var validData = true;
   


    if(document.getElementById('friendName1').value == "")
    {    
        validData = false;
        alert('Please enter your Friend Name');
    }
    else if(document.getElementById('friendEmail1').value == "")
    {
        validData = false;
        alert('Please enter your Friend Email');
    }
    else if(!iaf_checkNames(document.getElementById('friendName1'),'Friend Name'))
    {
        validData = false;
    }
    else if(!iaf_checkEmail(document.getElementById('friendEmail1'),'Friend Email'))
    {
        validData = false;
    }
    var i=0;
    if(validData==true)
    {
       for(i=1;i<=friendAmount;i++)
	{
            if(iaf_Trim(document.getElementById('friendEmail'+i).value) != "" && iaf_Trim(document.getElementById('friendName'+i).value) !="")
            {
                    //alert(i);
                    if(!iaf_checkNames(document.getElementById('friendName'+i),'Friend Name') || !iaf_checkEmail(document.getElementById('friendEmail'+i),'Friend Email'))
                    {
                        //alert('inside ' + i);
                        validData = false;
                        break;
                    }
                    //alert('outside ' + i);
            }
            else
            {
                    //alert('inside else ' + i);
                    if((iaf_Trim(document.getElementById('friendEmail'+i).value) == "" && iaf_Trim(document.getElementById('friendName'+i).value) != "") ||
                       (iaf_Trim(document.getElementById('friendEmail'+i).value) != "" && iaf_Trim(document.getElementById('friendName'+i).value) == ""))
                    {
                            alert('Friend Name and Email both must be filled.');
                            document.getElementById('friendName'+i).focus();
                            validData = false;
                            break;
                    }
                    //alert('outside else ' + i);
            }
	}
     }
     if(validData==true)
     {
        document.getElementById('userNameHidden').value = document.getElementById('userName').value;
        document.getElementById('userFirstNameHidden').value = document.getElementById('userFirstName').value;
        document.getElementById('userEmailHidden').value = document.getElementById('userEmail').value;
        document.getElementById('userPasswordHidden').value = document.getElementById('userPassword').value;
        document.getElementById('iafst').value = 1;
        document.getElementById('uc').value = 0;
        var theForm = document.getElementById('frmMain');
        
        theForm.submit();
     }
    
}

function iaf_Trim(inString)
{
	var retVal = "";
	var start = 0;
	while ((start < inString.length) && (inString.charAt(start) == ' ')) 
	{
		++start;
	}
	var end = inString.length;
	while ((end > 0) && (inString.charAt(end - 1) == ' '))
	{
		--end;
	}
	retVal = inString.substring(start, end);
	return retVal;
}
function iaf_processDBResponse(dbResponseFromIFRAME,environment)
{
    var i=0;
    var nextStep="";
    var inivitationEmailText="";
    var theUserName = "";
    var theUserEmail = "";
    var theForm = "";
    var theHost = window.location.host;
    if(uc_submitted==1)
    {
        if(dbResponseFromIFRAME == 'true')
        {

            var newSCut="";
            var scutArray = iaf_sCut.split('&');
            for(i=0;i<scutArray.length;i++)
                newSCut +=scutArray[i] + "%26";

            theUserFirstName = document.getElementById('userFirstName').value;
            nextStep = "emailClient";
            inivitationEmailText = document.getElementById('invitationTextPersnoalEmail').innerHTML;
            var tempArray = inivitationEmailText.split('#senderName#');
            inivitationEmailText = tempArray[0] + theUserFirstName + tempArray[1];


            theUserEmail  = document.getElementById('userEmail').value;
            theUserName  = document.getElementById('userName').value;
            
            var en_firstName = iafEncode(theUserFirstName);
            var tempurl= "http://" + theHost + "/new888/lang/en/texts/iafexamplev2.htm?s=" + sSession + "%26username=" + en_firstName + "%26sr=654971";

            tempArray = inivitationEmailText.split('#iafExampleurl#');
            inivitationEmailText = tempArray[0]  + tempurl + tempArray[1];
 

            
           if (environment == 'local'){
                 window.location.href="mailto:?cc=friends-bonus-test@888.com&subject=An invitation from me&body=" + inivitationEmailText;
            }
            else
            {
                  window.location.href="mailto:?cc=friends-bonus@888.com&subject=An invitation from me&body=" + inivitationEmailText;
            }
            
            window.open("iaf_emailClientpopup.htm","Invitation","width=530,height=386");
            window.location.href='/?page=iafthanks2&' + iaf_sCut;
        }
        else
        {
             window.location.href='/?page=iaf_error&' + iaf_sCut
        }
    }
    if(uc_submitted==2)
    {
        if(dbResponseFromIFRAME == 'true')
        {
            
            if(navigator.appName.indexOf("Microsoft")!=-1)
            {
                var theUserFirstName = document.getElementById('userFirstName').value;
                var en_firstName = iafEncode(theUserFirstName);
                var temp = document.getElementById('testPersnoalEmail').innerText;
                var tempArray = temp.split('#senderName#');
                temp = tempArray[0] + theUserFirstName + tempArray[1];
                
                var tempurl= "http://" + theHost + "/new888/lang/en/texts/iafexamplev2.htm?s=" + sSession + "&username=" + en_firstName + "&sr=654971";
                tempArray = temp.split('#iafExampleurl#');
                temp = tempArray[0] + tempurl + tempArray[1];
                
            }
            else
            {
                var theUserFirstName = document.getElementById('userFirstName').value;
                var en_firstName = iafEncode(theUserFirstName);
                var temp = document.getElementById('testPersnoalEmail').value;
                var tempArray = temp.split('#senderName#');
                temp = tempArray[0] + theUserFirstName + tempArray[1];


                var tempurl= "http://" + theHost + "/new888/lang/en/texts/iafexamplev2.htm?s=" + sSession + "&username=" + en_firstName + "&sr=654971";
                tempArray = inivitationEmailText.split('#iafExampleurl#');
                temp = tempArray[0] + tempurl + tempArray[1];
            }
            
            document.getElementById('theInnerFrame').value = temp;
            document.getElementById('step2').style.display = "none";
            document.getElementById('step3').style.display = "block";
        }
        else
        {
             window.location.href='/?page=iaf_error&' + iaf_sCut
        }
    }
}
function iaf_clickOnEnter(elementId)
{
	var btnEl
	//return in key pressed in a text area
	if(event.srcElement.tagName=="TEXTAREA")return;
	
	//this function cancel the Enter default action 
	if (event.keyCode==13){
		if (typeof(elementId) == "string")
			btnEl = document.getElementById(elementId)
		else btnEl = elementId
	
		if (btnEl != null)
		{
			btnEl.focus();
			btnEl.click();
			event.returnValue=false;
		}
	}
}
function iafEncode(u)
{
    var newu = "";
    var arr = u.split(" ");
    for(i=0;i<arr.length;i++)
    {
        newu += arr[i] + "_";
    }
    return newu;
}

function OpenInfo(sLang)
{
    var w = 405;
    var h = 252;
    var LocationString;
    var l = (window.screen.width-w)/2 - 12;
    var t = (window.screen.height-h)/2 - 12;
    var windowprops = "location=no,status=no,scrollbars=no,menubars=no,toolbars=no,resizable=no,left=" + l + ",top=" + t + ",width=" + w + ",height=" + h;
    var filename = "http://www.pacificpoker.com/pokerinfo.htm" + "?lang=" + sLang;
    var pokerinfo = window.open(filename,"PokerInfo",windowprops);
}
//for danish affilate + invite a friend links
function addParamsEn(a)
{  
    //because players club opens in a new window we must not
    //concatinate parameters if it already has ones.
    if(a.href.indexOf("playersclub.888")==-1 ||  a.href.indexOf("?")==-1)
    {
        if(a.href.lastIndexOf("/") ==  a.href.length -1 || a.href.lastIndexOf("htm") ==  a.href.length -3)
            a.href+="?" + sCutLang + "&lang=en";
        else
            a.href+="&" + sCutLang + "&lang=en";
    }    
}

function setFolatingDownloadPosX()
{
    if(document.all)
    {
        if(document.all['scrollPict'])
        {
            if(document.getElementById){document.all['scrollPict'].style.position="absolute";}
            ofw=document.body.offsetWidth;
            var diff=(1024-ofw)/2;
            if(ofw<1040 && ofw>819)
            {            
                if(diff<130)
                    window.document.all['scrollPict'].style.left=130-diff;
            }
            else if (ofw>1041)
                window.document.all['scrollPict'].style.left=130-diff;
            else if(ofw<820)
                window.document.all['scrollPict'].style.left=10;
        }
    }
}

function openTermsGift(id)
{
    var terms=document.getElementById("terms" + id); 
    terms.style.display="inline"; 
    var termsLabel=document.getElementById("openterms" + id); 
    termsLabel.style.display="none"; 
}

function closeTermsGift(id)
{
    var terms=document.getElementById("terms" + id); 
    terms.style.display="none"; 
    var termsLabel=document.getElementById("openterms" + id); 
    termsLabel.style.display="inline"; 
}


//for pwc iTech reports
function ShowPdfReport(Val,sImgPathNew)
{
    if(Val != "0")
    {
        var tmpObj= document.getElementById("ReportImg");
        tmpObj.src= sImgPathNew + "/lang/en/images/pwc/pwc_" + Val + ".gif";
        tmpObj.height=800;
        tmpObj.width=580;   
    }
}

function openItechReport(Val)
{
    if (Val == 'Jun07' || Val == 'May07' || Val == 'Apr07' || Val == '043007' || Val == '033007' || Val == '023007')
    {
        var url="http://www.itechlabs.com.au/certificates/Cassava/CON_audit_report_" + Val + ".pdf";
        window.open(url,"itech","resizable=yes,status=yes,location=yes,scrollbars=yes,toolbar=yes,menubar=yes");
    
        var tmpObj= document.getElementById("textLink");
        tmpObj.href="http://www.itechlabs.com.au/certificates/Cassava/CON_audit_report_" + Val + ".pdf";
    }
    else
    {
        var url="http://www.itechlabs.com.au/certificates/Cassava/Cassava_RTP_audit_report_" + Val + ".pdf";
        window.open(url,"itech","resizable=yes,status=yes,location=yes,scrollbars=yes,toolbar=yes,menubar=yes");
    
        var tmpObj= document.getElementById("textLink");
        tmpObj.href="http://www.itechlabs.com.au/certificates/Cassava/Cassava_RTP_audit_report_" + Val + ".pdf";     
    }
 }

function openItechQReport(Val)
{
    if(Val != "0") {

    var url="http://www.itechlabs.com.au/certificates/Cassava/RNG_report_" + Val + ".pdf";
    window.open(url,"itech","resizable=yes,status=yes,location=yes,scrollbars=yes,toolbar=yes,menubar=yes");
    
    var tmpObj= document.getElementById("textLink");
    tmpObj.href="http://www.itechlabs.com.au/certificates/Cassava/RNG_report_" + Val + ".pdf";    
    }
}
