//Browser Support Code
function runajax()
{ 
    //Create a boolean variable to check for a valid Internet Explorer instance.
    var xmlhttp = false;

    //Check if we are using IE.
    try {
        //If the javascript version is greater than 5.
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        //If not, then use the older active x object.
        try {
            //If we are using Internet Explorer.
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
            //Else we must be using a non-IE browser.
            xmlhttp = false;
        }
    }
    //If we are using a non-IE browser, create a javascript instance of the object.
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    	xmlhttp = new XMLHttpRequest();
    }

    return xmlhttp;
}

var http = runajax();
var nocache = 0;

var refreshrate = 2000;
//var queryrate   = 180000;
var queryrate   = 1000;

function forgot_username()
{
    showdiv('login_form_update');
    var queryString = "?cmd=forgot_username";
    
    var obj = document.getElementById('login_form_update');

    http.open ("GET","http://www.murfsystems.com/functions.php" + queryString + "");

    http.onreadystatechange = formReply;
    http.send(null);
}

function update_username()
{
    var email       = document.getElementById('email').value;
    var queryString = "?cmd=update_username&email=" + email;
    
    var obj = document.getElementById('login_from_update');

    http.open ("GET","http://www.murfsystems.com/functions.php" + queryString + "");

    http.onreadystatechange = formReply;
    http.send(null);
}

function forgot_password()
{
    showdiv('login_form_update');
    var queryString = "?cmd=forgot_password";

    var obj = document.getElementById('login_form_update');

    http.open ("GET","http://www.murfsystems.com/functions.php" + queryString + "");

    http.onreadystatechange = formReply;
    http.send(null);
}

function update_password()
{
    var email       = document.getElementById('email').value;
    var uname       = document.getElementById('username').value;
    var queryString = "?cmd=update_password&email=" + email +"&username="+ uname;
    
    var obj = document.getElementById('login_from_update');

    http.open ("GET","http://www.murfsystems.com/functions.php" + queryString + "");

    http.onreadystatechange = formReply;
    http.send(null);
}

function formReply()
{
    if(http.readyState == 4 && http.status == 200)
    {
        var response = http.responseText;
        
        document.getElementById('login_form_update').innerHTML = response;
    }
}

function msgReply()
{
    if(http.readyState == 4 && http.status == 200)
    {
        var response = http.responseText;
        
        document.getElementById('msg').innerHTML = response;
    }
}

function refreshview(page)
{
    setTimeout('runajax("contentdiv",  "'+ page +'")', refreshrate);
}

function refreshMe(page)
{
    setTimeout('runajax("contentdiv",  "'+ page +'")', queryrate);
}

//Function to show a loading message.
function showload (objDiv){
	document.getElementById(objDiv).innerHTML = '<div class="center"><img src="http://customer.murfsystems.net/images/loading_aqua.gif" width="315" height="200"></div>';
}

function showdiv(id) {
	document.getElementById(id).style.display = 'block';
        
}

function hidediv(id) {
	document.getElementById(id).style.display = 'none';
}

