$(document).ready(function(){

	// If browser is IE, disable BackgroundImageCache
	if (jQuery.browser.msie) {
		try {
			document.execCommand("BackgroundImageCache", false, true);
		} catch (err) {
		}
	}
    // Reset Font Size
    var originalFontSize = $('html').css('font-size');
    $(".font_reset").click(function(){
        $('html').css('font-size', originalFontSize);
    });
    // Increase Font Size
    $(".font_increase").click(function(){
        var currentFontSize = $('html').css('font-size');
        var currentFontSizeNum = parseFloat(currentFontSize, 10);
        var newFontSize = currentFontSizeNum * 1.1;
        $('html').css('font-size', newFontSize);
        return false;
    });
    // Decrease Font Size
    $(".font_decrease").click(function(){
        var currentFontSize = $('html').css('font-size');
        var currentFontSizeNum = parseFloat(currentFontSize, 10);
        var newFontSize = currentFontSizeNum * 0.9090909;
        $('html').css('font-size', newFontSize);
        return false;
    });
    
    // Lightbox Configuration
    $.fn.lightbox.init();
    
    // Accordion effects		
    $(".accordion").not(".active").find(".box").hide();
    $(".accordion .btn").css("cursor", "pointer");
    $(".accordion .btn").click(function(){
        $(this).parent().toggleClass("active");
        $(this).parent().find(".box").slideToggle();
    }); 
    
    // Metanavigation - Animations
    
    $('#countries li a').click(function(event){
    	$(this).attr("href", $(this).attr("href") + ($(this).attr("href").indexOf("?") > 0 ? '&' : '?') + "countrychange=1");
        var link = $(this).attr("href");
        var target = $(this).attr("target");

        if (target == "_blank") {
            return true;
        }

        $('#divisions ul li').each(function(){
            var newleft = $(this).css("left");
            $(this).css("left", newleft);
            
        });
        
        $('#divisions ul li.COUNT1').animate({
            left: '-=12em'
        }, 1000, 'linear', function(){
            document.location.href = link;
        });
        $('#divisions ul li.COUNT2').animate({
            left: '-=23em'
        }, 1000, 'linear');
        $('#divisions ul li.COUNT3').animate({
            left: '-=34em'
        }, 1000, 'linear');
        $('#divisions ul li.COUNT4').animate({
            left: '-=45em'
        }, 1000, 'linear');
        $('#divisions ul li.COUNT5').animate({
            left: '-=56em'
        }, 1000, 'linear');
        $('#divisions ul li.COUNT6').animate({
            left: '-=67em'
        }, 1000, 'linear');
        
        return false;
    });
    
    
    $('#divisions .countrychange li.COUNT1').animate({
        left: '-0.25em'
    }, 1000, 'linear');
    $('#divisions .countrychange li.COUNT2').animate({
        left: '10.75em'
    }, 1000, 'linear');
    $('#divisions .countrychange li.COUNT3').animate({
        left: '21.75em'
    }, 1000, 'linear');
    $('#divisions .countrychange li.COUNT4').animate({
        left: '32.75em'
    }, 1000, 'linear');
    $('#divisions .countrychange li.COUNT5').animate({
        left: '42.75em'
    }, 1000, 'linear');
    $('#divisions .countrychange li.COUNT6').animate({
        left: '54.75em'
    }, 1000, 'linear');
});

