/*
*	UTILITIES:
*	These are functions that will be used throughout.
*/

$(document).ready(function()	{
	
	/* Banner Img Blow Up */
	$("#fullSize a").click(function(e)	{
		e.preventDefault();
		imgHeight = 556;
		imgWidth = 500;
		
		// Position it in the middle of the screen
		width = $(window).width();
		widthDiff = (width - imgWidth);
		if(widthDiff < 0)	{
			left = 0;
		} else	{
			theWidth = (widthDiff / 2);
			left = (theWidth - 50);
		};
		
		height = $(window).height();
		heightDiff = (height - imgHeight);
		theHeight = (heightDiff / 2);
		
		verticalScroll = $(window).scrollTop();
		/*????
		No idea why this breaks IE:
		 top = (theHeight + verticalScroll);
		????*/
		
		// pop open the cover
		$("#cover").css("height", height);
		$("#cover").css("width", width);
		$("#cover").css("position", "absolute");
		$("#cover").css("top", verticalScroll);
		$("#cover").css("display", "block");
		$("#cover").css("opacity", "0");
		$("#cover").animate({'opacity': ".5"});
		
		setTimeout(function()	{
			$("#fullBooth").css("position", "absolute");
			$("#fullBooth").css("top", verticalScroll + 20);
			$("#fullBooth").css("left", left);
			$("#fullBooth").show("slow");
			$("#fullBoothImg").html('<img src="images/booth_lg.jpg">');
			}, 500);
	});
	
	$("#closeImg").click(function(e)	{
		e.preventDefault();
		$("#fullBooth").hide("slow");
		setTimeout(function()	{
			$("#cover").animate({'opacity': "0"});
			setTimeout(function()	{
				$("#cover").css("display", "none");
				}, 300);
			}, 500);
	});
	
	
	/* map rollovers */
	$("#Map area").mouseover(function(e)	{
		newId = "#" + this.id + '_box';
		
		offset = $(newId).offset();
		
		// fix for rollover that went off page
		if(newId == '#anchor_box')	{
			tempx = e.pageX;
			tempy = e.pageY;
			
			x = (tempx - 320);
			y = tempy;
		} else	{
			x = e.pageX + 15;
			y = e.pageY + 15;
		}			
		$(newId).css("position", "absolute");
		$(newId).css("top", y);				
		$(newId).css("left", x);
		$(newId).show("slow");		
	});
	
	$("#Map area").mouseout(function()	{
		newId = "#" + this.id + '_box';
		$(newId).hide("slow");
	});
	
	/* options */
	$(".optionsLink").toggle(
		function(e)	{
		e.preventDefault();
		newId = "#" + this.id + '_box';
		
		offset = $(newId).offset();
		
		x = e.pageX + 15;
		y = e.pageY + 15;
					
		$(newId).css("position", "absolute");
		$(newId).css("top", y);				
		$(newId).css("left", x);
		$(newId).show("slow");
		$(this).html("- view photo");
		},
		function(e)	{
			e.preventDefault();
			newId = "#" + this.id + '_box';
			$(newId).hide("slow");	
			$(this).html("+ view photo");
		});	
	
	$("#standards").toggle(
		function()	{
		$("#standardsMenu").slideDown();
		$("#standards").html("- Main Standards");
		$("#standardsMenu").css("position", "absolute");	
		},
		function()	{
		$("#standardsMenu").slideUp();
		$("#standards").html("+ Main Standards");
		});
		
});