function checkMailAddress(address)
{
    if( address.length == 0)
        return true;

    var myEMailIsValid = true;
    var myAtSymbolAt = address.indexOf('@');
    var myLastAtSymbolAt = address.lastIndexOf('@');
    var myLastDotAt = address.lastIndexOf('.');
    var mySpaceAt = address.indexOf(' ');
    var mySemicolonAt = address.indexOf(';');
    var myCommaAt = address.indexOf(',');
    var myLength = address.length;

    // at least one @ must be present and not before position 2
    // @yellow.com : NOT valid
    // x@yellow.com : VALID
    if (myAtSymbolAt < 1 )
     {myEMailIsValid = false}


    // at least one . (dot) afer the @ is required
    // x@yellow : NOT valid
    // x.y@yellow : NOT valid
    // x@yellow.org : VALID
    if (myLastDotAt < myAtSymbolAt)
     {myEMailIsValid = false}

    // at least two characters [com, uk, fr, ...] must occur after the last . (dot)
    // x.y@yellow. : NOT valid
    // x.y@yellow.a : NOT valid
    // x.y@yellow.ca : VALID
    if (myLength - myLastDotAt <= 2)
     {myEMailIsValid = false}


    // no empty space " " is permitted (one may trim the email)
    // x.y@yell ow.com : NOT valid
    if (mySpaceAt != -1)
     {myEMailIsValid = false}

    // several mail addresses are not allowed
    // x.y@yellow.com,a@b.net : NOT valid
    if (myLastAtSymbolAt != myAtSymbolAt)
        {myEMailIsValid = false}

    // no comma "," is permitted
    // several mail addresses are not allowed  x.y@yellow.com,a@b.net : NOT valid
    if (myCommaAt != -1)
     {myEMailIsValid = false}

    // no semicolon "," is permitted
    // several mail addresses are not allowed  x.y@yellow.com;a@b.net : NOT valid
    if (mySemicolonAt != -1)
     {myEMailIsValid = false}

    return myEMailIsValid
}