﻿$(function() {
    // These first three lines of code compensate for Javascript being turned on and off. 
    // It simply changes the submit input field from a type of "submit" to a type of "button".

    var paraTag = $('input#submit').parent('p');
    $(paraTag).children('input').remove();
    $(paraTag).append('<input type="button" name="submit" id="submit" value="Send" />');

    $('#contact-form input#submit').click(function() {
        $('#contact-form').append('<class="loaderIcon" alt="Loading..." />');

        var name = $('input#name').val();
        var email = $('input#email').val();
		var tele = $('input#tele').val();
		var fromadd = $('textarea#fromadd').val();
		var fromcity = $('input#fromcity').val();
		var frompcode = $('input#frompcode').val();
		var fromcountry = $('input#fromcountry').val();
		var toadd = $('textarea#toadd').val();
		var tocity = $('input#tocity').val();
		var topcode = $('input#topcode').val();
		var tocountry = $('input#tocountry').val();
		var month = $('select#month').val();
		var year = $('input#year').val();
		var employer = $('select#employer').val();
		var rooms = $('input#rooms').val();
		var weight = $('input#weight').val();
		
        $.ajax({
            type: 'post',
            url: 'scripts/contact_form/sendEmail.php',
            data: 'name=' + name + '&email=' + email + '&tele=' + tele + '&fromadd=' + fromadd + '&fromcity=' + fromcity + '&frompcode=' + frompcode + '&fromcountry=' + fromcountry + '&toadd=' + toadd + '&tocity=' + tocity + '&topcode=' + topcode + '&tocountry=' + tocountry + '&month=' + month + '&year=' + year + '&employer=' + employer + '&rooms=' + rooms + '&weight=' + weight,

            success: function(results) {
                $('#contact-form img.loaderIcon').fadeOut(1000);
                $('ul#response').html(results);
            }
        }); // end ajax
    });
});
		
