
if(window['console'] === undefined) window.console = { log: function() {} };

var landes = function() {
	return {
        journal_nav_width : 157
        ,journal_nav_height : 13
        ,journal_exp_height : 346
        ,journal_exp_width : 700
        ,landes_feature_speed : 15
        ,current_login_session : false
        ,init : function() {
            row = 0;
            col = 0;


//            $('#landes_main_nav_journals').attr('href', '#');
            $('#landes_main_nav_books').attr('href', '#');

            $('.landes_search_check').click(function(a,b,c) {
                    $('.landes_search_check').not('#'+$(this).attr('id')).attr('checked', false);
                });

            $('.landes_main_menu').superfish({
                    dropShadows:false,
                    autoArrows:false
                }); 

            landes.periodized_authcheck();
        }
        ,menu_hide : function() {
            $("#journalList_div").fadeOut('fast');
        }

        ,authcheck : function() {
            $.post("/authcheck/", function(a) {
                    if(a == 'ok') {
                        landes.current_login_session = true;
                    }
                    else if(a != 'ok') {
                        if(landes.current_login_session === true) {
                            document.location.href = "/";
                        }
                        else {
                            clearTimeout(landes.periodized_authcheck_timeout);
                        }
                    }
                });
        }

        ,periodized_authcheck : function() {
            landes.authcheck();
            landes.periodized_authcheck_timeout = setTimeout(landes.periodized_authcheck, 60000);
        }
    }
}();
$(landes.init); 

$(document).ready(function () {
    document.view = '';
    $.ajax({url:'get_view/',success:function(returned){document.view = returned.replace(/\"/g, '');}, async:false});
    if(document.view == 'full'){
	full_view();
    }
});

function toggle_view() {
    var current_width = $('#landes_page').css('width');
    if(current_width == '950px'){
	$.ajax({url:'set_view/?view=full', async:false});
    }else{
	$.ajax({url:'set_view/?view=normal', async:false});
    }
    document.location.reload();
}

function full_view() {
    var cururl = document.location+'';
    if(!cururl.match(/admin/)){return false;}
    var width = $(document).width() - 53;
    $(".container").css("width", width);
    $('.span-24, div.span-24').css('width', width);
    $('#landes_page').css('width', width);
    $('#landes_sub_nav').css('width', width);
    $('#landes_footer').css('width', width+40);
    $('.span-20').css('width', width);
}
 

