            var swfu;

            window.onload = function() {
                var settings = {
                    flash_url : "inc/swfup/Flash/swfupload.swf",
                    upload_url: "upload.php",
                    wmode: 'transparent',
                    post_params: {"PHPSESSID" : ""},
                    file_size_limit : "10 MB",
                    file_types : "*.*",
                    file_types_description : "All Files",
                    file_upload_limit : 100,
                    file_queue_limit : 1,
                    custom_settings : {
                        progressTarget : "fsUploadProgress",
                        cancelButtonId : "btnCancel"
                    },
                    debug: false,

                    // Button settings
                    button_image_url: "inc/images/button.png",
                    button_width: "119",
                    button_height: "35",
                    button_placeholder_id: "spanButtonPlaceHolder",
                    /*button_text: '<span class="theFont">Upload</span>',
                    button_text_style: ".theFont { font-size: 16; }",*/
                    button_text_left_padding: 12,
                    button_text_top_padding: 3,

                    // The event handler functions are defined in handlers.js
                    file_queued_handler : fileQueued,
                    file_queue_error_handler : fileQueueError,
                    file_dialog_complete_handler : fileDialogComplete,
                    upload_start_handler : uploadStart,
                    upload_progress_handler : uploadProgress,
                    upload_error_handler : uploadError,
                    upload_success_handler : uploadSuccess,
                    upload_complete_handler : uploadComplete,
                    queue_complete_handler : queueComplete    // Queue plugin event
                };

                swfu = new SWFUpload(settings);
             };

jQuery( document ).ready( function( $ ){
    $('#name,#email,#details,#project_type,#budget').toggleVal();
} );

function send_ajaxform()
{
    show_modal();
    var name, email, budget, details, project_type, valid;
    valid = true;

    jQuery( function( $ ){

        name = $('#name').val();
        email = $('#email').val();
        budget = $('#budget').val();
        details = $('#details').val();
        project_type  = $('#project_type').val();

        if ( /^(?:[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)$/i.test( email ) )
            valid = true;
        else
            valid = false;

        if( ! name || ! email || ! details || ! budget )
            valid = false;

        if( name == 'Your Name' ) valid = false;
        if( email == 'Your E-mail' ) valid = false;
        if( budget == 'Budget' ) valid = false;
        if( details == 'Details' ) valid = false;

        if( valid )
        {
            jQuery.ajax({
                url: 'send.php',
                dataType: 'json',
                type:'post',
                data: $('form').serialize(),
                error: function( json ){ return true; },
                success: function( json ){
                    $('.files').html( json.msg );
                    hide_modal();
                }
            });
        }
        else
        {
            hide_modal();
            $('.files').html( '<p class="response response-error">Please fill out the required fields.</p>' );
            highlite_erroneous_fields();
        }
    });
}

function highlite_erroneous_fields()
{
    var name, email, budget, details, project_type, valid;

    name = $('#name').val();
    email = $('#email').val();
    budget = $('#budget').val();
    details = $('#details').val();
    project_type  = $('#project_type').val();

    if ( /^(?:[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)$/i.test( email ) )
        var x = true;
    else
        highlite_field( 'email' );

    if( ! name ) highlite_field( 'name' );
    if( ! email ) highlite_field( 'email' );
    if( ! details ) highlite_field( 'details' );
    if( ! budget ) highlite_field( 'budget' );

    if( name == 'Your Name' ) highlite_field( 'name' );
    if( email == 'Your E-mail' ) highlite_field( 'email' );
    if( details == 'Details' ) highlite_field( 'details' );
    if( budget == 'Budget' ) highlite_field( 'budget' );


}

function highlite_field( id ){
    jQuery('#' + id ).attr( 'class', 'red' );
}

function show_modal(){
    jQuery( function($){
       $('.modal').fadeTo( 'fast', .3 );
       $('.ajax-busy').fadeTo( 'fast', 1 );
    });
}

function hide_modal(){
    jQuery( function($){
       $('.modal').fadeTo( 'fast', 0, function(){ $('.modal').hide(); } );
       $('.ajax-busy').fadeTo( 'fast', 0, function(){ $('.ajax-busy').hide(); } );
    });
}
