$(document).ready(function(){
	$('#datepicker').datepicker({
		inline: true,
		onSelect: function(date) {
		tb_show('Annual Special Events','http://parc1.lacity.org/appldept/calendarme/filedocs/rap/rap_all_calendar.cfm?&page=day&Department=&category=&customCat=&dateStart='+date+'&TB_iframe=true&height=600&width=650')
		} 
	});
	
	//ajax load
	$("#quick-links").load("quicklinks.htm #mainContent");	//load quicklinks
	$("#services-links").load("serviceslinks.htm #mainContent");	//load quicklinks
	$("#facilities").load("includes/facilities.htm");	//load facilities
	//$("#highlights .block-content").load("includes/highlights.htm");	//load facilities
	$("#news_events .block-content").load("includes/news-events.htm");	//load news
	$("#commresources .block-content").load("includes/commresources.htm");	//load community resources

	//quicklinks menu
	$("#quick-links,#services-links").hide();
	$("#quick-links-dd,#services-links-dd").attr("href","javascript:void");
	
	function showQuickLinks() {
        	$("#quick-links").fadeIn("300");
			$("#quick-links-arrow").css("background-position","160px 48px");
			hideServiceLinks();
	}
	function showServiceLinks() {
        	$("#services-links").fadeIn("300");
			$("#services-links-arrow").css("background-position","160px 48px");
			hideQuickLinks();
	}
	function hideServiceLinks() {
			$("#services-links").slideUp("fast");
			$("#services-links-arrow").css("background-position","192px 48px");
			$("#services-links-dd").css("color","#fff");
	}
	function hideQuickLinks() {
			$("#quick-links").slideUp("fast");
			$("#quick-links-arrow").css("background-position","192px 48px");
			$("#quick-links-dd").css("color","#fff");
	}

	$("#quick-links-dd").click(function () {
 		if ($("#quick-links").is(":hidden")) {
			showQuickLinks();

		} else {
			hideQuickLinks();
		}
	});
	$("#services-links-dd").click(function () {
 		if ($("#services-links").is(":hidden")) {
			showServiceLinks();
		} else {
			hideServiceLinks();
		}
	});

	
	var mnuTimeout;
   $("#quick-links-dd,#quick-links").hover(function () {
       clearTimeout(mnuTimeout);
       //showQuickLinks();
   }, function() {  mnuTimeout = setTimeout(hideQuickLinks,500) });
   $("#services-links-dd,#services-links").hover(function () {
       clearTimeout(mnuTimeout);
       //showServiceLinks();
   }, function() {  mnuTimeout = setTimeout(hideServiceLinks,500) });
   
   //footer
   //$("#footer").html('<a href="http://www.laparks.org/disclaimer.htm">Disclaimer</a> || <a href="http://www.laparks.org/policies.htm">Privacy Policy</a> || <a href="http://www.laparks.org/contact.htm">Contact Us</a> <br /> &copy; 2011 City of Los Angeles Department of Recreation and Parks')
});


function getAddress(address,radius,filter) {
	  geocoder = new GClientGeocoder();
	  
	  if(address == 0 ) { alert("Please enter your address or zip code") }
      else if (geocoder) { geocoder.getLocations( address, function(response) {
             if (!response || response.Status.code != 200) { alert("Sorry, we were unable to geocode that address"); } 
		    else { 
				place = response.Placemark[0];
				point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
				window.location.href = 'http://raponline.lacity.org/maplocator/?lng='+point.lng()+'&lat='+point.lat()+'&radius=' + radius + '&filter=' + filter + '&address=' + escape(place.address); 
			} 
			
		});
      }
    }
function checkFilter() {
	var cfRadius = document.getElementById('radius');
	if(document.getElementById('filter').value == "ca") {
		cfRadius.disabled=true;
		cfRadius.options[1].selected = true;
		cfRadius.options[1].text = "500";
		cfRadius.options[1].value = "500";
	} else {
		cfRadius.disabled=false;
		cfRadius.options[1].text = "10";
		cfRadius.options[1].value = "10";
	}
}
