/* menu.js */
$(document).ready(function() {
    $(document).click(function(event) {
        if (   $(event.target).attr('id') != 'sho-language'
            && $(event.target).attr('id') != 'sho-industries'
            && $(event.target).attr('id') != 'sho-locations'
            && $(event.target).attr('id') != 'sho-country'
        ){ toggle_frames(''); };
    });
    $('#sho-language').click(function() { toggle_frames('language'); });
    $('#sho-industries').click(function() { toggle_frames('industries'); });
    $('#sho-locations').click(function() { toggle_frames('locations'); });
    $('#sho-country').click(function() { toggle_frames('country'); });
});
function toggle_frames(i)
{
    $('#language:visible').fadeOut('fast');
    $('#industries:visible').fadeOut('fast');
    $('#locations:visible').fadeOut('fast');
    $('#country:visible').fadeOut('fast');
    if ( i != '' )
    {
        if ( $('#'+i).is(":visible") )
        { $('#'+i).fadeOut('fast'); }
        else
        { $('#'+i).fadeIn('fast'); }
    }
}


/* leaderboard-advertisement.js */
$(document).ready(function() { displayLeaderboardAdvertisement(); });

function displayLeaderboardAdvertisement () {
    /* JSON requests for featured recruiter banners and display */
    var $url = '/advertisement/leaderboard/get/1/';
    $.getJSON (
        $url,
        function(data)
        {
            $.each(data, function(key, value)
            {
                var banner = value.img;
                if ( banner == '' ) {

                } else {
                  if (value.alternate_code == undefined) {
                    $('.ad-holder').append('<a href="' + value.href + '" title="' + value.title + '"><img src="' + banner + '" alt="' + value.alt + '" title="' + value.title + '" style="border: 3px solid #DBE7F9;" width="468" height="60" /></a>');
                  } else {
                    //$('.ad-holder').append($("<span/>").html(value.alternate_code).text());
                    $('.ad-holder').append(value.alternate_code);
                  }
                }
            });
        }
    );
}


