jQuery(document).ready(function() {

	// fancybox for nextgen gallery
	$("a.sciffancybox").fancybox({
		'transitionIn' : 'none',
		'transitionOut' : 'none',
		'titlePosition' : 'over'
	});
	
	$('.ngg-galleryoverview').each(function(){
	    var linktoss = $('a.sciffancybox:first', this).attr('href');
	    var relofss = $('a.sciffancybox:first', this).attr('rel');
	    var titleofss = $('a.sciffancybox:first', this).attr('title');
	    $('a.slideshowlink', this).attr('href',linktoss);
	    $('a.slideshowlink', this).attr('rel',relofss);
	    $('a.slideshowlink', this).attr('title',titleofss);
	});
	
	$('.wpcf7-file').attr('size','10');
	
	// remove slideshow link
	$('.slideshowlink').remove();
	
	// open PDFs in a Google Viewer
	$('a[href$="pdf"]').each( function(){
	     $(this).attr('rel','external');
	     hrefOld = $(this).attr('href');
	     $(this).attr({
	          href: ('http://docs.google.com/viewer?url=' + hrefOld)
	     });
	});
	
	// put rel=external on target=_blank links
	$('a').each(function(){
		if ( $(this).attr('target') == '_blank' ) {
			$(this).attr('rel','external');
		}
	});
	
	// correct height of left column if right column is taller
	leftheight = $('.leftcol').height();
	rightheight = $('.rightcol').height();
	if ( rightheight > leftheight ) {
	    $('.leftcol').attr('style','height:'+rightheight+'px;');
	}
	
	// hovers
	$("ul#nav.nav li, .dohover").hover(
		function () {
			$(this).addClass("hover");
		},
			function () {
			$(this).removeClass("hover");
		}
	);
	
	jQuery.fn.exists = function(){return this.length>0;}
	if ( $('.logo2').exists() ) {
	    $('.bigcol').attr('style','margin-bottom:50px');
	}

});

function externalLinks() {
     if (!document.getElementsByTagName) return;
     var anchors = document.getElementsByTagName("a");
     for (var i=0; i<anchors.length; i++) {
          var anchor = anchors[i];
          if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank";
     }
}
window.onload = externalLinks;
