// For IE hover flicker bug
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}
// Hello jQuery!
$(document).ready(function(){
// Home Addison hover
	$(".addison a").mouseover(function() { $(this).parent(this).parent(".addison").addClass("addison_over"); });
	$(".addison a").mouseout(function() { $(this).parent(this).parent(".addison").removeClass("addison_over"); });
// Inline content
	$("#content .cols .linkList:last").addClass("last");
	$(".wide .col:last").addClass("last");
	$(".special .colBox:last").addClass("last");
	$(".colBox .linkList a").append("<span>&nbsp;&gt;&gt;</span>");
	$(".colBox a").mouseover(function() { $(this).parent().parent(".item").addClass("over") });
	$(".colBox a").mouseout(function() { $(this).parent().parent(".item").removeClass("over") });
// News
	$(".newsEvents ul li a").mouseover(function() { $(this).parent(this).parent(this).parent(".newsEvents ul").addClass("over"); });
	$(".newsEvents ul li a").mouseover(function() { $(this).parent(this).parent(".newsEvents ul").addClass("over"); });
	$(".newsEvents ul li a").mouseout(function() { $(this).parent(this).parent(this).parent(".newsEvents ul").removeClass("over"); });
	$(".newsEvents ul li a").mouseout(function() { $(this).parent(this).parent(".newsEvents ul").removeClass("over"); });
	$(".newsEvents ul li img").show();
	$(".newsEvents ul").find(".withImg").append("<span></span>");
// Related links / Tools & Resources
	$(".related li:last-child").addClass("last");
	$(".toolsResources li:last-child").addClass("last");
	$(".related a").append("<span>&nbsp;&raquo;</span>");
	$(".toolsResources a").append("<span>&nbsp;&raquo;</span>");
// Remove the scratchy underline from the last module in the left-hand column
	$("#navigation .module:last-child").addClass("last_module");
// Module hovers
	$(".gallery a").mouseover(function() { $(this).addClass("over"); });
	$(".gallery a").mouseout(function() { $(this).removeClass("over"); });
	$(".messaging a").mouseover(function() { $(this).parent(this).parent(".messaging").addClass("over"); });
	$(".messaging a").mouseout(function() { $(this).parent(this).parent(".messaging").removeClass("over"); });
	$(".timelyContent li").find("img").parent().parent("li").addClass("withImg");
	$(".newsEvents ul li").find("img").parent().parent("ul").addClass("withImg");
	$(".colBoxContent").find("img").parent(".item").addClass("withImg");
	$(".colBox .withImg").append("<span class=\"arrow\">&nbsp;</span>");
	$(".newsEvents li.title").append("<span class=\"arrow\">&nbsp;</span>");
	$(".meet a").mouseover(function() { $(this).parent().parent().addClass("over"); });
	$(".meet a").mouseout(function() { $(this).parent().parent().removeClass("over"); });
// Explore menu
	$(".exploreNav a").mouseover(function(){$(this).addClass("over")});
	$(".exploreNav a").mouseout(function(){$(this).removeClass("over")});
// Student Life Intro
	$(".studentLifeIntro li:eq(0)").addClass("active");
	$(".studentLifeIntro .panel:gt(0)").addClass("noShow");
	$(".studentLifeIntro li a").click(function() {
		var layerCount = $(this).parent().prevAll().length;
		var layerNum = (layerCount + 1)
		$(".studentLifeIntro li").removeClass("active");
		$(this).parent().addClass("active");
		$(".studentLifeIntro .panel").addClass("noShow");
		$(".studentLifeIntro").children(":eq("+layerNum+")").removeClass("noShow");
		return false;
	});
// zebra tables
	$("table").each(function(){
		$("tr:nth-child(odd)").addClass("odd");
	});
// Photos with Captions
	$("img.imageWithCaption").each( function() {
		$(this).wrap("<div class='imageAndCaption'></div>")
		$(this).parent().css("width", $(this).attr("width") + "px")
		$(this).after("<p>"+$(this).attr("alt")+"</p>")
	});
// navDrop
	$(".navDrop").mouseover(function() {$(this).addClass("sfhover")});
	$(".navDrop").mouseout(function() {$(this).removeClass("sfhover")});
// Thickbox Control
	var tbLink = $(".thickbox").attr("href");
	$(".thickbox").attr("href", tbLink + "?KeepThis=true&amp;TB_iframe=true&amp;width=613&amp;height=510");
}); // Bye-bye jQuery!
// The following has to be loaded *after* all images load or it won't report the proper height.
// Structure & styling
 window.onload = function(){
	$(document).ready(function() {
// column height
		var colsHeight = $(".wide .cols").height()
		$(".wide .cols").css({ height:colsHeight+31 });
// Thumbnail shadows
		$(".thumbs img").each(function() {
			var imgWidth = $(this).width();
			if (imgWidth > 68) {$(this).addClass("wide");}
			if (imgWidth < 68) {$(this).addClass("tall");}
		});
	});
}; // end of window.onload
/* Thickbox 3 - One Box To Rule Them All.
 * By Cody Lindley (http://www.codylindley.com)
 * Copyright (c) 2007 cody lindley
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php */
var tb_pathToImage = "../images/modules/tbLoading.gif";
$(document).ready(function(){   
	tb_init('a.thickbox, area.thickbox, input.thickbox');
	imgLoader = new Image();
	imgLoader.src = tb_pathToImage;
});
function tb_init(domChunk){
	$(domChunk).click(function(){
	var t = this.title || this.name || null;
	var a = this.href || this.alt;
	var g = this.rel || false;
	tb_show(t,a,g);
	this.blur();
	return false;
	});
}
function tb_show(caption, url, imageGroup) {
	try {
		if (typeof document.body.style.maxHeight === "undefined") {
			$("body","html").css({height: "100%", width: "100%"});
			$("html").css("overflow","hidden");
			if (document.getElementById("TB_HideSelect") === null) {
				$("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
				$("#TB_overlay").click(tb_remove);
			}
		}else{
			if(document.getElementById("TB_overlay") === null){
				$("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
				$("#TB_overlay").click(tb_remove);
			}
		}
		$("#TB_overlay").addClass("TB_overlayBG");
		if(caption===null){caption="";}
		$("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");
		$('#TB_load').show()
		var baseURL;
	   if(url.indexOf("?")!==-1){
			baseURL = url.substr(0, url.indexOf("?"));
	   }else{ 
	   		baseURL = url;
	   }
	   var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
	   var urlType = baseURL.toLowerCase().match(urlString);
		if(urlType == '.bmp'){//gallery code has been removed
		}else{
			var queryString = url.replace(/^[^\?]+\??/,'');
			var params = tb_parseQuery( queryString );
			TB_WIDTH = (params['width']*1) + 30 || 630;
			TB_HEIGHT = (params['height']*1) + 40 || 440;
			ajaxContentW = TB_WIDTH - 30;
			ajaxContentH = TB_HEIGHT - 45;
			if(url.indexOf('TB_iframe') != -1){	
					urlNoQuery = url.split('TB_');
					$("#TB_iframeContent").remove();
					if(params['modal'] != "true"){
						$("#TB_window").append("<a href='#' id='TB_closeWindowButton' title='Close'>Close Window</a><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' > </iframe>");
					}else{
					$("#TB_overlay").unbind();
						$("#TB_window").append("<iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;'> </iframe>");
					}
			}
			$("#TB_closeWindowButton").click(tb_remove);
				if(url.indexOf('TB_iframe') != -1){
					tb_position();
					if($.browser.safari){
						$("#TB_load").remove();
						$("#TB_window").css({display:"block"});
					}
				}
		}
		if(!params['modal']){
			document.onkeyup = function(e){ 	
				if (e == null) {
					keycode = event.keyCode;
				} else {
					keycode = e.which;
				}
				if(keycode == 27){
					tb_remove();
				}	
			};
		}
	} catch(e) {}
}
function tb_showIframe(){
	$("#TB_load").remove();
	$("#TB_window").css({display:"block"});
}
function tb_remove() {
	$("#TB_closeWindowButton").unbind("click");

	if (typeof document.body.style.maxHeight == "undefined") {
		$("#TB_window").fadeOut(1,function(){$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
	}else{
		$("#TB_overlay").fadeOut(500);
		$("#TB_window").fadeOut(500,function(){$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
	}
	$("#TB_load").remove();
	if (typeof document.body.style.maxHeight == "undefined") {
		$("body","html").css({height: "auto", width: "auto"});
		$("html").css("overflow","");
	}
	document.onkeydown = "";
	document.onkeyup = "";
	return false;
}
function tb_position() {
$("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
	if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) {
		$("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
	}
}
function tb_parseQuery ( query ) {
   var Params = {};
   if ( ! query ) {return Params;}
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;
}
function tb_getPageSize(){
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	arrayPageSize = [w,h];
	return arrayPageSize;
}