$( function() {
	
	if( $( "#gallery" ).length > 0 ) {
		$( "#gallery a" ).lightBox();
	}
	if( $( "#flickr-images" ).length > 0 ) {
		$( "#flickr-images a" ).lightBox();
	}

	$( "#submit_msg" ).click( function() {
		$( "#submit_status" ).show();
		$( "#submit_status" ).attr( "class", "loading" );
		$( "#submit_status" ).html( "Submitting message..." );
		var data = {
			name : $( "#fld-contact-name" ).val(),
			email : $( "#fld-contact-email" ).val(),
			message : $( "#fld-contact-message" ).val()
		};
		$.post( "_contact.php", data, function( result ) {
			if( result.success ) {
				
				//pageTracker._trackEvent( 'FAQ', 'Submit' );

				$( "#submit_status" ).attr( "class", "success" );
				$( "#submit_status" ).html( result.message );

				$( "#fld-contact-name" ).val( "" );
				$( "#fld-contact-email" ).val( "" );
				$( "#fld-contact-message" ).val( "" );

			} else {
				$( "#submit_status" ).attr( "class", "error" );
				$( "#submit_status" ).html( result.message );
			}
		}, "json" );
	});

	if( $( "#map_canvas" ).length > 0 ) {
		var myLatlng = new google.maps.LatLng( 43.076719, -79.08663 );
		var myOptions = {
		  zoom: 10,
		  center: myLatlng,
		  mapTypeId: google.maps.MapTypeId.ROADMAP
		}
		map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
		
		var schools = [{
			name: "Kate S Durdan Public School",
			address: "6855 Kalar Road, Niagara Falls, L2H 2T3",
			location: new google.maps.LatLng( 43.075619, -79.13563 ) 
		},{ 
			name: "Rose Seaton Public School",
			address: "255 Emerick Avenue, Fort Erie, L2A 2W4",
			location: new google.maps.LatLng( 42.932825, -78.923114 ) 		
		},{ 
			name: "Lincoln Centennial Public School",
			address: "348 Scott Street, St. Catharines, L2N 1J5",
			location: new google.maps.LatLng( 43.187396, -79.233434 ) 		
		},{ 
			name: "Plymouth Public School",
			address: "111 First Street, Welland, L3B 4S1",
			location: new google.maps.LatLng( 42.982979, -79.246268 )		
		}];

		var	marker0 = new google.maps.Marker({ position: schools[0].location, map: map, title: schools[0].name, icon: "http://maps.google.com/mapfiles/kml/pal2/icon10.png" });
		var	infowindow0 = new google.maps.InfoWindow({
			content: "<strong>" + schools[0].name + "</strong><p>" +  schools[0].address + "<br />Monday - Friday, 9:00am to 1:00 pm</p>"
		});

		google.maps.event.addListener( marker0, 'click', function() {				
			infowindow0.open( map, marker0 );
			infowindow1.close();
			infowindow2.close();
			infowindow3.close();
			$( "#katesd" ).addClass( "highlight" );
			$( "#roseseaton" ).removeClass( "highlight" );
			$( "#centennial" ).removeClass( "highlight" );
			$( "#plymouth" ).removeClass( "highlight" );
		});

		var	marker1 = new google.maps.Marker({ position: schools[1].location, map: map, title: schools[1].name, icon: "http://maps.google.com/mapfiles/kml/pal2/icon10.png" });
		var	infowindow1 = new google.maps.InfoWindow({
			content: "<strong>" + schools[1].name + "</strong><p>" +  schools[1].address + "<br />Monday - Friday, 9:00am to 1:00 pm</p>"
		});
		google.maps.event.addListener( marker1, 'click', function() {
			infowindow1.open( map, marker1 );
			infowindow0.close();
			infowindow2.close();
			infowindow3.close();
			$( "#katesd" ).removeClass( "highlight" );
			$( "#roseseaton" ).addClass( "highlight" );
			$( "#centennial" ).removeClass( "highlight" );
			$( "#plymouth" ).removeClass( "highlight" );
		});

		var	marker2 = new google.maps.Marker({ position: schools[2].location, map: map, title: schools[2].name, icon: "http://maps.google.com/mapfiles/kml/pal2/icon10.png" });
		var	infowindow2 = new google.maps.InfoWindow({
			content: "<strong>" + schools[2].name + "</strong><p>" +  schools[2].address + "<br />Monday - Friday, 9:00am to 1:00 pm</p>"
		});
		google.maps.event.addListener( marker2, 'click', function() {		
			infowindow2.open( map, marker2 );
			infowindow1.close();
			infowindow0.close();
			infowindow3.close();
			$( "#katesd" ).removeClass( "highlight" );
			$( "#roseseaton" ).removeClass( "highlight" );
			$( "#centennial" ).addClass( "highlight" );
			$( "#plymouth" ).removeClass( "highlight" );
		});

		var	marker3 = new google.maps.Marker({ position: schools[3].location, map: map, title: schools[3].name, icon: "http://maps.google.com/mapfiles/kml/pal2/icon10.png" });
		var	infowindow3 = new google.maps.InfoWindow({
			content: "<strong>" + schools[3].name + "</strong><p>" +  schools[3].address + "<br />Monday - Friday, 9:00am to 1:00 pm</p>"
		});
		google.maps.event.addListener( marker3, 'click', function() {
			infowindow3.open( map, marker3 );
			infowindow1.close();
			infowindow2.close();
			infowindow0.close();
			$( "#katesd" ).removeClass( "highlight" );
			$( "#roseseaton" ).removeClass( "highlight" );
			$( "#centennial" ).removeClass( "highlight" );
			$( "#plymouth" ).addClass( "highlight" );
		});
	}

});