/* Author:
	The Dam of Knowledge http://www.damofknowledge.com
*/

$(function(){
// check for IE
var isIE = $.browser.msie;
var isIE7 = isIE && (parseInt($.browser.version, 10) === 7);
var isIE8 = isIE && (parseInt($.browser.version, 10) === 8);
var isIE9 = isIE && (parseInt($.browser.version, 10) === 9);

// Home slideshow
	$.fn.showdelay = function(){
		var delay = 0
		return this.each(function(){
			$(this).delay(delay).fadeIn(500);
			delay += 4000;
		});
	};
	$('.home #quote img').delay(12500).fadeIn(500);
	$('.home-slideshow').showdelay();

// //autoload external links in new window
	$("a[href^='http:']:not([href*='" + window.location.host + "'])").each(function() {               
		$(this).attr("target", "_blank");
	});
	
	$('a[rel="external"], a[rel="external nofollow"]').click( function() {
		window.open( $(this).attr('href') );
		return false;
	});
		
// disable clicks on empty links in nav
	$('nav a[href="#"]').bind('click', function() {
		this.focus();
		return false;
	});

// allow scrollers in tall content
	//var myScroll;
	/*
	if($('#scrollcontent').length) {
		if (!isIE) {
			$('#scrollcontent').css('overflow-y','auto');
			//myScroll = new iScroll('scrollcontent', { hScrollbar: false, fixedScrollbar: false, bounce:false, scrollbarClass: 'myScrollbar' });
		} else {
			$('#scrollcontent').css('overflow-y','auto');
		}
	}
	*/
	
// fix IE7 dropdowns
	if (isIE7) {
		$('nav > ul > li > ul').each(function(index) {
			//alert(index + ': ' + $(this).text());
			//alert($(this).parent().width());
			var marginFix = $(this).parent().width() + 2;
			$('nav ul li ul:eq('+index+')').css('margin-left',('-' + marginFix + 'px'));
		});
		//$('nav ul li ul').parent().width());
		//css('margin-left','-50px');	
	}

// jquery masonry
/*$(function(){
  $('.ngg-galleryoverview').masonry({
    // options
    itemSelector : '.ngg-gallery-thumbnail-box'
  });
});*/

// colorbox 
	$("a[rel='colorbox']").colorbox({ 
		current:""
	});
	$("area[rel='colorbox']").colorbox({ 
		current:"",
		rel:"colorbox"
	});


if (isIE7 || isIE8 || isIE9) {
	// school colorbox
	$("#link1").colorbox({innerWidth:680, innerHeight:500, iframe:true});
	$("#link2").colorbox({innerWidth:680, innerHeight:500, iframe:true});
	$("#link3").colorbox({innerWidth:680, innerHeight:500, iframe:true});
	$("#link4").colorbox({innerWidth:680, innerHeight:500, iframe:true});
	$("#link5").colorbox({innerWidth:680, innerHeight:500, iframe:true});
	$("#link6").colorbox({innerWidth:680, innerHeight:500, iframe:true});
	$("#link7").colorbox({innerWidth:680, innerHeight:500, iframe:true});
	// watch videos colorbox 
	$("#watch1").colorbox({innerWidth:580, innerHeight:315, iframe:true});
	$("#watch2").colorbox({innerWidth:580, innerHeight:315, iframe:true});
	$("#watch3").colorbox({innerWidth:580, innerHeight:315, iframe:true});
	$("#watch4").colorbox({innerWidth:580, innerHeight:315, iframe:true});
} else {
	// school colorbox
	$("#link1").colorbox({innerWidth:660, innerHeight:500, iframe:true});
	$("#link2").colorbox({innerWidth:660, innerHeight:500, iframe:true});
	$("#link3").colorbox({innerWidth:660, innerHeight:500, iframe:true});
	$("#link4").colorbox({innerWidth:660, innerHeight:500, iframe:true});
	$("#link5").colorbox({innerWidth:660, innerHeight:500, iframe:true});
	$("#link6").colorbox({innerWidth:660, innerHeight:500, iframe:true});
	$("#link7").colorbox({innerWidth:660, innerHeight:500, iframe:true});
	// watch videos colorbox 
	$("#watch1").colorbox({innerWidth:560, innerHeight:315, iframe:true});
	$("#watch2").colorbox({innerWidth:560, innerHeight:315, iframe:true});
	$("#watch3").colorbox({innerWidth:560, innerHeight:315, iframe:true});
	$("#watch4").colorbox({innerWidth:560, innerHeight:315, iframe:true});
}


// tooltips
	$(".ngg-gallery-thumbnail a").each(function(i){
		//$(this).simpletip({ 
			//content: $(this).attr('title'),
			//fixed: false
		//});
		//$(this).append("<span>"+$(this).attr('title')+"</span>");
		$(this).removeAttr('alt');
		$(this).find('img').removeAttr('title').removeAttr('alt');
	}); 
	
// 

});
