﻿﻿﻿function get_game() {

    gameId = document.getElementById('gameId').value;
    newNum = document.getElementById('mobilenumber').value;
       
    try {

        //strips double zeros

        if (newNum.substr(0, 2) == "00") {

            mob = newNum.substr(0, 2);

        }

        else

            mob = newNum;

        //if starts with 0 we presume UK

        l = mob.length;



        if (l > 10) {

            if (mob.substr(0, 1) == "0") {

                backMob = mob.substr(l - 10, 10);

                mob = "44" + backMob;

            }

        }

        var r = getXMLHttpRequest();

        if (r == null)

            alert("This feature does not work in your browser, try IE")

        else {

            r.onreadystatechange = function() {
                    handler(r);
            }

            r.open("GET", "~/mobile.aspx?gameId=" + gameId + "&mobile=" + mob, true);

            r.send(null);

        }

    }

    catch (err) {

        alert(err.description);

    }
}
    function handler(oReq) {

        if (oReq.readyState == 4 /* complete */) {

            if (oReq.status == 200) {                
                document.getElementById("mobile_response").innerHTML = oReq.responseText;
            } else {
                alert(oReq.responseText);
            }
        }

    }



    function getXMLHttpRequest() {

        if (window.XMLHttpRequest) {

            return new window.XMLHttpRequest;

        } else {

            try {

                return new ActiveXObject("MSXML2.XMLHTTP.3.0");

            } catch (ex) {

                return null;

            }

        }

    }




