// Onload When Document Ready
$(document).ready(function() {
  $('a[rel=external]').attr('target', '_blank');
  $('.equalize').equalHeights('true');
  $("img[src$=png],.pngfix").pngfix();
  //$(document).stickyfooter();
  $("div#nav > ul > li:not(:last),div#subnav ul li:not(:last), ul#footernav li:not(:last)").append("<span class=\"spacer\">|</span>");
  $('.photocap > img[title]').each(function(){$(this).after("<p>"+this.title+"</p>").parent().css("width", $(this).width());});
  $('a.popup').live('click',function(){var data=$(this).metadata();var name=(data.name==null)?'popup':data.name;w=screen.availWidth;h=screen.availHeight;var leftPos=(w-data.width)/2,topPos=(h-data.height)/2;window.open($(this).attr('href'),name,'width='+data.width+',height='+data.height+',toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=yes,top='+topPos+',left='+leftPos);return false;});
  
  if($('.rotation').length){
  	
  	$.getScript('/javascript/jquery.cycle.min.js', function(){
  		$('.pageHandle').append('<div class="breadcrumb">');
  		$('.rotation').cycle({ 
		    speed:  'fast', 
		    timeout: 3000, 
		    pager:  '.breadcrumb' 
			});
		})
  		
	}

	if($('a.image_zoo').length) {
		$('a.image_zoo').fancybox();
	}

	if($('a.fancy_youtube').length) {

		$("a.fancy_youtube").click(function() {

			$.fancybox({
					'padding'		: 0,
					'autoScale'		: false,
					'transitionIn'	: 'none',
					'transitionOut'	: 'none',
					'title'			: this.title,
					'width'		: 680,
					'height'		: 495,
					'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
					'type'			: 'swf',
					'swf'			: {
					   	 'wmode'		: 'transparent',
						'allowfullscreen'	: 'true'
					}
				});
		
			return false;
		});
	}
});
