jQuery(document).ready(function() {	
	// Navigation : Global
	$(".global-nav li").hoverIntent({    
		sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		interval: 10, // number = milliseconds for onMouseOver polling interval    
		over: function() {
			$(this).addClass("hover");
			$("ul:first", this).removeClass("hide").animate({opacity: 1}, 200);
		}, 
		timeout: 100, // number = milliseconds delay before onMouseOut    
		out: function() {
			$(this).removeClass("hover");
			$("ul:first", this).addClass("hide").animate({opacity: 0}, 200);
		} 
	});
	
	// Map on contact page
	if(document.getElementById('theMap')) {
		// First create a div to host the map
	    var themap = $("#theMap");

	    // Now initialise the map
	    var mapstraction = new Mapstraction('theMap','google');
	    mapstraction.addControls({
	        zoom: 'large',
	        map_type: true
	    });

	    // Show map centred on Brighton
	    mapstraction.setCenterAndZoom(
	        new LatLonPoint(-33.813, 151.007),
	        14 // Zoom level appropriate for Brighton city centre
	    );

	    // Geocode each hcard and add a marker
	    jQuery('.vcard').each(function() {
	        var hcard = jQuery(this);
	    
	        var streetaddress = hcard.find('.street-address').text();
	        var postcode = hcard.find('.postal-code').text();
	    
	        var geocoder = new MapstractionGeocoder(function(result) {
	            var marker = new Marker(result.point);
	            marker.setInfoBubble(
	                '<div class="bubble">' + hcard.html() + '</div>'
	            );
	            mapstraction.addMarker(marker);
	        }, 'google');    
	        geocoder.geocode({'address': streetaddress + ', ' + postcode});
	    });
	}
});

function printPage() {
	if (window.print) {
		window.print() ;
	} else {
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = "";
	}
}
