/* 

START jQUERY 

*/
$(document).ready(function(){

	// Set the Copyright text to the current year
	setCopyrightYear ();
	
	//INIT Google Maps
	//loadGMap();
	
	/*
	
	SHOW-HIDE TOGGLE
	
	 - show-hide is triggered by the "toggler" class	 
	 - show-hide content defaults to open	
	 - show-hide collapsed trigger gets "toggler-closed" class
	 	 
	 */	 
	var toggleSpeed = 1000;
	$(".module h3").click(function(){	
		
		var theModule = $(this).parent().parent().parent();
		var theModuleBody = $(this).parent().parent();
		var theModuleImage = $(theModuleBody).children()[0];
		var theModuleCopy = $(theModuleBody).children()[1];
		
		var openHeight = Math.max($(theModuleImage).height(),$(theModuleCopy).height())	
	
		// a module with googlmap class doesn't open
		if ((!$(theModule).hasClass("googlemap")) && (!$(theModule).hasClass("callout"))) {
		
			if ($(theModule).hasClass("module-closed")) {
		
				$(theModuleBody).animate({ 
				   height: openHeight + "px"
				 }, toggleSpeed);
				 
				 $(theModule).removeClass("module-closed");			 
				
				// if the module is type "neighborhood" hide the text in the strong tag when moule is open
				 if ($(theModule).hasClass("neighborhood")) {
					$(this).children()[0].style.visibility="hidden";
				 }	
							
				 
			} else {
		
				$(theModuleBody).animate({ 
				   height: "18px"
				 }, toggleSpeed);
		
				$(theModule).addClass("module-closed");			 
				
				// if the module is type "neighborhood" show the text in the strong tag when moule is open
				 if ($(theModule).hasClass("neighborhood")) {
					$(this).children()[0].style.visibility="visible";
				 }
			
			}	
		}	
			
	});	
	
 });

//Show the current year in the Copyright
function setCopyrightYear () {
	var year = new Date().getFullYear();
	document.getElementById("year").innerHTML=year;	
}


