/**
 * Google GSA and search suggest config for Flight Centre New Zealand
 *
 * @author          Ryan Blunden
 * @modifiedby      $LastChangedBy$
 * @copyright       Copyright Flight Centre Ltd. All rights reserved.
 * @version         $Revision$
 * @lastmodified    $Date$
 * @requires        jQuery
 */

;FCNZ.GSA =
{
    client: 'FC_nz_frontend',
    site: 'FC_nz_all',

    /**
     * DocumenFCNZ.ion for the variables used in this file is available at
     * https://sites.google.com/a/flightcentre.com.au/web-services-wiki/development/google-search-appliance-gsa/sample-site-config-file
     */
    init: function()
    {
        this.ss_form_element = 'suggestion_form_gs';
        this.ss_popup_element = 'search_suggest';
        this.ss_seq = ['g'];
        this.ss_g_one_name_to_display = 'Suggestion';
        this.ss_g_more_names_to_display = 'Suggestions';
        this.ss_g_max_to_display = 10;
        this.ss_max_to_display = 12;
        this.ss_wait_millisec = 300;
        this.ss_delay_millisec = 30;
        this.ss_gsa_host = '{1}/search/suggest'.fclFormat(window.location.hostname);
        this.SS_OUTPUT_FORMAT_LEGACY = 'legacy';
        this.SS_OUTPUT_FORMAT_OPEN_SEARCH = 'os';
        this.SS_OUTPUT_FORMAT_RICH = 'rich';
        this.ss_protocol = this.SS_OUTPUT_FORMAT_RICH;
        this.ss_allow_non_query = true;
        this.ss_non_query_empty_title = 'No Title';
        this.ss_allow_debug = false;

        $(function()
        {
        	if ( /\/search(.*)/i.test(window.location) ) {
        		$('#search-box').remove();
        	} else {
        		//$('#search_suggest').bgIframe({ opacity:false, src: '' });
        	}
        	
            // Add the required fields to the search suggest form
            $('#suggestion_form_gs').append('<input type="hidden" name="client" value="'+ FCNZ.GSA.client +'" />')
                                    .append('<input type="hidden" name="site" value="'+ FCNZ.GSA.site +'" />');
            
          /*  $('#suggestion_form_gs').bind('submit', function(e)
            {
                e.preventDefault();
                window.location.href =
                    '{1}?q={2}'.fclFormat($(this).attr('action'), $(this).find('input[name="q"]').val());
            });*/
        });
    }
};

/**
 * On dom ready, call the FCNZ.GSA.init method, setting the context of 'this' inside of the method
 * to point to the window object so these variables will have required global scope. It's done this way
 * so if the scope changes at some point, the only code that needs to change is the context we
 * provide to FCNZ.GSA.init.
 */
FCNZ.GSA.init.call(window);
