/*
 * Registers listeners for the map and weather buttons on the hub page.
 * Because the school name and address are not available client-side, the calling page (hub page) must declare the following variables:
 * 		- SCHOOL_NAME
 * 		- SCHOOL_ADDRESS
 * 		- SCHOOL_ZIP
 * This allows the calling code to use server-side substitution to pass these values to the client-side.
 * 
 * By using live to register listener, we ensure that map and weather buttons are available while the page is still loading.
 */

jQuery('.googleMapLink').live('click', function(e) {
	e.preventDefault();
	var queryString = 'address=' + escape(SCHOOL_ADDRESS) + "&title=" + escape('Map for ' + SCHOOL_NAME);
	var GoogleMapWindow = window.open('/school/googlemap.jsp?' + queryString, 'GoogleMap', 'width=500, height=500, status=0, location=0, toolbar=0');
	GoogleMapWindow.moveTo(200, 300);
});

jQuery('.weatherLink').live('click', function(e) {
	e.preventDefault();
	var queryString = 'zip=' + escape(SCHOOL_ZIP) + "&title=" + escape('Weather at ' + SCHOOL_NAME);
	var WeatherWindow = window.open('/school/weather.jsp?' + queryString, 'Weather', 'width=300, height=250, status=0, location=0, toolbar=0');
	WeatherWindow.moveTo(760, 300);
});


jQuery(document).ready(function() {

	jQuery('.googleMapLink').hover(
		function() { // mouseover
			jQuery(this).addClass('googleMapLink_rollover');
		},
		function() { // mouseexit
			jQuery(this).removeClass('googleMapLink_rollover');
		}
	);

	jQuery('.weatherLink').hover(
		function() { // mouseover
			jQuery(this).addClass('weatherLink_rollover');
		},
		function() { // mouseexit
			jQuery(this).removeClass('weatherLink_rollover');
		}
	);

});
