﻿$(document).ready(function () {
    $("ul.navmnu li").hover(function () {
        $(this).children('ul').fadeIn(70);
    }, function () {
        $(this).children('ul').fadeOut(70);
    });
    //set selected root menu based on url (server-side control)
    var a = $("ul.navmnu li a.select:first");
    if (a != null) {
        var parent = a.parent().parent();
        //if root is not already selected
        if(!parent.hasClass('navmnu'))
            parent.parent().find("a:first").addClass("select");
    }
    // read more
    $('div.newsContainer ul li').hover(function () {
        var e = $(this).find('span.link span');
        if (e.css('display') == 'none') {
            e.css('display', 'inline');
        }
    },
        function () {
            var e = $(this).find('span.link span');
            if (e.css('display') != 'none') {
                e.css('display', 'none');
            }
        });
    initCountrybar();
});
// country bar
function initCountrybar() {
    $('#nation').click(function(e) { toggleCountryBar(); });
    $('#world').click(function(e) { toggleCountryBar(); });
    //set selection
    $('#nation span.countryselector').text($('li.select:first','#world').text());
}
function toggleCountryBar() {
    var world = $('#world');
    if (world.css('display') == 'none') {
        world.fadeIn('fast', function() { });
    } else {
        world.fadeOut('fast', function() { });
    }
}
