// Onload When Document Ready
$j(document).ready(function() {
  $j('a[rel=external]').attr('target', '_blank');
  $j('.equalize').equalHeights('true');
  $j("img[src$=png],.pngfix").pngfix();
  $j('a[rel*=facebox]').facebox();

	$j("a[href^='http']").not("a[href*='RinglingInternationalArtsFestival'],a.nopopup").click(function(){  
		var $a = jQuery(this);
		var href = this.href.replace('#', '%23');

		jQuery.facebox(function() {
		  jQuery.get('../external.cfm?link='+href, function(data) {
		    jQuery.facebox(data)
		  })
		}) 

		return false;

  });  

  if ($j('#rotate').length){
  	$j('#rotate')
  	.after('<div id="cyclenav">')
  	.cycle({
      fx:     'fade', 
      speed:  'fast', 
      next:   '#next', 
      prev:   '#prev', 
      pager:  '#cyclenav' 
    });
  }
	
  if ($j('#rotateQuote').length){
  	$j('#rotateQuote')
			.cycle({
				fx:	'fade',
				speed: 500,
				timeout: 7000
			
			});
	}
	
  if ($j('#rotateSponsor').length){
  	$j('#rotateSponsor')
			.cycle({
				fx:	'fade',
				speed: 500,
				timeout: 5000
			});
	}
	
  if ($j('#rotateHomepageSponsor').length){
  	$j('#rotateHomepageSponsor')
			.cycle({
				fx:	'fade',
				speed: 500,
				timeout: 5000
			});
	}
	
  if ($j('#rotatePerformanceImages').length){
  	$j('#rotatePerformanceImages')
			.cycle({
				fx:	'fade',
				speed: 250,
				timeout: 5000,
				before: function(currSlideElement, nextSlideElement, options, forwardFlag){
					var h = $j(nextSlideElement).height();
					$j("#rotatePerformanceImages").css("height", h).parent().css("height", h);
				},
				after: function(currSlideElement, nextSlideElement, options, forwardFlag){
					var h = $j(nextSlideElement).height();
					$j("#rotatePerformanceImages").css("height", h).parent().css("height", h);
				}
			});
	}
	
  if ($j('a.fancybox').length){
		$j("a.fancybox").fancybox({type: 'ajax', padding: 0});
	}

	$j('#danceToggle').click(function(){$j('div.danceSched').toggleClass('scheduleOn');return false;});
	$j('#theaterToggle').click(function(){$j('div.theaterSched').toggleClass('scheduleOn');return false;});
	$j('#musicToggle').click(function(){$j('div.musicSched').toggleClass('scheduleOn');return false;});
	$j('#visual-artToggle').click(function(){$j('div.visual-artSched').toggleClass('scheduleOn');return false;});

	  function addMenu(){
		$j(this).addClass("hovering").siblings(".hovering").each(function(){
			if($j(this).removeClass("hovering").hoverIntent_t) $j(this).hoverIntent_t = clearTimeout($j(this).hoverIntent_t);
		});
	}
	
  function removeMenu(){$j(this).removeClass("hovering");}
  
  var menuConfig = {
    over: addMenu,
    timeout: 500,
    out: removeMenu
  }
  $j("li.mega").hoverIntent(menuConfig);
	
	
});

function addBookmark(title,url) {
  if (window.sidebar) {
    window.sidebar.addPanel(title, url,"");
  } else if( document.all ) {
    window.external.AddFavorite( url, title);
  } else if( window.opera && window.print ) {
    return true;
  }
}
