$(document).ready(function() {
	
	$("a#homeVideo, a#homeVideo2").fancybox({
		//'hideOnContentClick': true
	});
	

	
	$('.toggleWaypoint').click(function() {
		$.ajax({
			type: "POST",
			url: "request/toggle_waypoint.request.php",
			data: "date=" + $(this).text(),
			success: function(val) {

				if (val != "") {
					var waypoints = val.split(",");
					//$('#home_map .bullet').hide();
					
					$('#home_map .bullet').each(function(index) {
						var wpID = $(this).attr('id').substring(9);
						
						if (in_array(wpID, waypoints)) 
							$(this).show();
						else 
							$(this).hide();
					});
				}
				else 
					$('#home_map .bullet').show();
			}
		});
	});
	
	
	$('#image_menu img').each(function() {
		var height = parseInt($(this).height());
		if (height > 25)
			$(this).height(25);
	});
	
	$('#image_menu ul li a').each(function() {
		function mouseover_evt() { 
		$('#image_menu span.label').text($(this).attr("name"));
		 }
		function mouseout_evt(){
			$('#image_menu span.label').text("");
		}
		
		$(this).mouseover(mouseover_evt);
		$(this).mouseout(mouseout_evt);
	});
	
	$('#content .prompt .close').click(function() {
		$(this).parent().parent().slideUp(1000);
	});
	
	
});


//-------------------------------------------------------------------//

function in_array(value, array) {
	var found = false;
	if (is_array(array)) {
		for (var i in array) {
			if (value == array[i]) {
				found = true;
				break;
			}
		}
	}
	return found;
}

function is_array(obj) {
	if (obj.constructor.toString().indexOf("Array") == -1) 
		return false;
	else 
		return true;
}

