$(function()  
{
        //  First Name
        $('#firstname_field').blur(function()
        {
            var firstname = $('#firstname_field').val();
            $.post("contactformajax.php", { action: 'checkfirstname', firstname: firstname },
            function(data)
            {
                $('#firstname_response').html(data);
            });              
        });
        
        //  Last Name
        $('#lastname_field').blur(function()
        {
            var lastname = $('#lastname_field').val();
            $.post("contactformajax.php", { action: 'checklastname', lastname: lastname },
            function(data)
            {
                $('#lastname_response').html(data);
            });              
        });
    
        //  Contact number
        $('#contactnumber_field').blur(function()
        {
            var contactnumber = $('#contactnumber_field').val();
            $.post("contactformajax.php", { action: 'checkcontactnumber', contactnumber: contactnumber },
            function(data)
            {
                $('#contactnumber_response').html(data);
            });              
        });
    
        //  Email 
        $('#email_field').blur(function()
        {
            var email = $('#email_field').val();
            $.post("contactformajax.php", { action: 'checkemail', email: email },
            function(data)
            {
                $('#email_response').html(data);
            });              
        });
        
        //  Address
        $('#address_field').blur(function()
        {
            var address = $('#address_field').val();
            $.post("contactformajax.php", { action: 'checkaddress', address: address },
            function(data)
            {
                $('#address_response').html(data);
            });              
        });
        
        //  City
        $('#city_field').blur(function()
        {
            var city = $('#city_field').val();
            $.post("contactformajax.php", { action: 'checkcity', city: city },
            function(data)
            {
                $('#city_response').html(data);
            });              
        });
        
        //  Postcoode
        $('#postcode_field').blur(function()
        {
            var postcode = $('#postcode_field').val();
            $.post("contactformajax.php", { action: 'checkpostcode', postcode: postcode },
            function(data)
            {
                $('#postcode_response').html(data);
            });              
        });
        
        
        
    
    
        //  Date picker
        $('.datepicker').datepicker({ dateFormat: 'dd/mm/yy' });
        
        $('#workdate').change(function()
        {
            var date = $('#workdate').val();
            $.post("contactformajax.php", { action: 'checkworkdate', date: date },
            function(data)
            {
                $('#date_response').html(data);
            });              
        });
        
        
        
        $('#repair_and_maintenance_fieldset').hide();
        $('#upgrade_fieldset').hide();
        $('#installation_fieldset').hide();
        
        $('#repair_checkbox').click(function() 
        {
            $('#repair_and_maintenance_fieldset').slideToggle('slow', function() 
            {

            });
        });
        
        $('#upgrade_checkbox').click(function() 
        {
            $('#upgrade_fieldset').slideToggle('slow', function() 
            {

            });
        });
        
        $('#installation_checkbox').click(function() 
        {
            $('#installation_fieldset').slideToggle('slow', function() 
            {

            });
        });
        
});
