$(function(){
	$(".popup").hide();
	$(".overlay").overlay({
		expose: {
			color: '#000',
			loadSpeed: 200,
			opacity: 0.7
		}
	});
	//$(".hide:not(:eq(0))").hide();
	$(".hide").hide();
	$(".hide:eq(0)").show();
	$("#local_nav a").click(
		function(){
			var id = $(this).attr("href");
			$(".hide").hide();
			$(id).fadeIn();
			//document.location = id;
			return false;
		}
	);
	
	//hide initial content
	hideAdditionalContent();
	//$("#schedule_month").hide();
	//alternate entry background colors
	$("#schedule_month td:not(.empty):odd").addClass("odd");
	$("#schedule_week .day").find(".event:odd").addClass("odd");
	//show .additional_content on click
	
	$(".schedule .event").live("click",
		function(event){
			var target = $(event.target);
			if(!target.is("a")){
				var obj = $(this).find(".additional_content");
				if(obj.is(":visible")){
					obj.hide();
				} else {
					obj.show();	
				}
			}
		}
	);
	
	//swap calendar display
	$("#schedule_options a.change").click(
		function(){
			var obj = $(this);
			$(".schedule .additional_content").hide();
			$("#schedule_day").hide();
			if(obj.hasClass('view-month')){
				obj.removeClass('view-month');
				obj.addClass('view-week');
				obj.text("View Weekly Calendar");
				$("#schedule_week").hide();
				$("#schedule_month").show();
				$("#date_options_week").hide();
				$("#date_options_month").show();
			} else {
				obj.removeClass('view-week');
				obj.addClass('view-month');	
				obj.text("View Monthly Calendar");
				$("#schedule_week").show();
				$("#schedule_month").hide();
				$("#date_options_month").hide();
				$("#date_options_week").show();
			}
			obj.blur();
			return false;
		}
	);
	//print schedule
	$("#schedule_options a.print").click(
		function(){
			var obj = $(this);
			var url = obj.attr("href");
			window.open(url,"window","width=600,height=600,scrollbars=1");			
			return false;
		}
	);

	//show single day calendar
	$("#schedule_month a").click(
		function(){
			$("#schedule_day").show("fast");
			var url = $(this).attr('href');
			$("#schedule_day").show();
			$("#schedule_day").load(url, postDayLoad);
			
			return false;						 
		}
	);
	function postDayLoad() {
		$("#schedule_day .day").find(".event:odd").addClass("odd");
		hideAdditionalContent();
	}
	//hide single day calendar
	$("#schedule_day span.close").live("click",
		function(){
			hideAdditionalContent();
			$("#schedule_day").hide("fast");	
		}
	);
	//hide .additional_content
	function hideAdditionalContent(){
		$(".schedule .additional_content").hide();	
	}
});
	
/*
 * jquery.tools 1.1.0 - The missing UI library for the Web
 * 
 * 
 * Copyright (c) 2009 Tero Piirainen
 * http://flowplayer.org/tools/
 *
 * Dual licensed under MIT and GPL 2+ licenses
 * http://www.opensource.org/licenses
 * 
 * -----
 * 
 * File generated: Thu Sep 03 13:35:13 GMT+00:00 2009
 */
(function(c){c.tools=c.tools||{};c.tools.overlay={version:"1.1.0",addEffect:function(e,f,g){b[e]=[f,g]},conf:{top:"10%",left:"center",absolute:false,speed:"normal",closeSpeed:"fast",effect:"default",close:null,oneInstance:true,closeOnClick:true,closeOnEsc:true,api:false,expose:null,target:null}};var b={};c.tools.overlay.addEffect("default",function(e){this.getOverlay().fadeIn(this.getConf().speed,e)},function(e){this.getOverlay().fadeOut(this.getConf().closeSpeed,e)});var d=[];function a(i,f){var p=this,o=c(window),l,k,j,g=f.expose&&c.tools.expose.version;var h=f.target||i.attr("rel");k=h?c(h):null||i;if(i){i.click(function(q){p.load();return q.preventDefault()})}function n(e,q){c(p).bind(e,function(s,r){if(q&&q.call(this)===false&&r){r.proceed=false}});return p}c.each(f,function(e,q){if(c.isFunction(q)){n(e,q)}});c.extend(p,{load:function(){if(p.isOpened()){return p}if(f.oneInstance){c.each(d,function(){this.close()})}var t={proceed:true};c(p).trigger("onBeforeLoad",t);if(!t.proceed){return p}if(g){k.expose().load()}var s=f.top;if(typeof s=="string"){s=parseInt(s,10)/100*o.height()}var r=f.left;var e=k.outerWidth({margin:true});var q=k.outerHeight({margin:true});if(s=="center"){s=Math.max((o.height()-q)/2,0)}if(r=="center"){r=Math.max((o.width()-e)/2,0)}if(!f.absolute){s+=o.scrollTop();r+=o.scrollLeft()}k.css({top:s,left:r,position:"absolute"});b[f.effect][0].call(p,function(){c(p).trigger("onLoad");j=true});if(f.closeOnClick){c(document).bind("click.overlay",function(u){if(!p.isOpened()){return}var v=c(u.target);if(v.parents(k).length>1){return}c.each(d,function(){this.close()})})}if(f.closeOnEsc){c(document).unbind("keydown.overlay").bind("keydown.overlay",function(u){if(u.keyCode==27){c.each(d,function(){this.close()})}})}return p},close:function(){if(!p.isOpened()){return p}var q={proceed:true};c(p).trigger("onBeforeClose",q);if(!q.proceed){return p}b[f.effect][1].call(p,function(){j=false;c(p).trigger("onClose")});var e=true;c.each(d,function(){if(this.isOpened()){e=false}});if(e){c(document).unbind("click.overlay").unbind("keydown.overlay")}return p},getContent:function(){return k},getOverlay:function(){return k},getTrigger:function(){return i},getClosers:function(){return l},isOpened:function(){return j},getConf:function(){return f},onBeforeLoad:function(e){return n("onBeforeLoad",e)},onLoad:function(e){return n("onLoad",e)},onBeforeClose:function(e){return n("onBeforeClose",e)},onClose:function(e){return n("onClose",e)}});if(g){if(typeof f.expose=="string"){f.expose={color:f.expose}}c.extend(f.expose,{api:true,closeOnClick:f.closeOnClick,closeOnEsc:false});var m=k.expose(f.expose);m.onBeforeClose(function(){p.close()});p.onClose(function(){m.close()})}l=k.find(f.close||".close");if(!l.length&&!f.close){l=c('<div class="close"></div>');k.prepend(l)}l.click(function(){p.close()})}c.fn.overlay=function(e){var f=this.eq(typeof e=="number"?e:0).data("overlay");if(f){return f}if(c.isFunction(e)){e={onBeforeLoad:e}}var g=c.extend({},c.tools.overlay.conf);c.extend(true,g,e);this.each(function(){f=new a(c(this),g);d.push(f);c(this).data("overlay",f)});return g.api?f:this}})(jQuery);	

(function(b){b.tools=b.tools||{};b.tools.expose={version:"1.0.4",conf:{maskId:null,loadSpeed:"slow",closeSpeed:"fast",closeOnClick:true,closeOnEsc:true,zIndex:9998,opacity:0.8,color:"#456",api:false}};function a(){if(b.browser.msie){var f=b(document).height(),e=b(window).height();return[window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,f-e<20?e:f]}return[b(window).width(),b(document).height()]}function c(g,h){var e=this,d=null,f=false,i=0;function j(k,l){b(e).bind(k,function(n,m){if(l&&l.call(this)===false&&m){m.proceed=false}});return e}b.each(h,function(k,l){if(b.isFunction(l)){j(k,l)}});b(window).resize(function(){e.fit()});b.extend(this,{getMask:function(){return d},getExposed:function(){return g},getConf:function(){return h},isLoaded:function(){return f},load:function(){if(f){return e}i=g.eq(0).css("zIndex");if(h.maskId){d=b("#"+h.maskId)}if(!d||!d.length){var l=a();d=b("<div/>").css({position:"absolute",top:0,left:0,width:l[0],height:l[1],display:"none",opacity:0,zIndex:h.zIndex});if(h.maskId){d.attr("id",h.maskId)}b("body").append(d);var k=d.css("backgroundColor");if(!k||k=="transparent"||k=="rgba(0, 0, 0, 0)"){d.css("backgroundColor",h.color)}if(h.closeOnEsc){b(document).bind("keydown.unexpose",function(o){if(o.keyCode==27){e.close()}})}if(h.closeOnClick){d.bind("click.unexpose",function(){e.close()})}}var n={proceed:true};b(e).trigger("onBeforeLoad",n);if(!n.proceed){return e}b.each(g,function(){var o=b(this);if(!/relative|absolute|fixed/i.test(o.css("position"))){o.css("position","relative")}});g.css({zIndex:Math.max(h.zIndex+1,i=="auto"?0:i)});var m=d.height();if(!this.isLoaded()){d.css({opacity:0,display:"block"}).fadeTo(h.loadSpeed,h.opacity,function(){if(d.height()!=m){d.css("height",m)}b(e).trigger("onLoad")})}f=true;return e},close:function(){if(!f){return e}var k={proceed:true};b(e).trigger("onBeforeClose",k);if(k.proceed===false){return e}d.fadeOut(h.closeSpeed,function(){b(e).trigger("onClose");g.css({zIndex:b.browser.msie?i:null})});f=false;return e},onBeforeLoad:function(k){return j("onBeforeLoad",k)},onLoad:function(k){return j("onLoad",k)},onBeforeClose:function(k){return j("onBeforeClose",k)},onClose:function(k){return j("onClose",k)},fit:function(){if(d){var k=a();d.css({width:k[0],height:k[1]})}}})}b.fn.expose=function(d){var e=this.eq(typeof d=="number"?d:0).data("expose");if(e){return e}if(typeof d=="string"){d={color:d}}var f=b.extend({},b.tools.expose.conf);b.extend(f,d);this.each(function(){e=new c(b(this),f);b(this).data("expose",e)});return f.api?e:this}})(jQuery);

(function($) {  
	$.fn.googleMap = function(options) {
		var defaults = {
			address: false,
			LatLng: [0, 0],
			zoom: 8, //higher number means zoom in further
			icon: false,
			mapTypeId: google.maps.MapTypeId.ROADMAP 
			//mapTypeId: google.maps.MapTypeId.SATELLITE 
			//mapTypeId: google.maps.MapTypeId.HYBRID 
			//mapTypeId: google.maps.MapTypeId.TERRAIN 
		}
		var options = $.extend(defaults, options);
		return this.each(function() {
			var obj = $(this)[0];
			var map;
			var mapLatLng = new google.maps.LatLng(options.LatLng[0],options.LatLng[1]);
			var mapOptions = {
				zoom: options.zoom,
				center: mapLatLng,
				mapTypeId:options.mapTypeId
			}
			var map = new google.maps.Map(obj,mapOptions);
			if(options.address){
				var geocoder = new google.maps.Geocoder();	
				geocoder.geocode( { 'address': options.address}, function(results, status) {
					if (status == google.maps.GeocoderStatus.OK) {
						if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
							map.set_center(results[0].geometry.location);
							if(options.icon){
								var marker = new google.maps.Marker({
									map: map, 
									position: results[0].geometry.location,
									icon:options.icon
								})
							} else {
								var marker = new google.maps.Marker({
									map: map, 
									position: results[0].geometry.location
								});
							}
						} else {
							alert("No results found");
						}
					} else {
						alert("Geocode was not successful for the following reason: " + status);
					}
				});
			}
		});
	}
})(jQuery);