var formsubmit = false; var disabled = false; var logoutTimeOut = null; var boxObjectName = ''; function gotoURL(url) { window.location.href = url; } function openChooseCountryDialog(closeOtherBoxFirst) { boxObjectName = 'choosecountrydialog'; if ((closeOtherBoxFirst) && (closeOtherBoxFirst.length > 0)) { destroyDialog(closeOtherBoxFirst); } showDialog('/includes/general/choosecountry.jsp?iaru=true', boxObjectName, 359); } function openChooseLanguageDialog(cid, closeOtherBoxFirst) { boxObjectName = 'chooselanguagedialog'; if ((closeOtherBoxFirst) && (closeOtherBoxFirst.length > 0)) { destroyDialog(closeOtherBoxFirst); } showDialog('/includes/general/chooselanguage.jsp?iaru=true&cid=' + cid, boxObjectName, 359); } function redir(cc, cl) { document.location = '/choosecountry.jsp?cc=' + cc + '&cl=' + cl; return false; } function openLoginDialog(gid, forwardurl, closeOtherBoxFirst, afterwardsURL) { boxObjectName = 'logindialog'; if ((closeOtherBoxFirst) && (closeOtherBoxFirst.length > 0)) { destroyDialog(closeOtherBoxFirst); } var url = '/includes/registration/login.jsp?iaru=true&gid=' + gid + '&forwardurl=' + escape(forwardurl); if (afterwardsURL == null || afterwardsURL == '') { afterwardsURL = '/'; } url += '&afterwardsurl=' + afterwardsURL; showDialog(url, boxObjectName, 359, 'snfield'); } function openForgotPasswordDialog(closeOtherBoxFirst, gid) { boxObjectName = 'forgotpassworddialog'; if ((closeOtherBoxFirst) && (closeOtherBoxFirst.length > 0)) { destroyDialog(closeOtherBoxFirst); } showDialog('/includes/registration/forgotpassword.jsp?iaru=true&gid=' + gid, boxObjectName, 359, 'emailfield'); } function showDialog(url, id, width, focusObj) { var xmlhttp = false; try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { xmlhttp = false; } } if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } xmlhttp.open("GET", url, true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { //alert(xmlhttp.responseText); createDialog(id, width, xmlhttp.responseText, focusObj); } } xmlhttp.send(null); } function createDialog(id, width, content, focusObj) { if (logoutTimeOut) { clearTimeout(logoutTimeOut); } disableElements(true); var pageSize = getPageSize(); var dialogParent = document.getElementsByTagName("BODY")[0]; var dialogObject = document.createElement("DIV"); var screenX = pageSize[0]; var screenY = window.screen.height; var boxWidth = width; var actualPageWidth = 760; var pageHeight = pageSize[1]; var xPos = ((screenX - actualPageWidth) / 2) + ((actualPageWidth - boxWidth) / 2); var yPos = document.body.scrollTop + 150; //alert(yPos); dialogParent.appendChild(dialogObject); dialogObject.style.width = boxWidth + 'px'; dialogObject.style.zIndex = '8'; dialogObject.style.position = 'absolute'; dialogObject.style.left = xPos; dialogObject.style.top = yPos; dialogObject.style.display = 'block'; dialogObject.id = id; dialogObject.innerHTML = content; if (document.getElementById(focusObj)) { // IE Rendering fix! (yes IE also needs fixes) document.getElementById(focusObj).focus(); document.getElementById(focusObj).focus(); } showOverlay(id); } function destroyDialog(id, closeOverlay) { var dialogParent = document.getElementsByTagName("BODY")[0]; var dialogObject = document.getElementById(id); disableElements(false); if (dialogObject) { dialogParent.removeChild(dialogObject); if (closeOverlay) { hideOverlay(); } } } function postDataToServlet(url, dataToSend, doRedirect, box) { var xmlhttp=false; try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { xmlhttp = false; } } if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } xmlhttp.open("POST", url, true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { //alert(xmlhttp.responseText); if (doRedirect) { if ((box) && (box.length > 0)) { //alert(document.getElementById(box)); document.getElementById(box).innerHTML = xmlhttp.responseText; } } } } xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xmlhttp.send(dataToSend); } function checkLoginForm() { var screenName = document.loginform.sn.value; var password = document.loginform.pwd.value; var redirURL = document.loginform.forwardurl.value; var afterURL = document.loginform.afterwardsurl.value; var gameSetID = document.loginform.gid.value; var xmlhttp = false; var url = '/UserLogin?sn=' + encodeHTML(screenName) + '&pwd=' + encodeHTML(password) + '&gid=' + gameSetID + '&forwardurl=' + redirURL; if (afterURL != null && afterURL != "") { url += '&afterwardsurl=' + afterURL; } try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { xmlhttp = false; } } if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } xmlhttp.open("GET", url, true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { //alert(xmlhttp.responseText); //alert(redirURL); if (xmlhttp.responseText.indexOf('loginsucceed') != -1) { //alert(redirURL); if (redirURL.indexOf("?") > -1) { redirURL = redirURL + '&isfromlogin=true'; } else { redirURL = redirURL + '?isfromlogin=true'; } if (afterURL != null && afterURL != "" && afterURL != "/") { redirURL += '&al=' + afterURL; } window.location.href = redirURL; } else { document.getElementById('logindialog').innerHTML = xmlhttp.responseText; document.getElementById('snfield').focus(); } } } xmlhttp.send(null); } function checkForgotPassWordForm() { var email = document.forgotpasswordform.email.value; var gameSetID = document.forgotpasswordform.gid.value; var xmlhttp = false; var url = '/RegistrationReminder?email=' + encodeHTML(email) + '&gid=' + gameSetID; try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { xmlhttp = false; } } if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } xmlhttp.open("GET", url, true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { //alert(xmlhttp.responseText); document.getElementById('forgotpassworddialog').innerHTML = xmlhttp.responseText; document.getElementById('emailfield').focus(); } } xmlhttp.send(null); } /** * Escape and encode text */ function encodeHTML(value) { encodedHtml = escape(value); encodedHtml = encodedHtml.replace(/\//g, "%2F"); encodedHtml = encodedHtml.replace(/\?/g, "%3F"); encodedHtml = encodedHtml.replace(/=/g, "%3D"); encodedHtml = encodedHtml.replace(/&/g, "%26"); encodedHtml = encodedHtml.replace(/@/g, "%40"); return encodedHtml; } function disableElements(disable) { var forms = document.forms; for (i = 0; i <= forms.length - 1; i++) { objects = forms[i].elements; objlength = objects.length; for (j = 0; j <= objlength - 1; j++) { objects[j].disabled = disable; } } }