$().ready(function() {
    $('.searchin').selectbox();
    $('.popupwindow').popupwindow(profiles);
    $('.int-crumb ul li a:first').addClass('crstart');
    $('.int-crumb ul li a:eq(1)').addClass('crsecond')
});

var profiles = { window800: { height: 800, width: 800, status: 1 }, window200: { height: 200, width: 200, status: 1, resizable: 0 }, windowCenter: { height: 300, width: 400, center: 1 }, windowNotNew: { height: 300, width: 400, center: 1, createnew: 0 }, windowemailcol: { height: 510, width: 400, center: 1, createnew: 0 }, windowprint: { height: 400, width: 600, center: 1, createnew: 0, scrollbars: 1} };
$().ready(function() {
    $('A[rel="external"]').click(function() {
        window.open($(this).attr('href'));
        return false
    })
});



$().ready(function() {
    // show panel based on state
    if ($.cookie('pub-aaps') == 'visible') {
        $('#pub-aaps').show();
    }
    else {
        $('#pub-aaps').hide();
    }
    if ($.cookie('pub-pharmres') == 'visible') {
        $('#pub-pharmres').show();
    }
    else {
        $('#pub-pharmres').hide();
    }
    if ($.cookie('pub-pharmscitech') == 'visible') {
        $('#pub-pharmscitech').show();
    }
    else {
        $('#pub-pharmscitech').hide();
    }

    if ($.cookie('pub-news') == 'visible') {
        $('#pub-news').show();
    }
    else {
        $('#pub-news').hide();
    }


    $('#tabs-aaps > ul, #tabs-pharmres > ul, #tabs-pharmscitech > ul, #tabs-news > ul').tabs({ cookie: {} });
    if ($('#pub-aaps').is(':visible')) {
        $('#btn-aaps').addClass("active");
    }
    if ($('#pub-pharmres').is(':visible')) {
        $('#btn-pharmres').addClass("active");
    }
    if ($('#pub-pharmscitech').is(':visible')) {
        $('#btn-pharmscitech').addClass("active");
    }
    if ($('#pub-news').is(':visible')) {
        $('#btn-news').addClass("active");
    }     
    // switch state when panel is clicked
    $('#btn-aaps').click(function() {
        $('#pub-aaps').slideToggle("fast", function() {
            if ($('#pub-aaps').is(':hidden')) {
                $.cookie('pub-aaps', 'hidden');
            }
            else {
                $.cookie('pub-aaps', 'visible');
            }
        });
        $(this).toggleClass("active");
        return false
    });
    $('#btn-pharmres').click(function() {
        $('#pub-pharmres').slideToggle("fast", function() {
            if ($('#pub-pharmres').is(':hidden')) {
                $.cookie('pub-pharmres', 'hidden');
            }
            else {
                $.cookie('pub-pharmres', 'visible');
            }
        });
        $(this).toggleClass("active");
        return false
    });
    $('#btn-pharmscitech').click(function() {
        $('#pub-pharmscitech').slideToggle("fast", function() {
            if ($('#pub-pharmscitech').is(':hidden')) {
                $.cookie('pub-pharmscitech', 'hidden');
            }
            else {
                $.cookie('pub-pharmscitech', 'visible');
            }
        });
        $(this).toggleClass("active");
        return false
    });
    $('#btn-news').click(function() {
        $('#pub-news').slideToggle("fast", function() {
            if ($('#pub-news').is(':hidden')) {
                $.cookie('pub-news', 'hidden');
            }
            else {
                $.cookie('pub-news', 'visible');
            }
        });
        $(this).toggleClass("active");
        return false
    });    
    
    $('.at').after('<div class="alert-nav">').cycle({ fx: 'fade', speed: 'fast', timeout: 9000, pause: true, pager: '.alert-nav' });
    $('.ui-tabs-panel ul li:nth-child(odd)').addClass("alt")
});

$().ready(function() {
$('ul.author-list li:last-child, .side-articles ul li:last-child, .article-tools ul li:last-child, .subtheme-item ul li:last-child').addClass('nobg'); 
    $('.side-title:last').addClass('nobor');
    $('div.artref:nth-child(even)').addClass('altref'); $('.article-notes').hide();
    $('a.authref').click(function() { $('.article-notes').slideToggle('400'); return false });
    $('.artref').hover(function() { $(this).addClass('arthov') }, function() { $(this).removeClass('arthov') });


    // show panel based on state
    if ($.cookie('side-mostview') == 'visible') {
        $('#side-mostview').show();
    }
    else {
        $('#side-mostview').hide();
    }
    if ($.cookie('side-onfirst') == 'visible') {
        $('#side-onfirst').show();
    }
    else {
        $('#side-onfirst').hide();
    }
    if ($.cookie('side-theme') == 'visible') {
        $('#side-theme').show();
    }
    else {
        $('#side-theme').hide();
    }        
 
    $('#btn-morefrom').click(function() {
    $('#side-morefrom').slideToggle("fast", function() {
            if ($('#side-morefrom').is(':hidden')) {
                $.cookie('side-morefrom', 'hidden');
            }
            else {
                $.cookie('side-morefrom', 'visible');
            }
        });
        $(this).toggleClass("active"); 
        return false
    });
    $('#btn-mostview').click(function() {
        $('#side-mostview').slideToggle("fast", function() {
            if ($('#side-mostview').is(':hidden')) {
                $.cookie('side-mostview', 'hidden');
            }
            else {
                $.cookie('side-mostview', 'visible');
            }
        });
        $(this).toggleClass("active"); 
        return false
    }); 
    $('#btn-onfirst').click(function() {
        $('#side-onfirst').slideToggle("fast", function() {
            if ($('#side-onfirst').is(':hidden')) {
                $.cookie('side-onfirst', 'hidden');
            }
            else {
                $.cookie('side-onfirst', 'visible');
            }
        });
        $(this).toggleClass("active");
        return false
    }); 
    $('#btn-theme').click(function() {
        $('#side-theme').slideToggle("fast", function() {
            if ($('#side-theme').is(':hidden')) {
                $.cookie('side-theme', 'hidden');
            }
            else {
                $.cookie('side-theme', 'visible');
            }
        });
        $(this).toggleClass("active");
        return false
    });
        
    $('a.noteclose').click(function(){$('.article-notes').slideUp('400');
    return false
});
$('#savepulse').click(function() {
    $('#artsave').effect('pulsate', { times: 1 }, 600);
    return false
})
});

$().ready(function() {
    $('.issue-article ul li:nth-child(even), .subtheme-item ul li:nth-child(even)').addClass('alt');
    $('.search-table tr:nth-child(even)').addClass('alt');
    $('.mypharma-article ul li:nth-child(even)').addClass('alt');

    // show panel based on state
    if ($.cookie('category-jrnfirst') == 'visible') {
        $('#category-jrnfirst').show();
    }
    else {
        $('#category-jrnfirst').hide();
    }    
    if ($.cookie('category-jrnmost') == 'visible') {
        $('#category-jrnmost').show();
    }
    else {
        $('#category-jrnmost').hide();
    }
    if ($.cookie('category-jrncurrent') == 'visible') {
        $('#category-jrncurrent').show();
    }
    else {
        $('#category-jrncurrent').hide();
    }
    if ($.cookie('category-jrntheme') == 'visible') {
        $('#category-jrntheme').show();
    }
    else {
        $('#category-jrntheme').hide();
    }
    if ($.cookie('category-jrnarchive') == 'visible') {
        $('#category-jrnarchive').show();
    }
    else {
        $('#category-jrnarchive').hide();
    }

    $('#btn-jrncurrent').click(function() {
        $('#category-jrncurrent').slideToggle("fast", function() {
            if ($('#category-jrncurrent').is(':hidden')) {
                $.cookie('category-jrncurrent', 'hidden');
            }
            else {
                $.cookie('category-jrncurrent', 'visible');
            }
        });
        $(this).toggleClass("active");
        return false
    });
    $('#btn-jrnmost').click(function() {
        $('#category-jrnmost').slideToggle("fast", function() {
            if ($('#category-jrnmost').is(':hidden')) {
                $.cookie('category-jrnmost', 'hidden');
            }
            else {
                $.cookie('category-jrnmost', 'visible');
            }
        });
        $(this).toggleClass("active");
        return false
    });
    $('#btn-jrnfirst').click(function() {
        $('#category-jrnfirst').slideToggle("fast", function() {
            if ($('#category-jrnfirst').is(':hidden')) {
                $.cookie('category-jrnfirst', 'hidden');
            }
            else {
                $.cookie('category-jrnfirst', 'visible');
            }
        });
        $(this).toggleClass("active");
        return false
    });
    $('#btn-jrntheme').click(function() {
        $('#category-jrntheme').slideToggle("fast", function() {
            if ($('#category-jrntheme').is(':hidden')) {
                $.cookie('category-jrntheme', 'hidden');
            }
            else {
                $.cookie('category-jrntheme', 'visible');
            }
        });
        $(this).toggleClass("active");
        return false
    });
    $('#btn-jrnarchive').click(function() {
        $('#category-jrnarchive').slideToggle("fast", function() {
            if ($('#category-jrnarchive').is(':hidden')) {
                $.cookie('category-jrnarchive', 'hidden');
            }
            else {
                $.cookie('category-jrnarchive', 'visible');
            }
        });
        $(this).toggleClass("active");
        return false
    })
}
);