﻿jQuery(function () {

    // language.
    var getCurrentLan = function () {
        var lan = jQuery.cookie('lan');
        if (!lan)
            lan = 'en';
        return lan;
    };
    var currentLan = getCurrentLan();

    // Add event handlers for footer language links.
    jQuery("a[data-lan]").each(function () {
        var href = 'javascript:void(0);';
        jQuery(this).attr('href', href);
        var lan = jQuery(this).attr('data-lan');
        var isCurrent = lan == currentLan;

        if (isCurrent) {
            //jQuery(this).css({});

        }
        jQuery(this).click(function () {
            /*if (isCurrent) {
                console.log('Lanauage already ' + lan + '.');
                alert('Already in ' + jQuery(this).text());
            }
            else {*/
                console.log('Changing language to ' + lan + '...');
                jQuery.cookie('lan', lan);
                window.location = window.location;
            //}
        });
    });
	
	
	// Set class="current" to navigation links.
	var currentFile=window.location.pathname;
	if(currentFile && currentFile.length>1){
		currentFile=currentFile.substring(1,currentFile.length);
		jQuery('a[href="'+currentFile+'"], a[href="/'+currentFile+'"]').addClass('navon');
		
	}
});
