$(document).ready(function(){
  $("#vaccordian h3").click(function(){
    if($(this).attr('class') == "close-section") {
      $(this).css({backgroundImage:"url(/images/buttons/close_view1-pub.png)"});
      $(this).next(".section-content").slideDown(500); 
      $(this).removeClass('close-section');
      $(this).addClass('open-section');
    } else {
      $(this).css({backgroundImage:"url(/images/buttons/open_view1-pub.png)"});
      $(this).next(".section-content").slideUp(500);
      $(this).removeClass('open-section');
      $(this).addClass('close-section');
    }
    return false;
  });
  if($('.close-all').length > 0) {
    $("#vaccordian h3").removeClass('close-section');
    $("#vaccordian h3").addClass('open-section');
    $(".section-content").show();
	$("#vaccordian h3").css({backgroundImage:"url(/images/buttons/close_view1-pub.png)"});
    $("#v_open_all").html("Minimize All Sections");
  } else {
    $("#vaccordian h3").removeClass('open-section');
    $("#vaccordian h3").addClass('close-section');
    $("#vaccordian h3").css({backgroundImage:"url(/images/buttons/open_view1-pub.png)"});
    $("#v_open_all").html("Expand All Sections");
  }
  $("#v_open_all").click(function(){
    if($('.close-all').length > 0) {
    $(".section-content").slideUp(500);
	  $("#vaccordian h3").css({backgroundImage:"url(/images/buttons/open_view1-pub.png)"});
    $("#vaccordian h3").removeClass('open-section');
    $("#vaccordian h3").addClass('close-section');
    $(this).html("Expand All Sections");
    $(this).removeClass('close-all');
    $(this).addClass('open-all');
    } else {
    $(".section-content").slideDown(500);
	$("#vaccordian h3").css({backgroundImage:"url(/images/buttons/close_view1-pub.png)"});
    $("#vaccordian h3").removeClass('close-section');
    $("#vaccordian h3").addClass('open-section');
    $(this).html("Minimize All Sections");
    $(this).removeClass('open-all');
    $(this).addClass('close-all');
    }
    return false;
  });
	/* New Catalog Interface JS */

  $('#worldCat').parent("a").attr({id: "worldCatlink"});
  $('#sdCircuit').parent("a").attr({id: "sdCircuitlink"});
  $('#viewSaved').parent("a").attr({id: "viewSavedlink"});
  $('#clearSaved').parent("a").attr({id: "clearSavedlink"});
  $('#saveRecord').parent("a").attr({id: "saveRecordlink"});
  $('#marcDisplay').parent("a").attr({id: "marcDisplaylink"});
  $('#amazonReview').parent("a").attr({id: "amzlink"});
  $('#showSimilar').parent("a").attr({id: "simlink"});
  $('#site-navi a img[title^=Remove]').parent("a").attr({id: "rmSavedItem"});
  $('#site-navi a img[title^=Remove]').after('Remove');
  $('#site-navi a img[title^=Remove]').css('display','none');
  $('.briefcitEntryMark a img[title^=Save]').after('<span class="addtext">Add</span>');
  $('.briefcitEntryMark a img[title^=Remove]').after('<span class="rmtext">Remove</span>');
  var viewresultsitems = $.cookie('catalogresultsview');
  $("#export_form").prepend("<div id='view-changer'>Brief View</div>");
  if (viewresultsitems == "briefview"){
    $(".browseScreen .briefcitItems").fadeOut(500);
    $("#view-changer").html("Expanded View");
    $(".browseScreen .briefcitItems #view-changer").removeClass('expanded');
    $(".browseScreen .briefcitItems #view-changer").addClass('briefview');
    $(".browseScreen .briefcitItems").removeClass('expanded-section');
    $(".browseScreen .briefcitItems").addClass('briefview-section');
  } else {
    $(".browseScreen .briefcitItems").slideDown(500);
    $("#view-changer").html("Brief View");
    $(".browseScreen .briefcitItems #view-changer").removeClass('briefview');
    $(".browseScreen .briefcitItems #view-changer").addClass('expanded');
    $(".browseScreen .briefcitItems").removeClass('briefview-section');
    $(".browseScreen .briefcitItems").addClass('expanded-section');
  }  
  $("#view-changer").click(function(){
    if($('#view-changer.expanded').length > 0) {
      $(".browseScreen .briefcitItems").fadeOut(500);
      $(this).html("Expanded View");
      $(this).removeClass('expanded');
      $(this).addClass('briefview');
      $(".browseScreen .briefcitItems").removeClass('expanded-section');
      $(".browseScreen .briefcitItems").addClass('briefview-section');
      $.cookie('viewresultsitems', 'briefview', { path: '/', expires: 10 });
    } else {
      $(".briefview-section").slideDown(500);
      $(this).html("Brief View");
      $(this).removeClass('briefview');
      $(this).addClass('expanded');
      $(".browseScreen .briefcitItems").removeClass('briefview-section');
      $(".browseScreen .briefcitItems").addClass('expanded-section');
      $.cookie('viewresultsitems', null, { path: '/' });
    }
    return false;
  });
});
this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 30;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$(".tipsy").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$(this).children("img").attr({alt: ""});									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$(".tipsy").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};
this.tooltipMeebo = function(){	
	$(".meebonote").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$(".meebonote").prepend("<div id='meebo_notice'>"+ this.t +"</div>");
		$("#meebo_notice")
			.stop(true, true).animate({opacity: "show", top: '10',right: "-140"}, "6000");		
    },
	function(){
		this.title = this.t;		
		$("#meebo_notice").remove();
    });	
};
this.tooltipPlus = function(){	
	$(".bubblify").mouseover(function(){											  
		$("p#meebo_bubble").css({top: 600, left: 584})
			.fadeIn('2000');		
    }).mouseout(function(){
		$("p#meebo_bubble").fadeOut('2500');
    });	
};
function initMenu() {
  $('.jquery-float-menu ul').hide();
  $('#top-menu-1 li.menuparent a').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        $('.jquery-float-menu ul:visible').fadeOut('1000');
        return false;
      }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('.jquery-float-menu ul:visible').fadeOut('1000');
        checkElement.fadeIn('1000');
        return false;
      }
    }
  );
  $('.jquery-float-menu2 ul').hide();
  $('ul.submenu').show();
  $('#library-nav li.menuparent a').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        $('.jquery-float-menu2 ul:visible').fadeOut('1000');
        return false;
      }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('.jquery-float-menu2 ul:visible').fadeOut('1000');
        checkElement.fadeIn('1000');
        $('ul.submenu').show();
        return false;
      }
    } 
  );
$('#nice-menu-7 li.menuparent a').click(
function() {
  var checkElement = $(this).next();
  if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
  $('.nice-menu ul:visible').fadeOut('1000');
  return false;
  }
  if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
  $('.nice-menu ul:visible').fadeOut('1000');
  checkElement.fadeIn('1000');
  return false;
  }
  }
);
}
