(function($){
	$(function() {
		$("#ts-tcc-slideshow").cycle();
		$("dd").hide();
		$("dt a").hover(function() {
			$("dd:visible").slideUp("slow");
			$(this).parent().next().slideDown("slow");
			return false;
		});
		
		$(".pop").colorbox();
		
		var rotater = function($el) {
			setTimeout($el).cycle()
		};
		
		var delay = 0;
		$("#head-rotator ul").each(function() {
			var list = $(this);
			setTimeout(function() { list.cycle(); }, delay++ * 1250);
		});
		
		$('a[rel*=facebox]').facebox({
			loadingImage : '/site/images/loading.gif',
			closeImage   : '/site/images/closelabel.png'
		});
		
		if($(".course-panel")) {
			$(".course-panel").hide();
			$(".course-list h4").click(function() {
				var $panel = $(this).next(),
					$otherPanels = $panel.siblings(".open"),
					target = this;
					
				$otherPanels.slideUp().removeClass("open");
				$panel.slideToggle(function(){
					if($(target).next().hasClass("open")) {
						$.scrollTo(target, 300);
					}
				}).toggleClass("open");
				
			});
			$(".course-list h4 a").click(function(e) {
				e.preventDefault();
			});
			if(window.location.hash){
				$(window.location.hash).prev().click()
			}
		}
	});


$(function() {
	$("area", "#tcc_map").each(function() {
		$this = $(this);
		ttPosition = { target: 'topRight', tooltip: 'bottomLeft' };
		ttAdjust = { x: 0, y: 0 };
		ttwidth = 350;
		switch($this.attr('alt')) {
			case "#DZ":
				ttwidth = 200;
				ttPosition = { target: 'topMiddle', tooltip: 'bottomLeft' };
				ttAdjust = { x: 30, y: 50 }
				break;
			case "#b":
				ttPosition = { target: 'topRight', tooltip: 'bottomLeft' };
				ttwidth = 400;
				ttAdjust = { x: -95, y: 165 }
				break;
			case "#c":
				ttPosition = { target: 'topLeft', tooltip: 'bottomRight' };
				ttAdjust = { x: 30, y: -20 }
				ttwidth = 450;
				break;
			case "#d":
				ttPosition = { target: 'topLeft', tooltip: 'bottomRight' };
				ttAdjust = { x: 30, y: -20 }
				break;
			case "#e":
				ttPosition = { target: 'topLeft', tooltip: 'bottomRight' };
				ttAdjust = { x: 30, y: -20 }
				break;
			case "#f":
				ttAdjust = { x: -20, y: -8 }
				break;
			case "#g":
				ttwidth = 400;
				ttAdjust = { x: -17, y: -5 }
				break;
			case "#h":
				ttAdjust = { x: -25, y: -5 }
				break;
			case "#b2":
				ttAdjust = { x: 5, y: -2 }
				ttPosition = { target: 'topLeft', tooltip: 'bottomRight' };
				ttwidth = 400;
				break;
			case "#b3":
				ttwidth = 250;
				ttAdjust = { x: 5, y: -2 }
				ttPosition = { target: 'topLeft', tooltip: 'bottomRight' };
				break;
			case "#b4":
				ttwidth = 375;
				ttAdjust = { x: 4, y: -2 }
				ttPosition = { target: 'topLeft', tooltip: 'bottomRight' };
				break;
			case "#b5":
				ttPosition = { target: 'topLeft', tooltip: 'bottomRight' };
				ttAdjust = { x: 4, y: -2 }
				break;
			case "#b6":
				ttAdjust = { x: 5, y: -2 }
				ttPosition = { target: 'topLeft', tooltip: 'bottomRight' };
				break;
			case "#b7":
				ttAdjust = { x: 5, y: -2 }
				ttPosition = { target: 'topLeft', tooltip: 'bottomRight' };
				break;
			case "#b8":
				ttAdjust = { x: 5, y: -2 }
				ttPosition = { target: 'topLeft', tooltip: 'bottomRight' };
				break;
			case "#b9":
				ttAdjust = { x: 5, y: -2 }
				ttPosition = { target: 'topLeft', tooltip: 'bottomRight' };
				break;
			case "#b10":
				ttAdjust = { x: 5, y: -2 }
				ttPosition = { target: 'topLeft', tooltip: 'bottomRight' };
				break;
			case "#b11":
				ttAdjust = { x: 5, y: -2 }
				ttPosition = { target: 'topLeft', tooltip: 'bottomRight' };
				break;
			case "#b12":
				ttwidth = 225;
				ttAdjust = { x: 5, y: -2 }
				ttPosition = { target: 'topLeft', tooltip: 'bottomRight' };
				break;
			case "#b14":
				ttwidth = 300;
				ttAdjust = { x: -2, y: -8 }
				break;
			case "#b15":
				ttwidth = 200;
				break;
			case "#b18":
				ttwidth = 300;
				ttAdjust = { x: -7, y: -3 }
				break;
			case "#b20":
				ttwidth = 250;
				ttAdjust = { x: -10, y: 0 }
				break;
		}
		$this.qtip({
			content: $($this.attr('alt')).html(),
			position: { corner: ttPosition, adjust: ttAdjust },
			style: {
				name: 'dark',
				border: {
					width: 0, 
					radius: 4 }, 
				tip: true,
				width: ttwidth
			},
			show: { delay: 0, effect: { length: 0 } },
			hide: { effect: { length: 0 } }
		});
	});
	/*
	if (GBrowserIsCompatible()) {	
		gmap = new GMap2(document.getElementById("map_canvas"));
		gdir = new GDirections(gmap);//, document.getElementById("text_directions"));
		gmap.setCenter(new GLatLng(35.029715, -78.87394), 13);
		gdir.load("from: Fort Bragg, NC to: 34.952157,-78.688223");
	}*/
});


})(jQuery);
