/* 
 * main.js 
 * JavaScript for Oklahoma Agritourism Growing Adventure.
 
 * Applies to all pages.
 */

window.addEvent('domready', function(){	
	window.addEvent('resize', function(){
		// resize the footer so green bleeds to bottom
		var winH = window.getSize().y;
		var footTop = $('footer').getPosition().y;
		var footH = winH - footTop - 25;
		if (footH < 95) footH = 95;
		$('footer').setStyle('height', footH);
	});
	window.fireEvent('resize');

	if (hdrSearchBtn = $('hdrSearchBtn')){
		hdrSearchBtn.addEvent('click', function(){
			document.forms.hdrSearchForm.submit();
		});
	}
	
	if (hdrSearchInput = $('hdrSearchInput')){
		hdrSearchInput.addEvent('click', function(){
			if (this.value == 'search agritourism'){
				this.value = '';
			} else {
				this.select();
			}
		});
	}
});


// Includes the Google Map API
function includeGoogleMapAPI(){
	// dev
	//key = 'ABQIAAAAlUR188h4rgkW3-IO0kz5iBTiiY--Xfpv7HDuBUs87krxGKLn2BT3_LVvLwNMyJlaM1vrSkzlN7gojg';
	
	// live
	key = 'ABQIAAAAlUR188h4rgkW3-IO0kz5iBQF3SgaifhIWW0I2267shwJGVjDhhRgVxfDj_SNzF_f4wATkDjecw25tw';
	
	document.writeln('<script type="text/javascript" src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;sensor=false&amp;key=' + key + '"></script>');
}
