// Onload When Document Ready
$(document).ready(function() {
  $('a[rel=external]').attr('target', '_blank');
  $('.equalize').equalHeights('true');
  //$(document).stickyfooter();
  $("div.wrapContain").prepend("<div class=\"wrapHead\"><div class=\"wrapCorners R\">&nbsp;</div><div class=\"wrapCorners L\">&nbsp;</div></div>");
  $("div.wrapContain").append("<div class=\"wrapFoot\"><div class=\"wrapCorners R\">&nbsp;</div><div class=\"wrapCorners L\">&nbsp;</div></div>");
  $(".innerPod").prepend("<div class=\"innerHead\"><div class=\"innerCorners R\">&nbsp;</div><div class=\"innerCorners L\">&nbsp;</div></div>");
  $(".innerPod").append("<div class=\"innerFoot\"><div class=\"innerCorners R\">&nbsp;</div><div class=\"innerCorners L\">&nbsp;</div></div>");
  
  $('.caption > img[title], .inline-caption > img[title]').each(function(){
    $(this).after("<p>"+this.title+"</p>");
  });
  
  $('.caption > img, .inline-caption > img').each(function(){
    $(this).parent().css("width", $(this).width());
    $(this).next("p").css("width", $(this).width() - ($(this).next("p").innerWidth() - $(this).next("p").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 ($('#nominateForm').length) {
    $.getScript('/javascript/jquery.validate.min.js',
      function() {
        $('#nominateForm').validate();
      }
    );
  }

  if ($('#newsletterForm').length) {
    $.getScript('/javascript/jquery.validate.min.js',
      function() {
        $('#newsletterForm').validate();
      }
    );
  }

	
	
	
  if ($('a.fancybox').length) {
    $.getScript(
      '/fancybox/jquery.fancybox-1.3.1.pack.js',
      function() {
        $("a.fancybox").fancybox({
          'hideOnContentClick': true,
          'titlePosition'  : 'inside'
        });
      }
    );
  }
  
  if ($('a.vimeo_vid').length) {
    $.getScript('/fancybox/jquery.fancybox-1.3.1.pack.js',
      function() {

				$("a.vimeo_vid").click(function() {
						$.fancybox({
							'padding'		: 0,
							'autoScale'		: false,
							'transitionIn'	: 'none',
							'transitionOut'	: 'none',
							'title'			: this.title,
							'width'			: 640,
							'height'		: 480,
							'href'			: this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'),
							'type'			: 'swf'
						});
				
						return false;
					});

      }
    );
  }
  





  if ($('label.infield').length) {
    $.getScript(
      '/javascript/jquery.infieldlabel.min.js',
      function() {
        $('label.infield').inFieldLabels();
      }
    );
  }
  
});
