SF.ENQUIRY = {


    tracking:
    {
        timestamp: function() { d = new Date(); return d.getTime() }(),
        validation: false
    },

    TYPE:
    {
        name: 'general-enquiry'
    },

    FIELDNAMES :
    {
        departureLocation: 'Depature location',
        travelDestination: 'Travel Destination',
        departureDate: 'Departure date',
        returnDate: 'Return date',
        fullName: 'Full name',
        email: 'Email Address',
        postCode: 'Postcode',
        phone: 'Phone Number'
    },

    // this parameter was added to enable submit plugins to invalidate a form, preventing the enquiry submission.
    formValidated: false,

    plugins: [],

    init: function ()
    {
        var objThis = this;

        $(document).ready(function() {
            SF.ENQUIRY.$form = $('#productEnquiry');
            SF.ENQUIRY.$wrapper = $('#productEnquireForm');
            SF.ENQUIRY.setupForm();
            SF.ENQUIRY.setupValidation();
        });

        FCL.SIGNALS.send('SF.ENQUIRY', 'init');

    },

    addMarketingSuccess: function()
    {
        //* YAHOO MARKETING
        var priceDigits = '0.00';
        var timestamp = function() { d = new Date(); return d.getTime(); }();

		if (typeof(window.ysm_customData) != 'object') window.ysm_customData = new Object();
		window.ysm_customData.conversion = SF.format('transId=GEN{1},currency=AUD,amount={2}',timestamp,priceDigits);

		ysm_accountid  = '195CHAMUE2CDPPQHITP9CE0ID2G'

        var yahooScript = document.createElement('script');
        yahooScript.type = 'text/javascript';
        yahooScript.src = '//srv2.wa.marketingsolutions.yahoo.com/script/ScriptServlet?aid='+ysm_accountid;
        $('body').append(yahooScript);

        //* CALL GOOGLE ANALYTICS AJAX TRACKPAGE EVENT
        SF.registerGAPageView({path:this.TYPE.name});

        //* DGM TRACKING
        var dgm1 = '<img height="1" width="3" src="http://www.s2d6.com/x/?x=a&amp;h=16628&amp;o={1}" alt="" class="hide" />';
        var dgm2 = '<img height="1" width="3" src="http://www.s2d6.com/x/?x=r&amp;h=16628&amp;o={1}&amp;g=357679833273&amp;s={2}&amp;q=1" class="hide" />';

        //* AD.DOUBLECLICK
        var doubleClick = '<img height="1" width="3" src="https://ad.doubleclick.net/activity;src=986775;type=fligh123;cat=sfsal002;qty=1;cost=0.00;ord={1}?" alt="" class="hide" />';

        //* GOOGLE AD CONVERSION
        var google_conversion_id = 1035570271;
        var google_conversion_language = 'en_US';
        var google_conversion_format = '1';
        var google_conversion_color = 'ffffff';
        var google_conversion_label = '2M0gCKnxnAEQ35jm7QM';
        var googleAdImage = '<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1035570271/?label=2M0gCKnxnAEQ35jm7QM&amp;guid=ON&amp;script=0"/>' +
                            '<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1005941684/?label=qKD5CKTS9gEQtOfV3wM&amp;guid=ON&amp;script=0"/>' +
                            '<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/998531215/?label=wfwVCPGYiQIQj8GR3AM&amp;guid=ON&amp;script=0"/>' +
                            '<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1002905825/?label=rFqCCIfSlgIQ4cGc3gM&amp;guid=ON&amp;script=0"/>' +
                            '<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/999516777/?label=8TWjCO_w7wEQ6dTN3AM&amp;guid=ON&amp;script=0"/>' +
                            '<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/997474498/?label=aH6ICM6A9gEQwoHR2wM&amp;guid=ON&amp;script=0"/>' +
                            '<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/997672965/?label=V6wtCLu9_AEQhZDd2wM&amp;guid=ON&amp;script=0"/>' +
                            '<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1045875622/?label=lgLqCJKp-AEQppfb8gM&amp;guid=ON&amp;script=0"/>' +
                            '<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1040398195/?label=07u4CIXFuwEQ8-6M8AM&amp;guid=ON&amp;script=0"/>' +
                            '<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1018237290/?label=htnQCO6g0wEQ6qLE5QM&amp;guid=ON&amp;script=0"/>' +
                            '<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1018237290/?label=EsCUCP6e0wEQ6qLE5QM&amp;guid=ON&amp;script=0"/>' +
                            '<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1018237290/?label=7egCCPaf0wEQ6qLE5QM&amp;guid=ON&amp;script=0"/>';

        $('body').prepend(SF.format(dgm1, timestamp))
                 .prepend(SF.format(dgm2, timestamp, priceDigits))
                 .prepend(SF.format(doubleClick,timestamp))
                 .append(googleAdImage);

    },

    getDestination: function()
    {
		var strDes = '';
		var $strDestination = $('meta[name="product.destination"]');
		if ($strDestination.length > 0)
		{
			strDes = $strDestination.attr('content');
		}
		if (strDes == '')
		{
	        var strDesPath = window.location.pathname;
			strDesPath = strDesPath.split('/').pop();

			if (strDesPath.indexOf('+') >-1)
			{
				strDes = strDesPath.split('-')[0].replace('+','-').toLowerCase();
			}
			else
			{
				strDes = strDesPath.split('-')[0].toLowerCase();
			}
		}
		return strDes;
    },

    getSku: function()
    {
        var strSku = window.location.pathname;

        if (strSku.indexOf('.html') >-1)
        {
            return SF.getUrlVars('', 'sku')
        }
        try
        {
            strSku = strSku.match(/\d{1,7}/)[0];
        }
        catch(e)
        {
            strSku = $('#prodSku').val() != '' ? $('#prodSku').val() : '';
        }

        return strSku;
    },

    setupForm: function()
    {
        SF.ENQUIRY.$form.find('.ef-submit').attr('disabled', false);
        var packageName = SF.getUrlVars('','packageName'), packagePrice = SF.getUrlVars('','packagePrice'), pageUrl = SF.getUrlVars('','pageUrl'), packageSku = SF.getUrlVars('','sku')
        var $departureDate = $('#departureDate');
        var $returnDate = $('#returnDate');


        $departureDate.val('dd/mm/yyyy');
        $returnDate.val('dd/mm/yyyy');

        SF.ENQUIRY.$form.find('input[name="pageUrl"]').val(pageUrl);
        SF.ENQUIRY.$wrapper.find('span.productName').text(packageName);
        SF.ENQUIRY.$wrapper.find('span.price').text(packagePrice);
        SF.ENQUIRY.$form.find('#prodSku').val(packageSku);
        SF.ENQUIRY.$form.find('#prodPrice').val(packagePrice);

        // We load datepickers on document.ready as they barf in IE otherwise
        $(document).ready(function()
        {
            if(typeof(FAREINFO) === 'undefined') {
                // Date pickers (force return date to be after departure date)
				$departureDate.datepicker(
					$.extend(SF.SETTINGS.datePicker,
					{
						"minDate": 1,
						"showOn": 'button'
					})
				);

				$returnDate.datepicker(
					$.extend(SF.SETTINGS.datePicker,
					{
						"minDate": 2,
						"showOn": 'button'
					})
				);
            }
        });

        // Execute Plugins that should run on dom ready
        this.executePlugins('init');
    },


    setupValidation: function()
    {
        _this = this;
        var objType = this.TYPE.name;

        jQuery.validator.addMethod('defaultVal', function(value, element, params) {
            var strValidDate = $('#'+element.id).val();

            if (strValidDate == 'dd/mm/yyyy') {
                return false;
            } else {
                return true;
            };
        }, jQuery.format('We need a valid date'));

        SF.ENQUIRY.$form.validate({
            onfocusout: false,
            onkeyup: false,
            onclick: false,
            highlight: function(element, errorClass)
            {
                 $(element).css('background-color', 'LemonChiffon')
            },

            invalidHandler: function(form, validator)
            {
                var strError ='';
                var errorMessage = '';
                var intErrors = validator.numberOfInvalids();

                for (var formError in validator.errorMap)
                {
                    strError += SF.ENQUIRY.FIELDNAMES[formError] + ': ' + validator.errorMap[formError] + '\n'
                    SF.googleTrackPageEvent('enquiry', 'validationError', SF.ENQUIRY.FIELDNAMES[formError] + ': ' + validator.errorMap[formError]);
                };

                if (strError != '')
                {
                    alert(strError);

                };

            },

            rules:
            {

                travelDestination:
                {
                    required: true
                },

                departureLocation:
                {
                    required: true
                },

                departureDate:
                {
                    required: true,
                    defaultVal: true
                },

                returnDate:
                {
                    required: true,
                    defaultVal: true,
                    departureArrivalDates: true
                },

                fullName:
                {
                    required: true
                },

                phone:
                {
                    required: true
                },

                postCode:
                {
                    required: true,
                    minlength: 4,
                    maxlength: 4,
                    digits: true
                },

                email:
                {
                    required: true,
                    email: true
                }

            },

            messages:
            {
                email:
                {
                    email: 'Please enter a valid email address, example: you@yourdomain.com'
                }
            },

            submitHandler: function(form)
            {

                // Stops tracking if NOT fareinfo form
                var path = window.location.pathname;
                if(path.indexOf('flight-booking') == -1)
                {
                    SF.TRACKING.trackEvent = {
                     'action': 'enquiry',
                     'type': 'email'
                    };

                    SF.TRACKING.eventTracking();
                }

                SF.ENQUIRY.$form.find('.ef-submit').attr('disabled', 'disabled');

                // Execute Plugins that should run before form is submitted
                _this.executePlugins('submit');
                FCL.SIGNALS.send('SF.ENQUIRY', 'submit');

                var extraFields = ['airfares', 'tours', 'cars', 'railPasses', 'hotels', 'insurance','rail', 'owh'];
                var queryStringAppend = '&';

                for(var i=0; i<extraFields.length; i++)
                {
                    if(SF.ENQUIRY.$form.find('input[name="'+ extraFields[i] +'"]').length == 0)
                    {
                        queryStringAppend += extraFields[i] +'=&';
                        continue;
                    }

                    if(SF.ENQUIRY.$form.find('input[name="'+ extraFields[i] +'"]:checked').length == 0 &&
                        SF.ENQUIRY.$form.find('input[name="'+ extraFields[i] +'"]').attr('type') != 'text')
                    {
                        queryStringAppend += extraFields[i] +'=&';
                    }
                }

                var strSubject = '';
                strSubject = 'General Enquiry: ' + SF.ENQUIRY.$form.find('#fullName').val() + ' ' + SF.ENQUIRY.$form.find('#email').val();

                var strTemplate = SF.ENQUIRY.$form.find('input[name="template"]').val();
				var pCode = SF.ENQUIRY.$form.find('input[name="postCode"]').val();


                $('#ajaxLoad').show();


                //* Append the full name and email to Subject field before getting all the fields to post
                //* Add the appropriate Subject based on type of enquiry

                if (strTemplate == 'ausf/product-enquiry.html')
                {
                    strSubject = 'Product Enquiry: ' + SF.ENQUIRY.$form.find('#fullName').val() + ' ' + SF.ENQUIRY.$form.find('#email').val();

					/*
					*	Ensure closer templates are applied
					*/
					SF.ENQUIRY.$form.find('input[name="template"]').val('ausf/ct-product-enquiry.html');
                }

                if (strTemplate == 'ausf/fareInfoEnquiry.html')
                {
					strSubject = 'International Flights enquiry: ' + SF.ENQUIRY.$form.find('#fullName').val() + ' ' + SF.ENQUIRY.$form.find('#email').val();

					/*
					*	Ensure closer templates are applied
					*/

					SF.ENQUIRY.$form.find('input[name="template"]').val('ausf/ct-fareInfoEnquiry.html');

        		}

				if(strTemplate == 'ausf/general-enquiry.html' || strTemplate =='ausf/ct-general-enquiry.html')
				{
					/*
					*	Ensure closer templates are applied
					*/

					SF.ENQUIRY.$form.find('input[name="template"]').val('ausf/ct-general-enquiry.html');
				}

                //*  Conditionals to check if it a modal product inquiry or page product enquiry
                var checkPageUrl = SF.ENQUIRY.$form.find('input[name="pageUrl"]').val();

                if (checkPageUrl == '')
                {
                    SF.ENQUIRY.$form.find('input[name="pageUrl"]').val(SF.GENERALVARS.url);
                };

                SF.ENQUIRY.$form.find('input[name="Subject"]').val(strSubject);



                if(SF.TM.isWithinThreeClicks() || SF.getQueryVariable('tourismMediaTracking') == 'true')
                {
                    var timestamp = function() { d = new Date(); return d.getTime(); }();
                    if(SF.ENQUIRY.$form.find('input[name="tourismMediaEnquiry"]').length == 0)
                    {
                        SF.ENQUIRY.$form.append('<input type="hidden" name="tourismMediaEnquiry" value="" />');
                    }
                    SF.ENQUIRY.$form.find('input[name="tourismMediaEnquiry"]').val('Yes: '+timestamp);

                    SF.TM.googleAnalyticsReporting(timestamp);
                }

		        // Get proccessed string from form values
                var gimpUrl = SF.GIMP.processForm(SF.ENQUIRY.$form) + queryStringAppend;

                $.get(gimpUrl, function(data){

                    result = data.indexOf('successful');

                    if (typeof SF.PRODUCTENQ != 'undefined')
                    {
                        SF.PRODUCTENQ.addMarketingSuccess();

                    };

                    if (typeof SF.ENQUIRY != 'undefined' && typeof SF.PRODUCTENQ == 'undefined' && typeof SF.FAREINFOENQ == 'undefined')
                    {
                        SF.ENQUIRY.addMarketingSuccess();

                    };

                    if (typeof SF.FAREINFOENQ != 'undefined')
                    {
                        SF.FAREINFOENQ.addMarketingSuccess();

                    };

                    if (result > -1)
                    {
                        setTimeout(function(){
                            $('#ajaxLoad').hide();
                            var theWrapperHeight = SF.ENQUIRY.$wrapper.height();
                            SF.ENQUIRY.$wrapper.height(theWrapperHeight)
                            SF.ENQUIRY.$wrapper.find('.note').fadeOut(1000)
                            SF.ENQUIRY.$form.fadeOut(1000,function(){
                                SF.ENQUIRY.$wrapper.animate({height: 76},1500,function(){
                                    SF.ENQUIRY.$form.before('<div id="successful" style="display:none"><strong>'+SF.SETTINGS.LANG.enquirySuccess+'</strong></div>');
                                    $('#successful').fadeIn('slow')
                                });
                            })
                        }, 2000);

                    }
                    else
                    {
                        setTimeout(function(){
                            $('#ajaxLoad').hide();
                            var theWrapperHeight = SF.ENQUIRY.$wrapper.height();
                            SF.ENQUIRY.$wrapper.height(theWrapperHeight)
                            SF.ENQUIRY.$wrapper.find('.note').fadeOut(1000)
                            SF.ENQUIRY.$form.fadeOut(1000,function(){
                                SF.ENQUIRY.$wrapper.animate({height: 76},1500,function(){
                                    SF.ENQUIRY.$form.before('<div id="fail" style="display:none"><strong>Sorry, we are unable to send your enquiry at this time. Please try again later</strong></div>');
                                    $('#fail').fadeIn('slow')
                                });
                            })
                        }, 2000)
                    }
                }, "html");

                return false
            }

       });
    },

    /**
     * Simple little function which adds a plugin to the plugins variable. This provides a simple way
     * for plugins to be registered that do things to the page and/or enquiry form when a certain
     * condition is met
     */
    registerPlugin: function(obj)
    {
        this.plugins.push(obj);
    },

    /**
     * Now that DOM is ready, run all the plugins so they can modify what they need to
     * the result of each plugin is
     */
    executePlugins: function(event)
    {
        var _this = this;
        $(function()
        {
            for(var i=0; i<_this.plugins.length; i++)
            {
                try
                {
                   var result = _this.plugins[i][event].call(_this);
                }
                catch(e){};
            }
        });
    }

};

//plugin to register any user that selects yes to the specials radio box
//if the user is already registered then we do nothing.
SF.ENQUIRY.registerPlugin(
{
    init: function()
    {},

    submit: function()
    {
        var _this = this;
        this.$form.find('input[name=specials]').each(function()
        {


            if($(this).val() == 'yes' && $(this).attr('checked'))
            {
                var email = _this.$form.find('input[name=email]').val();
                var fullName = _this.$form.find('input[name=fullName]').val();
                var phone = _this.$form.find('input[name=phone]').val();
                var postCode = _this.$form.find('input[name=postCode]').val();
                var source= '10011'; //'enquiry' -> see doc for more source id's
                var key = 'blmo6f3110f28769370bcd5564fc1254';

                $.ajax({
                    url: '/fcl/js/fcl/fcl.xcomm.js?v=2',
                    dataType: 'script',
                    async:false,
                    success:function(data){
                        FCL.UTIL.xcommSubscribe(email,fullName,phone,postCode,source,key);
                    }
                });
            }
        });
    }
});

/**
 * Fareinfo plugin.
 */

SF.ENQUIRY.registerPlugin(
{
    init: function()
    {
        var path = window.location.pathname;
        if(path.indexOf('flight-booking') == -1)
        {
            return;
        }
        var $form = SF.ENQUIRY.$form;
        $(document).ready(function(){
			$form.field('todaysDate', FCL.DATETIME.todaysDate());
			$form.field('pageUrl', window.location.protocol + '//' + window.location.hostname + window.location.pathname + window.location.search);
            FCL.FORMS.replaceSubmitButton($form.find('.submitButton'),'/images/ajax-loader.gif');
            if (FCL.UTIL.getUrlVar('depDate') != '') {
                $form.find('input[name="departureDate"]').val(FCL.UTIL.getUrlVar('depDate'));
            }
            if (FCL.UTIL.getUrlVar('retDate') != '') {
                $form.find('input[name="returnDate"]').val(FCL.UTIL.getUrlVar('retDate'));
            }
        });
    },

    submit: function()
    {

        var path = window.location.pathname;
        if(path.indexOf('flight-booking') == -1)
        {
            return;
        }

        SF.TRACKING.trackEvent = {
         'action': 'enquiry',
         'type': 'fareinfo'
        };

        SF.TRACKING.eventTracking();

        /*
         *  Before submit we need to populate the enquiry form with the values from the users selection
         */
        var $form = SF.ENQUIRY.$form;
        $form.trigger('replaceSubmit');

        var fare = FAREINFO.selectedFlight,
			itinerarySeperator = '.\n  ',
			itinerary = '',
			_departureCityCode = '',
			_departureCityName = '',
			_departureCityCountryName = '',
			_departureString = '',
			_todaysDate = FCL.DATETIME.todaysDate(),
			_arrivalCityCode = '',
			_arrivalCityName = '',
			_arrivalCityCountryName = '',
			_arrivalString = '',
			_cabinClass = '',
			_fareType = '',
			_routeType = '',
			_enquiryType = '',
			_airlineName = '',
			_airlineCode = '',
			_price = 'N/A',
			_base = '',
			_tax = '',
			_
			_specialID = 'No Fare',
            _subscribedNewsletter = 'no';


		if(typeof(FAREINFO.modelJson)!=='undefined' && FAREINFO.modelJson!==null) {
			_departureCityCode = (typeof(FAREINFO.modelJson.responseJson.journey.departureCity.code)!='undefined') ? FAREINFO.modelJson.responseJson.journey.departureCity.code : 'no-results';
			_departureCityName = (typeof(FAREINFO.modelJson.responseJson.journey.departureCity.name)!='undefined') ? FAREINFO.modelJson.responseJson.journey.departureCity.name : 'no-results';
			_departureCityCountryName = (typeof(FAREINFO.modelJson.responseJson.journey.departureCity.country.name)!='undefined') ? FAREINFO.modelJson.responseJson.journey.departureCity.country.name : 'no-results' ;
			_departureString = _departureCityName +' ('+_departureCityCountryName+')';

			_arrivalCityCode = (typeof(FAREINFO.modelJson.responseJson.journey.arrivalCity.code)!='undefined') ? FAREINFO.modelJson.responseJson.journey.arrivalCity.code : 'no-results';
			_arrivalCityName = (typeof(FAREINFO.modelJson.responseJson.journey.arrivalCity.name)!='undefined') ? FAREINFO.modelJson.responseJson.journey.arrivalCity.name : 'no-results';
			_arrivalCityCountryName = (typeof(FAREINFO.modelJson.responseJson.journey.arrivalCity.country.name)!='undefined') ? FAREINFO.modelJson.responseJson.journey.arrivalCity.country.name : 'no-results';
			_arrivalString = _arrivalCityName +' ('+_arrivalCityCountryName+')';

			_cabinClass = (typeof(FAREINFO.modelJson.cabinClass)!='undefined') ? FAREINFO.modelJson.cabinClass : 'no-results';
			_fareType = (typeof(FAREINFO.modelJson.fareType)!='undefined') ? FAREINFO.modelJson.fareType : 'no-results';
			_routeType = (typeof(FAREINFO.modelJson.routeType)!='undefined') ? FAREINFO.modelJson.routeType : 'no-results';
			_enquiryType = (typeof(FAREINFO.modelJson.responseJson)!=='undefined') ?  (FAREINFO.modelJson.responseJson.journey.departureCity.code + '-' + FAREINFO.modelJson.responseJson.journey.arrivalCity.code)  : 'no-results' ;

			if(typeof(fare)!='undefined') {
		    // build Itinerary string
				$.each(fare.legs, function(i, leg)
				{
					itinerary += leg.departureAirport.code + '-'
							  + leg.arrivalAirport.code + '-'
							  + leg.flightNumber +  '-'
							  + leg.departureTime +  '-'
							  + leg.arrivalTime + itinerarySeperator;
				});

				_airlineName = typeof(fare.airline.name)!='undefined' ? fare.airline.name : _airlineName;
				_airlineCode =  typeof(fare.airline.code)!='undefined' ? fare.airline.code : _airlineCode;
				_price = typeof(fare.price.grossPrice)!='undefined' ? '$' + fare.price.grossPrice : _price;
				_base = typeof(fare.price.nettPrice)!='undefined' ? '$' + fare.price.nettPrice : _base;
				_tax = typeof(fare.price.tax)!='undefined' ? '$' + fare.price.tax : _tax;

				// If this is an internal product report on the SKU
				_specialID = (fare.code=="SKU") ? fare.sku : fare.code;

				if(fare.code=="SKU")
				{
					 itinerary = 'sku product';
				}
			}
		}
		if(typeof(FAREINFO.queryObj) !== 'undefined' && _departureCityCode === '') {
            _departureCityCode =  (typeof(FAREINFO.queryObj.depCode)!='undefined' ? FAREINFO.queryObj.depCode : _departureCityCode );
            _departureCityName = (typeof(FAREINFO.queryObj.depCity)!='undefined' ? FAREINFO.queryObj.depCity : _departureCityName );
            _departureString = (typeof(FAREINFO.queryObj.depStr)!='undefined' ? FAREINFO.queryObj.depStr : _departureString );

            _arrivalCityCode = (typeof(FAREINFO.queryObj.destCode)!='undefined' ? FAREINFO.queryObj.destCode : _arrivalCityCode );
            _arrivalCityName = (typeof(FAREINFO.queryObj.destCity)!='undefined' ? FAREINFO.queryObj.destCity : _arrivalCityName );
            _arrivalString = (typeof(FAREINFO.queryObj.destStr)!='undefined' ? FAREINFO.queryObj.destStr : _arrivalString );

			_cabinClass = (typeof(FAREINFO.queryObj.cabinClass)!='undefined' ? FAREINFO.queryObj.cabinClass : _cabinClass );
			_fareType = (typeof(FAREINFO.queryObj.fareType)!='undefined' ? FAREINFO.queryObj.fareType : _fareType );
			_routeType = (typeof(FAREINFO.queryObj.routeType)!='undefined' ? FAREINFO.queryObj.routeType : _routeType );
			_enquiryType = _departureCityCode + '-' + _arrivalCityCode;
			_airlineCode = 'N/A';
        }

        // Check if newsletter subscribed
        this.$form.find('input[name=specials]').each(function()
        {
            if($(this).val() == 'yes' && $(this).attr('checked'))
            {
                _subscribedNewsletter = 'yes';
            }
        });

        // Set the enquiry success message to be more informative
        SF.SETTINGS.LANG.enquirySuccess = 'Your international flights enquiry from '+ _departureCityName +' to '+ _arrivalCityName +' has been sent and a flights specialist will be in contact with you shortly. ';


		        // Change enquiry-type (reflected in Google Stats)
        $form.field('enquiryType', 'international-flights-enquiry/' + _enquiryType);
		$form.field('specialOid', _specialID);
		$form.field('todaysDate', _todaysDate);

		// Populate general enquiry form feilds.
        $form.field('departureIATA', _departureCityCode );
        $form.field('departureCity', _departureCityName);
        $form.field('departureStr', _departureCityName);

        $form.field('destinationIATA', _arrivalCityCode);
        $form.field('destinationCity', _arrivalCityName);
        $form.field('destinationStr', _arrivalCityName);

		$form.field('cabinClass', _cabinClass);
        $form.field('fareType', _fareType);
        $form.field('tripType', _routeType);

		$form.field('airlineName', _airlineName);
		$form.field('airlineCode', _airlineCode);
		$form.field('price', _price);
		$form.field('base', _base);
		$form.field('tax', _tax);
        $form.field('emailNewsletter', _subscribedNewsletter);

		if(_routeType == 'OW') {
			$form.field('retDate', '');
		}
		$form.field('itin', itinerary);

		FCL.UTIL.log("form vals are \n",$form.serialize());
    }
});

