var hoverMap = 0;
var hoverDrop = 0;

function closePopUp() {
	if (hoverMap == 1 && hoverDrop == 1) {
		$("#flashContentContainer div").removeClass("showFlyoutDiv");
	}
}

var hoverMap2 = 0;
var hoverDrop2 = 0;

function closePopUp2() {
	if (hoverMap2 == 1 && hoverDrop2 == 1) {
		$("#servicesContainer img").removeClass("imageOverlay");
		$("#servicesContainer div").removeClass("showImageOverlay");
	}
}

$(document).ready(function() {
	$("#flashContentContainer a").not("#servicesContainer a").not("h3 a").unbind("mouseover");
	$("#flashContentContainer a").not("#servicesContainer a").not("h3 a").mouseover(function() {
		
		// remove current pop up
		$("#flashContentContainer div").removeClass("showFlyoutDiv");
		
		// show pop up
		$("#flyout"+$(this).parent("div").attr("id").substring(10)).addClass("showFlyoutDiv");
		
		hoverMap = 0;
		hoverDrop = 1;
	});
	
	$("#flashContentContainer a").not("#servicesContainer a").not("h3 a").unbind("mouseout");
	$("#flashContentContainer a").not("#servicesContainer a").not("h3 a").mouseout(function() {
		hoverMap = 1;
		
		setTimeout(function() { closePopUp(); }, 200);
	});
	
	$("#flashContentContainer .hidden").hover(
		function () {
			hoverMap = 1;
			hoverDrop = 0;
		},
		function () {
			hoverDrop = 1;
			
			setTimeout(function() { closePopUp(); }, 200);
		}
    );
	
	
	
	$("#servicesContainer div").unbind("mouseover");
	$("#servicesContainer div").mouseover(function() {
		// remove image overlay
		$("#servicesContainer img").removeClass("imageOverlay");
		$(this).children("img").addClass("imageOverlay");
		
		// remove current pop up
		$("#servicesContainer div").removeClass("showImageOverlay");
		// show pop up
		//$("#"+$(this).parent("div").attr("id")+"Flyout").addClass("showImageOverlay");
		$("#"+$(this).attr("id")+"Flyout").addClass("showImageOverlay");
		
		hoverMap2 = 0;
		hoverDrop2 = 1;
	});
	$("#servicesContainer div").unbind("mouseout");
	$("#servicesContainer div").mouseout(function() {
		hoverMap2 = 1;
		
		setTimeout(function() { closePopUp2(); }, 50);
	});
	$("#servicesContainer .hidden").hover(
		function () {
			hoverMap2 = 1;
			hoverDrop2 = 0;
		},
		function () {
			hoverDrop2 = 1;
			
			setTimeout(function() { closePopUp2(); }, 50);
		}
    );
});
