
// Get the HTTP Object
function getHTTPObject(){
    if (window.ActiveXObject) {
        return new ActiveXObject("Microsoft.XMLHTTP");
    } else if (window.XMLHttpRequest){ return new XMLHttpRequest();
    } else {
        alert("Your browser does not support AJAX.");
        return null;
    }
}   

// Change the value of the outputText field
function setStatus(){
    if(httpObject.readyState == 4){
        document.getElementById('isStudentPic').src = httpObject.responseText;
    }
}

// Change the value of the outputText field
function setMatch(){
    if(httpObject.readyState == 4){
        document.getElementById('matchPasswordPic').src = httpObject.responseText;
    }
}

// Change the value of the outputText field
function setValidPassword(){
    if(httpObject.readyState == 4){
        document.getElementById('validPasswordPic').src = httpObject.responseText;
    }
}

// Implement business logic    
function getStatus(){    
    httpObject = getHTTPObject();
    if (httpObject != null) {  
        var email = document.getElementById("email").value;       
        httpObject.open("GET", "scripts/validateLDAP.php?email="
                + email, true);
        httpObject.send(null); 
        httpObject.onreadystatechange = setStatus;
    }
}

// Implement business logic    
function getValidPassword(){    
httpObject = getHTTPObject();
    if (httpObject != null) {  
        var password = document.getElementById("password").value;
        var email = document.getElementById("email").value;   
        httpObject.open("GET", "scripts/validatePassword.php?email=" + email + "&password="
                + password, true);
        httpObject.send(null); 
        httpObject.onreadystatechange = setValidPassword;
    } 
}

// Implement business logic    
function getMatch(){    
httpObject = getHTTPObject();
    if (httpObject != null) {  
        var password = document.getElementById("newpassword").value;
        var repassword = document.getElementById("repassword").value;             
        httpObject.open("GET", "scripts/matchPassword.php?password=" + password + "&repassword="
                + repassword, true);
        httpObject.send(null); 
        httpObject.onreadystatechange = setMatch;
    } 
}

function addRow(){

    //add a row to the rows collection and get a reference to the newly added row
    var myTable = document.getElementById('login');
    var rows = myTable.getElementsByTagName('tr');

if ( rows.length == 3 )
{
    var newRow = myTable.insertRow(2);
    oCell = newRow.insertCell();
    oCell.innerHTML = "<img src=\"\" height=\"20\" id=\"passwordPic\" />"; 

    oCell = newRow.insertCell();
    oCell.innerHTML = "";

    oCell = newRow.insertCell();
    oCell.innerHTML = "<input type=\"password\" tabindex = \"3\" />";

    var oCell = newRow.insertCell();
    oCell.innerHTML = "Retype Password";

    var button = document.getElementById("goodToGo");
    button.value = "I agree to your terms.";
}
}


var httpObject = null;

