$(document).ready(function(){
var isHovering = false;
var focusedPackage = "";
var btnHeights = (140 + 2) *3; //heights of buttons to the right and margins between
	$(".packageDiv").hide();
	$(".packageLink").css({opacity:.85});
	$("#whereBanner").css({position:"absolute"});
	$(".packageDiv").css({position:"absolute"});
	
//SFBA Specific
	var normalHeight = $("#rfp_btn").css("height");
/*
	$("#wrapper").hover(
	function(){
		isHovering = true;
	},
	function(){
		if(isHovering = true){
			if($("#whereBanner").css("display") != "block"){
				$(".packageLink").animate({opacity: .85}, 200 );
				$(".packageDiv").fadeOut('fast',function(){
					$("#whereBanner").show();
				});
			}
		}
	});
*/		
	$(".packageLink").hoverIntent(
		function(){
			var link = "#" + $(this).attr("id").replace(/Link/g, "");
			if($(link).attr("id") != focusedPackage){
				$(this).animate({opacity: 1},500);
			}
		},
		function(){
			var link = "#" + $(this).attr("id").replace(/Link/g, "");
			if($(link).attr("id") != focusedPackage){
				$(this).css({opacity: .85});
			}
		}
	);
	$("#rfp_btn").hoverIntent(
		loadWhere,
		function(){
			
		}
	);
	$("#header").hoverIntent(
		loadWhere,
		function(){
			
		}
	);
/*
	$("#footer").hoverIntent(
		loadWhere,
		function(){
			
		}
	);
*/	
	function loadWhere(){
			$("#rfp_btn").animate({height:normalHeight});
			$(".packageDiv").hide();
			$(".packageLink").css({opacity: .85});
			$("#whereBanner").fadeIn('fast', function(){focusedPackage = "flashBanner";});
	}

	$(".packageLink").click(
		function(){
			return false;
		});
/*		
	$(".packageLink").click(
		function(){
			var link = $(this).attr("id").replace(/Link/g, "");
			if(link != focusedPackage){
				$(".packageLink").not($(this)).animate({opacity: .85}, 200 );
				$(this).css("opacity",1);
				focusedPackage = link;
				$(".packageDiv").hide();
				$("#" + link).fadeIn('fast', function(){focusedPackage = link;});
				$("#whereBanner").hide();
				return false;
			}
		}
	);
*/
	$(".packageLink").hoverIntent(
		function(){
			var link = $(this).attr("id").replace(/Link/g, "");
			if(link != focusedPackage){
				$(".packageLink").not($(this)).css({opacity: .85});
				$(this).css("opacity",1);
				$(".packageDiv").hide();
				if(link == "package01"){
					$("#rfp_btn").animate({height:$("#package01").height() - btnHeights});
				}
				if(link == "package02"){
					$("#rfp_btn").animate({height:$("#package02").height() - btnHeights});
				}
				if(link == "package03"){
					$("#rfp_btn").animate({height:$("#package03").height() - btnHeights});
				}
				$("#" + link).fadeIn('fast', function(){focusedPackage = link;});
				$("#whereBanner").hide();
				return false;
			}
		},
		function(){
			return false;
		}
	
	);

});
