function applyContactFormEvents()
{
    var resetButton = document.getElementById('resetButton');
    var submitButton = document.getElementById('submitButton');
    
    resetButton.onmouseup = function(){
        document.contactForm.reset();
    };
    resetButton.onclick = function(){ return false; }
    submitButton.onmouseup = function(){
        if (validateForm()){
            document.contactForm.method = 'POST';
            document.contactForm.submit();
        }
    };
    submitButton.onclick = function(){ return false; }
};

function validateForm()
{
    var errors = new Array();
    var fullName = document.getElementById('fullName').value;
    var message  = document.getElementById('message').value;
    var email    = document.getElementById('email').value;
    
    //full name
    if (fullName.length==0) errors.push('Full Name Required.');
    //email
    if (email.length==0){
        errors.push('Email Address Required.');
    }else{
        if (email.indexOf('@')==-1 || email.indexOf('.')==-1)
            errors.push('Valid Email Address Required.');
    }
    //message
    if (message.length==0) errors.push('Message Required.');
    

    if (errors.length>0) alert( errors.join('\n') );
    return (errors.length==0) ? true : false;
};

function start_contactForm(){
    applyContactFormEvents();
};

initRouter_add(start_contactForm);

