/**
* homeventilation.co.uk
*/
$(document).ready(function()
{

    if($('#latest_posts').length > 0)
    {
        $('#latest_posts').html('Loading Articles Please Wait...');

        $.ajax({
            type: "GET",
            dataType: "html",
            url: 'http://www.homeventilation.co.uk/posts-proxy.php?cat=home&format=li',
            success: function(response)
            {
                if(response)
                {
                    $('#latest_posts').html(response);
                }
                else
                {
                    $('#latest_posts_section').hide();
                }
            }
        });
    }

    if($('#postcode_search_form').length > 0)
    {
        /**
        * Setup the postcode search form
        */
        $('#postcode_search_form').submit(function(event)
        {
            event.preventDefault();

            // setup the options
            var options = new Array();

            // set the URL for the proxy and handler
            options['proxy_url'] = 'http://www.homeventilation.co.uk/form-proxy.php';
            options['url'] = 'http://www.envirovent.com/postcode-handler.php';

            // add the unique IDs
            options['site_id'] = 1;
            options['form_id'] = 'postcode_search_form';
            options['error_id'] = 'postcode_search_errors';

            if($('#postcode').val() != '')
            {
                // call the contact form submit handler with the options
                ajax_postcode(options);
            }
        });
    }

    if($('#contact_form').length > 0)
    {
        /**
        * Setup the contact form
        */
        $('#contact_form').submit(function(event)
        {
            event.preventDefault();

            // setup the options
            var options = new Array();

            // set the URL for the proxy and handler
            options['proxy_url'] = 'http://www.homeventilation.co.uk/form-proxy.php';
            options['url'] = 'http://www.envirovent.com/form-handler.php';

            // add the unique IDs
            options['form_id'] = 'contact_form';
            options['error_id'] = 'contact_form_errors';
            options['success_id'] = 'contact_form_success';

            // call the contact form submit handler with the options
            ajax_form(options);
        });
    }


    if($('#survey_form').length > 0)
    {
        /**
        * Setup the survey form
        */
        $('#survey_form').submit(function(event)
        {
            event.preventDefault();

            // setup the options
            var options = new Array();

            // set the URL for the proxy and handler
            options['proxy_url'] = 'http://www.homeventilation.co.uk/form-proxy.php';
            options['url'] = 'http://www.envirovent.com/form-handler.php';

            // add the unique IDs
            options['form_id'] = 'survey_form';
            options['error_id'] = 'survey_form_errors';
            options['success_id'] = 'survey_form_success';

            // call the contact form submit handler with the options
            ajax_form(options);
        });
    }

    if($('#quick_quote_form').length > 0)
    {
        /**
        * Setup the quick quote form
        */
        $('#quick_quote_form').submit(function(event)
        {
            event.preventDefault();

            // setup the options
            var options = new Array();

            // set the URL for the proxy and handler
            options['proxy_url'] = 'http://www.homeventilation.co.uk/form-proxy.php';
            options['url'] = 'http://www.envirovent.com/form-handler.php';

            // add the unique IDs
            options['form_id'] = 'quick_quote_form';
            options['error_id'] = 'quick_quote_form_errors';
            options['success_id'] = 'quick_quote_form_success';

            // call the contact form submit handler with the options
            ajax_form(options);
        });
    }

    if($('#quote_form').length > 0)
    {
        /**
        * Setup the quick quote form
        */
        $('#quote_form').submit(function(event)
        {
            event.preventDefault();

            // setup the options
            var options = new Array();

            // set the URL for the proxy and handler
            options['proxy_url'] = 'http://www.homeventilation.co.uk/form-proxy.php';
            options['url'] = 'http://www.envirovent.com/form-handler.php';

            // add the unique IDs
            options['form_id'] = 'quote_form';
            options['error_id'] = 'quote_form_errors';
            options['success_id'] = 'quote_form_success';

            // call the contact form submit handler with the options
            ajax_form(options);
        });
    }

    if($('#brochure_form').length > 0)
    {
        /**
        * Setup the brochure form
        */
        $('#brochure_form').submit(function(event)
        {
            event.preventDefault();

            // setup the options
            var options = new Array();

            // set the URL for the proxy and handler
            options['proxy_url'] = 'http://www.homeventilation.co.uk/form-proxy.php';
            options['url'] = 'http://www.envirovent.com/form-handler.php';

            // add the unique IDs
            options['form_id'] = 'brochure_form';
            options['error_id'] = 'brochure_form_errors';
            options['success_id'] = 'brochure_form_success';

            // call the contact form submit handler with the options
            ajax_form(options);
        });
    }
	
    if($('#referafriend_form').length > 0)
    {
        /**
        * Setup the brochure form
        */
        $('#referafriend_form').submit(function(event)
        {
            event.preventDefault();

            // setup the options
            var options = new Array();

            // set the URL for the proxy and handler
            options['proxy_url'] = 'http://www.homeventilation.co.uk/form-proxy.php';
            options['url'] = 'http://www.envirovent.com/form-handler.php';

            // add the unique IDs
            options['form_id'] = 'referafriend_form';
            options['error_id'] = 'referafriend_form_errors';
            options['success_id'] = 'referafriend_form_success';

            // call the contact form submit handler with the options
            ajax_form(options);
        });
    }	
});

