$(document).ready(function(){

$("ul.sf-menu").superfish();

$('#feature').jcarousel({scroll:1, wrap: 'circular'});

$('#pub-scroll').jcarousel({scroll:6});


$("a.login_overlay").overlay({
close: "a#close-overlay",
mask: {color: '#000',loadSpeed: 200,opacity: 0.5},
top: '0%'
});

//publication tooltip
$(".jcarousel-container-horizontal .pubcover-item img.pubcover").tooltip({ relative: true, position: "top center", offset: [160, 0]});

$(".pub-page .pubcover-item img.pubcover").tooltip({ position: "top center", offset: [145, 0]});

$(".ohio-home-pub .pubcover-item img.pubcover").tooltip({relative: true, position: "top center", offset: [70, 0]});

//change pagination controls
$("td.pg-prev a").text("<");
$("td.pg-next a").text(">");

//tabs
$(".tabs").tabs(".panes > div");
$(".tabs-commentary").tabs(".panes > div");


//load videos
$("a.showvideo").click(function(event){
event.preventDefault();

var whichVideo = "#" + $(this).attr("id");
$(".video-player").hide();
$(whichVideo+" .video-player").show();

$('body').animate({
scrollTop: $('body').position().top
}, 'slow');

return false;

});

//load podcasts
$("a.playpodcast").click(function(event){
event.preventDefault();

var whichPodcast = "#" + $(this).attr("id");
$(".playme").hide();
$(whichPodcast+" .playme").show();

$('body').animate({
scrollTop: $('body').position().top
}, 'slow');

return false;

});

//blog archive form

$('.archive-link').change(function() {

var goto= $(".archive-link option:selected").attr("value");
window.location = goto;

});

//blog box rollover

$("#flypaper-box a").mouseover(function(){
$("#flypaper-box").addClass("hover");
$("#flypaper-box h2").addClass("hover");
});
$("#flypaper-box a").mouseout(function(){
$("#flypaper-box").removeClass("hover");
$("#flypaper-box h2").removeClass("hover");
});

$("#cc-box a").mouseover(function(){
$("#cc-box").addClass("hover");
$("#cc-box h2").addClass("hover");
});
$("#cc-box a").mouseout(function(){
$("#cc-box").removeClass("hover");
$("#cc-box h2").removeClass("hover");
});

$("#cw-box a").mouseover(function(){
$("#cw-box").addClass("hover");
$("#cw-box h2").addClass("hover");
});
$("#cw-box a").mouseout(function(){
$("#cw-box").removeClass("hover");
$("#cw-box h2").removeClass("hover");
});

$("#ohio-box a").mouseover(function(){
$("#ohio-box").addClass("hover");
$("#ohio-box h2").addClass("hover");
});
$("#ohio-box a").mouseout(function(){
$("#ohio-box").removeClass("hover");
$("#ohio-box h2").removeClass("hover");
});

$("#bev-box a").mouseover(function(){
$("#bev-box").addClass("hover");
$("#bev-box h2").addClass("hover");
});
$("#bev-box a").mouseout(function(){
$("#bev-box").removeClass("hover");
$("#bev-box h2").removeClass("hover");
});

$("#stsd-box a").mouseover(function(){
$("#stsd-box").addClass("hover");
$("#stsd-box h2").addClass("hover");
});
$("#stsd-box a").mouseout(function(){
$("#stsd-box").removeClass("hover");
$("#stsd-box h2").removeClass("hover");
});


$("#tier2-box-1 a").mouseover(function(){
$("#tier2-box-1 .header").addClass("hover");
$("#tier2-box-1 .description").addClass("hover");
});
$("#tier2-box-1 a").mouseout(function(){
$("#tier2-box-1 .header").removeClass("hover");
$("#tier2-box-1 .description").removeClass("hover");
});

$("#tier2-box-2 a").mouseover(function(){
$("#tier2-box-2 .header").addClass("hover");
$("#tier2-box-2 .description").addClass("hover");
});
$("#tier2-box-2 a").mouseout(function(){
$("#tier2-box-2 .header").removeClass("hover");
$("#tier2-box-2 .description").removeClass("hover");
});

$("#tier2-box-3 a").mouseover(function(){
$("#tier2-box-3 .header").addClass("hover");
$("#tier2-box-3 .description").addClass("hover");
});
$("#tier2-box-3 a").mouseout(function(){
$("#tier2-box-3 .header").removeClass("hover");
$("#tier2-box-3 .description").removeClass("hover");
});




$("form[name=search]").parent().parent().parent().hide();
$("p.searchDescription").each(function(){
var thisText = $(this).text();
var toRemove = 'Description: ';
var cleanDesc = thisText.replace(toRemove,'');
$(this).text(cleanDesc);
});

$("img#archive-search-submit").click(function(){
var thisYear = $("form#adv-search select#year option:selected").val();
var thisMonth = $("form#adv-search select#month option:selected").val();
var goto=$("form#adv-search").attr("action");
var startMo = thisMonth;
var endMo= thisMonth;

if (thisMonth=='any'){
startMo="01";
endMo="12";
}

var lastDay = "31";	

if (thisMonth=='04' || thisMonth=='06' || thisMonth=='09' || thisMonth=='11'){
lastDay = "30";	
}

if (thisMonth=='02'){
lastDay="28";	
}

window.location = goto + "&startDate=" + startMo + "/01/"+ thisYear + "&endDate=" + endMo + "/" + lastDay + "/" + thisYear;
});




});

