﻿function CheckUsername(username) {
    if (username.toString().length > 0)
        CallServer(username, "");
    else
        ReceiveServerData("undefined");
}

function ReceiveServerData(rValue) {
    var exists = "Resources/Images/notav.gif";
    var notexists = "Resources/Images/av.gif";

    if (rValue == "false") {
        var oUser = $get("ctl00_pageContent_UserName");
        $get("usernameexists").style.display = '';
        $get("usernameexists").src = notexists;
        $get("usernameexists").title = "Congradulation! this user name is available";
        if (oUser != null) {
            if (oUser.value == "")
                $get("usernameexists").style.display = 'none';
        }
    }
    else if (rValue == "undefined") {
        $get("usernameexists").style.display = 'none';
    }
    else {
        $get("usernameexists").style.display = '';
        $get("usernameexists").src = exists;
        $get("usernameexists").title = "Sorry! this user name is not available";
    }
}