var validates_ok    = '<img src="/be-side/image/80_contact/accept.png" width="16" height="16" style="vertical-align: middle"/>';
var validates_error = '<img src="/be-side/image/80_contact/stop.png" width="16" height="16" style="vertical-align: middle"/>';
var validates_info  = '<img src="/be-side/image/80_contact/info.png" width="16" height="16" style="vertical-align: middle"/>';
Validator.register({
    "#name" : {
        "/^$/": validates_info+'<span class="require">必須</span>',
        "/.*/": validates_ok
    },
    "#mail" : {
        "/^([^@\\s]+)@((?:[-a-z0-9]+\\.)+[a-z]{2,})$/": validates_ok,
        "/^$/": validates_info+'<span class="require">必須</span>',
        "/.*/": validates_error+"正しいメールアドレスを入力してください"
    },
    "#comment" : {
        "/^$/": validates_info+'<span class="notice">必須</span>',
        "/.*/": validates_ok
    },
    "#zip" : {
        "/^$/": validates_info+'<span class="infomation">半角数字とハイフンで入力してください。</span>',
        "/^[0-9]{3}-[0-9]{4}$/": validates_ok,
        "/.*/": validates_error+'<span class="notice">半角数字とハイフンで入力してください。</span>'
    }
});

var Check = Class.create();
Check.prototype = {
    initialize: function() {
        this.c_tel  = $('c_tel');
        this.c_mail = $('c_mail');
        this.c_or   = $('c_or');

        this.tel     = $('tel');
        this.contact = $('contact');

        Event.observe(this.tel, 'change', this.televent.bindAsEventListener(this), true);
        Event.observe(this.c_tel, 'click', this.checktel.bindAsEventListener(this), true);
        Event.observe(this.c_mail, 'click', this.checktel.bindAsEventListener(this), true);
        Event.observe(this.c_or, 'click', this.checktel.bindAsEventListener(this), true);
    },
    televent: function(event) {

        if ( this.c_tel.checked ) {
            if ( this.tel.value.match(/\d{2,4}-\d{2,4}-\d{2,4}/) ) {
                $('tel_msg').innerHTML = validates_ok;
            } else {
                $('tel_msg').innerHTML = validates_info+'<span class="infomation">半角数字とハイフンで入力してください。</span>';
            }
        }
    },
    checktel: function (event) {
        if ( this.c_tel.checked ) {
            this.televent(event);
            this.tel.bgcolor = '#FF0000';
        } else {
            $('tel_msg').innerHTML = '';
        }
    }
}



