﻿function emailCheckOk( result, eventArgs )
{
    if( !result )
    {
        $get( "emailWarning" ).style.visibility = "visible";
    }
    else
    {
        $get( "emailWarning" ).style.visibility = "hidden";
    }
}

function checkPassword()
{
    var p = $get( password ).value.trim();
    
    if( p.length > 0 && p.length < 5 )
    {
        $get( "passwordWarning" ).style.visibility = "visible";
        return false;
    }
    else
    {
        $get( "passwordWarning" ).style.visibility = "hidden";
        return true;
    }
}

function checkPasswordMatch( e )
{
    var p = $get( password ).value.trim();
    var p1 = $get( password1 ).value.trim();
    
    if( p.length > 0 && p1.length > 0 && p != p1 )
    {
        $get( "passwordWarning1" ).style.visibility = "visible";
        return false;
    }
    else
    {
        $get( "passwordWarning1" ).style.visibility = "hidden";
        return true;
    }
}

function validateRest()
{
    var text = "";

    if( $get( email ).value.trim().length == 0 )
    {
        text += emailEmpty;
    }

    if( $get( "emailWarning" ).style.visibility == "visible" )
    {
        text += emailExists;
    }
    
    var p = $get( password ).value.trim();
    var p1 = $get( password1 ).value.trim();
    
    if( p.length < 5 )
    {
        $get( "passwordWarning" ).style.visibility = "visible"; 
        text += passswordShort;
    }

    if( p != p1 )
    {
        $get( "passwordWarning1" ).style.visibility = "visible";
        text += passwordsNotMatch;
    }

    return text;
}
