jQuery(document).ready(function() {
	
	
	
	 
	
	jQuery('input[title!=""]').hint();
	
	jQuery("a.article").fancybox(
			{
				
				'hideOnContentClick'	: false

			}
	);
	
	jQuery("a.youtube").fancybox(
			{	
				'padding'		: 0,
				'type'				: 'iframe',
				'hideOnContentClick': false,
				'autoScale'		: false,
				'width'		: 680,
				'height'		: 495,
				'transitionIn'	: 'none',
				'transitionOut'	: 'none'

			}
	);
	jQuery(function() {
		jQuery("#tree").treeview({
			collapsed: true,
			animated: "medium",
			control:"#sidetreecontrol"			
		});
	});
	
	jQuery(function() {
	    jQuery(".car").jCarouselLite({
	        
	    	auto: 2000,
	        speed: 1000,
	        visible: 6
	       
	    });
	});
	var my_src = '';
	var my_text = '';
	jQuery(".car ul li  img").click(function() {
		   my_src = jQuery(this).attr('src');
		   my_src = my_src.replace('_thumb','_main');
		   my_text = jQuery(this).attr('alt');
		   jQuery("div.top_gallery img,div.img_text").fadeOut('slow', function() {
			   jQuery("div.top_gallery img").attr('src',my_src).fadeIn('slow');
			   jQuery("div.img_text").html(my_text).fadeIn('slow');
		   });
	});
	jQuery(".map_starr").click(function() {
		map_id = (jQuery(this).attr('id')).substr(4);
		
		jQuery.ajax({
		   type: "POST",
		   url: "/pages/map_ajax.php",
		   data: "map_id="+map_id,
		   success: function(msg){
		     
		     jQuery(".map_text").fadeOut('slow', function() {
		    	 jQuery(".map_text").html(msg).fadeIn('slow');
				});
				jQuery("a.article").fancybox(
			{
				
				'hideOnContentClick'	: false

			}
	);
		   }
		 });
	});	
	
	jQuery('.custom_map_title').click(function() {
		  jQuery('.custom_map_options').slideToggle();
	});
	jQuery('.custom_map_options input').click(function() {
		  showFacilities();
	});
	
});


function showFacilities(){
	var allmarkers = [];
	mgr.clearMarkers();
	var bounds = new GLatLngBounds();
	jQuery(".facility_checker:checked").each(function(){
		for (var i in markers_dan[jQuery(this).val()]) {
			var fac = markers_dan[jQuery(this).val()][i];
			if (fac.title!=''){
				jack = jQuery(this).val();
				
								
				var point = new GLatLng(fac.geo_lon, fac.geo_lat);
				var marker = createMarker(point,fac.title,fac.description, fac.id, ''); 
				allmarkers.push(marker);
				bounds.extend(point);
			}
		}
	});
	mgr.addMarkers(allmarkers,0, 17);
	mgr.refresh();
}
