//LavaLamp 1.3.3 plugin for jQuery
(function(b){b.fn.lavaLamp=function(a){a=b.extend({fx:"swing",speed:500,click:function(){return true},startItem:"no",autoReturn:true,returnDelay:0,setOnClick:true,homeTop:0,homeLeft:0,homeWidth:0,homeHeight:0,returnHome:false},a||{});var g;if(a.homeTop||a.homeLeft){g=b('<li class="homeLava selectedLava"></li>').css({left:a.homeLeft,top:a.homeTop,width:a.homeWidth,height:a.homeHeight,position:"absolute"});b(this).prepend(g)}return this.each(function(){function h(d){d||(d=c);var k=0,l=0;if(!b.browser.msie){k=
(e.outerWidth()-e.innerWidth())/2;l=(e.outerHeight()-e.innerHeight())/2}e.stop().animate({left:d.offsetLeft-k,top:d.offsetTop-l,width:d.offsetWidth,height:d.offsetHeight},a.speed,a.fx)}var m=location.pathname+location.search+location.hash,f={},i,e,c,j=b("li[class!=noLava]",this);if(a.startItem=="no")f=b('li a[href$="'+m+'"]',this).parent("li");if(f.length==0&&a.startItem=="no")f=b('li a[href$="'+location.pathname.substring(location.pathname.lastIndexOf("/")+1)+location.search+location.hash+'"]',this).parent("li");
if(f.length==0||a.startItem!="no"){if(a.startItem=="no")a.startItem=0;f=b(j[a.startItem])}c=b("li.selectedLava",this)[0]||b(f).addClass("selectedLava")[0];j.mouseenter(function(){if(b(this).hasClass("homeLava"))c=b(this)[0];h(this)});e=b('<li class="backLava"><div class="leftLava"></div><div class="bottomLava"></div><div class="cornerLava"></div></li>').appendTo(this);b(this).mouseleave(function(){if(a.autoReturn)if(a.returnHome&&g)h(g[0]);else if(a.returnDelay){i&&clearTimeout(i);i=setTimeout(function(){h(null)},
a.returnDelay+a.speed)}else h(null)});j.click(function(d){if(a.setOnClick){b(c).removeClass("selectedLava");b(this).addClass("selectedLava");c=this}return a.click.apply(this,[d,this])});a.homeTop||a.homeLeft?e.css({left:a.homeLeft,top:a.homeTop,width:a.homeWidth,height:a.homeHeight}):e.css({left:c.offsetLeft,top:c.offsetTop,width:c.offsetWidth,height:c.offsetHeight})})}})(jQuery);

var IE7_PNG_SUFFIX = ".png";

$(document).ready(function(){

  //for state regualtions page
  $(".drop-link").click(function () {
    $(this).next().slideToggle("normal");
    return false;
  });

  $(".regionLink").click(function () {
    var region = $(this).attr("title");
    var regionElement = $(".region-link[id='" +region+ "']");
    regionElement.trigger('click');
    return false;
  });

  $("#nav").lavaLamp({fx: 'swing', speed: 333});
  $("#ocviDemo").overlay();
  
  $("#accordion").tabs("div.collapse-box", { 
    tabs: 'h2',
    effect: 'horizontal'
  });
  var tabApi = $("#accordion").data("tabs");
  //hack to get the tab we want to open via url param
  var lhash = window.location.hash;
  var initTab = 0;
  if(lhash == "#vets"){initTab = 1};
  if(lhash == "#labs"){initTab = 2};
  if(lhash == "#officials"){initTab = 3};
  tabApi.click(initTab);

  $("#accordion .tipped-right[title]").tooltip({
    position:'center right',
    tipClass:'accordion-tip',
    effect:'fade',
    opacity: 0.9,
    fadeInSpeed:120,
    fadeOutSpeed:240,
    delay:150,
    predelay:3
  });
  $("#accordion .tipped-left[title]").tooltip({
    position:'center left',
    tipClass:'accordion-tip',
    effect:'fade',
    opacity: 0.9,
    fadeInSpeed:120,
    fadeOutSpeed:240,
    delay:150,
    predelay:3
  });
  
  $(".accordion-switch a:first-child").click(function() {tabApi.prev(); return false;});
  $(".accordion-switch a:last-child").click(function() {tabApi.next(); return false;});
});


