// JavaScript Document

//JQuery Code

$(function(){

    $('.error').hide();
    $('input.text').css({
        backgroundColor: "#FFFFFF"
    });
    $('input.text').focus(function(){
        $(this).css({
            backgroundColor: "#EEEEEE"
        });
    });
    $('input.text-input').blur(function(){
        $(this).css({
            backgroundColor: "#FFFFFF"
        });
    });
    
    $(".submit").click(function(){
        // validate and process form
        // first hide any error messages
        $('.error').hide();
        
        var first_name = $("input#first_name").val();
        if (first_name == "") {
            $("label#first_name_error").show();
            $("input#first_name").focus();
            return false;
        }
        var last_name = $("input#last_name").val();
        if (last_name == "") {
            $("label#last_name_error").show();
            $("input#last_name").focus();
            return false;
        }
        var email = $("input#email").val();
        if (email == "") {
            $("label#email_error").show();
            $("input#email").focus();
            return false;
        }
        var phone = $("input#phone").val();
        if (phone == "") {
            $("label#phone_error").show();
            $("input#phone").focus();
            return false;
        }
        
        var address = $("input#address").val();
        if (address == "") {
            $("label#address_error").show();
            $("input#address").focus();
            return false;
        }
        var citystatezip = $("input#citystatezip").val();
        if (citystatezip == "") {
            $("label#citystatezip_error").show();
            $("input#citystatezip").focus();
            return false;
        }
        var company = $("input#company").val();
        if (company == "") {
            $("label#company_error").show();
            $("input#company").focus();
            return false;
        }
        
		var comments = $("textarea#comments").val();
        var opt = $("input#webex_opt").attr("checked");
        
        var dataString = 'first_name=' + first_name + '&last_name=' + last_name + '&email=' + email + '&phone=' + phone + '&address=' + address + '&citystatezip=' + citystatezip + '&company=' + company + '&comments=' + comments + '&webex_opt=' + opt;
        //alert (dataString);return false;
        
        $.ajax({
            type: "POST",
            url: "_process.php",
            data: dataString,
            success: function(html){
                $('#signup').html("<div id='message'></div>");
                $('#message').html("<h2>Request Received!</h2>").append("<p>We will be in touch soon.</p>").hide().fadeIn(1500, function(){
                    $('#message').append("");
                });
            }
        });
        //return false;
    });
});






