﻿function doClick(buttonName,e)
{
    var keyunicode=e.charCode || e.keyCode    
    //the purpose of this function is to allow the enter key to 
    //point to the correct button to click.
    var key;					
    if(e.which){//firefox
        if (keyunicode == 13)
        {
            //Get the button the user wants to have clicked
            var btn = document.getElementById(buttonName);
            if (btn != null)
            { //If we find the button click it
                btn.click(); e.charCode = 0 ; //firefox
            }
        }                                              
    }
    else {
        key = e.keyCode; //IE    
        if (key == 13)
        {
            //Get the button the user wants to have clicked
            var btn = document.getElementById(buttonName);
            if (btn != null)
            { //If we find the button click it
                btn.click(); e.keyCode = 0 ; //IE
            }
        }                        
    }
}

        function init() {
        var TextFirstname = document.getElementById("TextFirstname");
        TextFirstname.focus();
        var today = new Date();
        document.getElementById("MonDayYear").innerHTML='<span class="month">'+today.toLocaleDateString()+'</span>';                        
        }
        
        function ButtonClientSubmit_onclick() {
            var TextFirstname = document.getElementById("TextFirstname");
            var TextLastname = document.getElementById("TextLastname");
            var TextLoginEmail = document.getElementById("TextLoginEmail");
            var Password1 = document.getElementById("Password1");
            var Password2 = document.getElementById("Password2");
            window.status = "Getting registration values ...";
            var inputValues = TextFirstname.value+"|"+TextLastname.value+"|"+TextLoginEmail.value+"|"+Password1.value+"|"+Password2.value;
            RS.Execute("LoginOrRegister.aspx","ServerSideReturn",inputValues,updateResult);
            window.status = "";
        }
        
        function updateResult(result){
            var TextFirstname = document.getElementById("TextFirstname");
            var TextLastname = document.getElementById("TextLastname");
            var TextLoginEmail = document.getElementById("TextLoginEmail");
            var Password1 = document.getElementById("Password1");
            var Password2 = document.getElementById("Password2");
        
            var TDMsg = document.getElementById("TDMsg");
            var TDKey = document.getElementById("TDKey");
            var TDError = document.getElementById("TDError");
            var TDLoginUrl = document.getElementById("TDLoginUrl");
            TDMsg.innerHTML="";
            TDKey.innerHTML="";
            TDError.innerHTML=""; 
            TDLoginUrl.innerHTML=""; 
            

            var returnAry = new Array();
            returnAry = result.split("|");
            if(returnAry[0]!="0"){
                TDError.innerHTML=returnAry[1];
                return;
            }
            TDMsg.innerHTML = "Thank for registering with Dynamic Geometry!";    
            TDLoginUrl.innerHTML="Please check your email and follow the instruction to active your account.";             
            TextFirstname.value="";
            TextLastname.value="";
            TextLoginEmail.value="";
            Password1.value="";
            Password2.value="";
        }