var HINT = {
    'show': function( e, text ) {
            var e = e || window.event;

            var hintDiv = $('#hintToolTip');
            var hintFrame = $('#hintToolTipFrame');

            if ( !$(hintDiv).length ) {
                var hintDiv = $('<div id="hintToolTip">').prependTo( $('body', document) );

                if ( $.browser.msie && $.browser.version < 7 ) {
                    $('<iframe id="hintToolTipFrame" frameborder="0">')
                        .attr('src', 'javascript:"<html></html>"')
                        .insertAfter( hintDiv );
                }
            }

            $(hintDiv).css({
                'top':  $(e.target).offset().top - 0,
                'left': $(e.target).offset().left + 180
            })

            $(hintDiv).html(text).show();

            if ( $.browser.msie && $.browser.version < 7 ) {
                $('#hintToolTipFrame')
                    .css({  'top':      $(hintDiv).css('top'),
                            'left':     $(hintDiv).css('left'),
                            'width':    $(hintDiv).width() + 12,
                            'height':   $(hintDiv).height() + 6})
                    .show();
            }

            if ( this.timer ) {
                window.clearTimeout( this.timer );
            }

            this.timer = window.setTimeout( 'HINT.hide();', 15000);
        },
    'hide': function() {
            if ( this.timer ) {
                window.clearTimeout( this.timer );
            }

            $('#hintToolTip').hide().text('');

            if ( $.browser.msie && $.browser.version < 7 ) {
                $('#hintToolTipFrame').hide();
            }
        }
};

$(document).ready(function(){
    $('#email')
        .focus(function(e){  HINT.show(e, 'This e-mail address will be used for account verification.'); })
        .blur(function(e){   HINT.hide(); });
});

function validateRegLite( frm ) {

    var errorMsg = null;
    var focusObj = null;

    if ( frm.email.value == '' ) {
        errorMsg = translation[225];
        focusObj = frm.email;
    }
    else if ( !isValidEmail( frm.email.value ) ) {
        errorMsg = translation[29];
        focusObj = frm.email;
    }
    else if( frm.username.value == '' ) {
        errorMsg = translation[238];
        focusObj = frm.username;
    }
    else if ( frm.username.value.length < 6 ) {
        errorMsg = translation[44];
        focusObj = frm.username;
    }
    else if( frm.password1.value == '' ) {
        errorMsg = translation[42];
        focusObj = frm.password1;
    }
    else if ( frm.password1.value.length < 6 || frm.password1.value.length == frm.username.value ) {
        errorMsg = translation[42];
        focusObj = frm.password1;
    }
    else if( frm.password1.value != frm.password2.value ) {
        errorMsg = translation[43];
        focusObj = frm.password2;
    }
    else if( frm.countryID.value == '' ) {
        errorMsg = translation[45];
        focusObj = frm.countryID;
    }
    else if( frm.terms.checked == '' ) {
        errorMsg = translation[53];
        focusObj = frm.terms;
    }

    if ( errorMsg == null ) {
        return true;
    }

    alert( errorMsg );
    if ( focusObj )
        focusObj.focus();
    return false;
}
