$(document).ready(function(){
    var msg = '';

    $("input").keypress(function(e){
        var code = null;
        code = (e.keyCode ? e.keyCode : e.which);
        return (code == 13 ) ? false : true;
    });

    var val = {
        '4tonvsl9sdf': ['Email ID']
    };

    $.each(val,function(i,d)
    {
        $('#'+i).focus(function(){
            if($.trim($(this).val()) == d[0]){
                $(this).val('');
            }
        });

        $('#'+i).blur(function()
        {
            if($.trim($(this).val()) == '')
            {
                $(this).val(d[0]);
            }
        });
    })

    $("#34sdnl9834sdd").click(function(){



        //checking valid email address
        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
        var email =$.trim($("#4tonvsl9sdf").val());
        if(reg.test(email) == false) {

            msg = "Invalid Email Address"
            $("<div />", {
                className: 'topbar',
                text: msg
            }).hide().prependTo("body")

            .slideDown('fast').delay(1000).slideUp(function() {
                $(this).remove();
                $("#4tonvsl9sdf").val('Email ID');
            });
        }
        else{
            var qrystr = 'key=fjsdlkfjdskl&'+$('#frm_index').serialize();

            $.ajax({
                url :'../notify_action.php',
                type : 'POST',
                data : qrystr,
                success: function(rs){
                    if(rs==0){
                        $("<div />", {
                            className: 'topbar_wrning',
                            text: 'This Email ID already exist'
                        }).hide().prependTo("body")

                        .slideDown('fast').delay(1000).slideUp(function() {
                            $(this).remove();
                            $("#4tonvsl9sdf").val('Email ID');
                            $("#34sdnl9834sdd").attr('disabled',true);
                            setTimeout(function() {
                                $("#34sdnl9834sdd").removeAttr('disabled');
                            }, 3000);
                        });
                    }
                    else{
                    $("<div />", {
                        className: 'topbar',
                        text: rs
                    }).hide().prependTo("body")

                    .slideDown('fast').delay(1000).slideUp(function() {
                        $(this).remove();
                        $("#4tonvsl9sdf").val('Email ID');
                        $("#34sdnl9834sdd").attr('disabled',true);
                        setTimeout(function() {
                            $("#34sdnl9834sdd").removeAttr('disabled');
                        }, 3000);
                    });
                }
                }
            });
        }           
    })
});
