﻿
// Open a new window and search in transversal for the specified criteria
function AskFlybmiOpenWinSearch(nlpq, kb) {

    var windowToOpen = "http://ask.flybmi.com/templates/flybmi/help/resultspage";

    var culture = document.location.href.toLowerCase().split('/')[4];

    // If its not null or empty
    if (culture) {
        // Get country section
        var country = culture.split('-')[1];
        // If it is 2 chars long e.g. ie/gb
        if (country && country.length == 2) {
            // Set correct account type, default to uk if we dont find country
            switch (country) {
                case "ie":
                    windowToOpen = "http://flybmi.metafaq.com/en-ie";
                    break;
                default:
                    windowToOpen = "http://ask.flybmi.com/templates/flybmi/help/resultspage";
                    break;
            }
        }
    }

    var mfWin = window.open(windowToOpen + "?nlpq=" + nlpq + "&kb=" + kb, mfWin, "screenX=10,screenY=10,left=10,top=10,width=600,height=600,resizable");
    
    mfWin.focus();
}

// Open a new window with the specified url
function AskFlybmiOpenWinArticle(url) {
    var mfWin = window.open(url, mfWin, "screenX=10,screenY=10,left=10,top=10,width=600,height=600,resizable");
    mfWin.focus();
}

function AskFlybmiTrackUse(el, desc) {
   // Create the Omniture tracking object, use s_account that is defined in s_code.js
    var asks = s_gi(s_account);
   asks.tl(el, 'o', desc);
}

var Top5Loaded = false;

function GetTop5Questions() {

    if (!Top5Loaded) {
        var top5 = Src_Ascx_Controls_Transversal_TopFiveFAQ.LoadTop5().value;

        if (top5 != null)
            document.getElementById('faqDiv').innerHTML = top5;

        Top5Loaded = true;
    }
}

$(function () {
    $(".search", ".search_AskFlybmi").click(function (e) {
        var element = $(this);
        var searchText = $(".textbox", ".search_AskFlybmi").val();
        AskFlybmiOpenWinSearch(searchText, '');
        AskFlybmiTrackUse(element, 'Transversal search from top navigation')
        e.preventDefault();
    });

    $(".faq_btm_bdr_top5").click(function () {
        //Show top 5 questions
        $(".faq_btm_bdr").toggle();
    });


});
