/*
    Document   : contact
    Created on : 16/11/2010, 8:52:00
    Author     : CarlosGarcia
    Description: Javascript contact controller
    Purpose of the javascript follows.
*/

$(document).ready(function() {


    $("#bt_send_contact").click(function(e) {
       
        sendContactForm();
        
    });

    $('#bt_clear_contact').click(function(e) {
    
        clearForm();

    });


});//Close Document Ready

function sendContactForm()
{

    var name = $('#name').val();
    var email = $('#email').val();
    var message = $('#message').val();
    var phone = $('#phone').val();

    $.post("index.php?r=site/sendform", {
        name: name,
        email: email,
        phone: phone,
        message: message

    },

    function(data){
        //var url = "trace.php?t=" + data + "&KeepThis=true&TB_iframe=true&height=100&width=200";
        //tb_show(null, url , null);
        $('#output_contact').text("Your message has succesfully been sent!");
        clearForm();
    });
}

function clearForm()
{

    $('#name').val("");
    $('#email').val("");
    $('#phone').val("");
    $('#message').val("");

}
