$.fn.pause = function(duration) {
	$(this).animate({ dummy: 1 }, duration);
	return this;
};

$(function() {
	activateDropdowns();
	activateCollapsibles();
});

activateDropdowns = function() {
	$("#nav-global ul li ul").each(function() {
		$(this).parent().addClass("dropdown").find("a:first")
		.click(function(e) {
			e.preventDefault();
			$(this).parent().toggleClass("open").find("ul").toggle();
		});
	});
}

activateCollapsibles = function() {
	$("#product div h2").click(function() {
		/*$("#product div .inside").slideUp(100, function() {
			$(this).parent().removeClass("open");
		});*/
		if ($(this).parent().hasClass("open")) {
			$(this).parent().find(".inside").slideUp(200, function() {
				$(this).parent().removeClass("open");
			});
		}
		else {
			$(this).parent().addClass("open");
			$(this).parent().find(".inside").slideDown(200);
		}
	});
}

createProductMap = function(containerId, latitude, longitude){
	map = new GMap2(document.getElementById(containerId));

	var icon = new GIcon();
	icon.image = '/images/icons/map_icon_bg.png';
	icon.iconSize = new GSize(32, 24);
	icon.iconAnchor = new GPoint(16, 24);
	icon.infoWindowAnchor = new GPoint(25, 7);
	map.clearOverlays();

	var bounds = new GLatLngBounds();
	var point = new GLatLng(latitude,longitude);
	
	opts = {
	"icon": icon,
	"clickable": true,
	"labelText": "<span></span>",
		"title": "",
		"labelOffset": new GSize(-16, -22),
		"labelClass": "marker-label"
	};
	var marker = new LabeledMarker(point, opts);

	map.addOverlay(marker);
	bounds.extend(point);

	var zoomLevel = 15;
	if (map.getBoundsZoomLevel(bounds) < zoomLevel) { zoomLevel = map.getBoundsZoomLevel(bounds) }
	map.setCenter(bounds.getCenter(), zoomLevel);
	var customUI = map.getDefaultUI();
	customUI.controls.scalecontrol = false;
	customUI.zoom.scrollwheel = false;
	map.setUI(customUI);
}