$(document).ready(function() {
        
    var symbols_check = /[^0-9a-zA-Z]/g;
    var mail_symbols_check = /[^-.@_0-9a-zA-Z]/g;
    var mail_check = /.+@.+\..+/;

    $('#downloads_submit').click(function() {

	if ($("#email").val() == "") {
	    msg('email_msg', 'Please input your E-mail!!', 0);
	    $("#email").focus();
	    return false;
	} else if (!$("#email").val().match(mail_check)) {
	    msg('email_msg', 'Please check your E-mail!!', 0);
	    $("#email").focus();
	    return false;
	} else if ($("#email").val().match(mail_symbols_check)) {
	    msg('email_msg', "Please don't input symbols!!", 0);
	    $("#email").focus();
	    return false;
	} else {
	    $("#email_msg").html("");
	}

	$('#downloads_form').submit();
	//return true;
    
    })

    $('#authentication_form').submit(function() {
	if ($("#uid").val() == "") {
	    msg('error_msg', 'Please input your E-mail!!', 1);
	    $("#uid").focus();
	    return false;
	} else if (!$("#uid").val().match(mail_check)) {
	    msg('error_msg', 'Please check your E-mail!!', 1);
	    $("#uid").focus();
	    return false;
	} else if ($("#uid").val().match(mail_symbols_check)) {
	    msg('error_msg', "Please don't input symbols!!", 1);
	    $("#uid").focus();
	    return false;
	} else {
	    $("#error_msg").html("");
	}


	if ($("#upwd").val( )== "") {
	    msg('error_msg', 'Please input password!!', 1);
	    $("#upwd").focus();
	    return false;
	} else if ($("#upwd").val().match(symbols_check)) {
	    msg('error_msg', "Please don't input symbols!!", 1);
	    $("#upwd").focus();
	    return false;
	} else if ($("#upwd").val().length < 5) {
	    msg('error_msg', 'Please input 5-12 characters!!', 1);
	    $("#upwd").focus();
	    return false;
	}  else {
	    $("#error_msg").html("");
	}

	if ($("#redeem").val().length != 40) {
	    msg('error_msg', 'Redeem code error!!', 1);
	    $("#redeem").focus();
	    return false;
	} else {
	    $("#error_msg").html("");
	}

	$('#authentication_form').submit();
	return true;

    })

    function msg(Element_id, str, push)
    {
	if (push == 1) {
	    str_html = '<div class="box120">&nbsp</div>' + str + '<div class="clearH15"></div>';
	} else {
	    str_html = str;
	}
	$("#" + Element_id).html(str_html);
	fade(Element_id);
    }

    function fade(Element_id)
    {
	$("#" + Element_id).fadeTo("slow", 0.3, function() {
	    $("#" + Element_id).fadeTo("slow", 1.0);
	})
    }

})
