﻿jQuery(document).ready(function() {
    var host = "";
    host = location.protocol + "//";
    host += location.host;
    var changeCountry = jQuery("#panel").expose({ maskId: 'mask', api: true, closeOnClick: false });

    // Expand Panel
    jQuery("#slideme").click(function() {
        jQuery("div#panel").slideDown("slow").queue(function() {
            jQuery.ajax({
                url: host + "/master/about_ef/country-selector",
                type: "GET",
                dataType: "html",

                success: function(data) {

                    jQuery("#fChangeCountry").html(data);
                },

                error: function(xhr, ajaxOptions, thrownError) {
                    alert("error loading the ajax change country page!" + thrownError.toString());
                },
                async: false
            });
            jQuery(this).dequeue();
        });

        jQuery("div#toppanel .tab").css("display", "block");







        changeCountry.load();
        //setInterval("", 500000);








    });

    // Collapse Panel
    jQuery("#close").click(function() {
        jQuery("div#panel").slideUp("slow");
        jQuery("div#toppanel .tab").css("display", "none");

        changeCountry.close();

    });
});

/* closes the topbar if escape key pressed */
jQuery(document).keyup(function(e) {
    var changeCountry = jQuery("#panel").expose({ maskId: 'mask', api: true, closeOnClick: false });

    if (e.keyCode == 27) {
        jQuery("div#panel").slideUp('slow');
        jQuery("div#toppanel .tab").css("display", "none");
        changeCountry.close();
    }
});
