
  
  $(document).ready(function(){
$('#eb5RegionalCenters').parents('#midColContent').find('#print').hide();

$('#eb5RegionalCenters').dataTable( {

	"sDom":  'T<"clear"><"top1"lf><"clear"><"top2"ip><"clear">rt<"bottom1"ip><"clear">',
		"oTableTools": {
				"aButtons": [
					{
						"sExtends": "print",
						"sButtonText": "Printer Friendly",
						"sToolTip": "Printer Friendly",
						"sInfo":  "<h6>Print view</h6><p>To print, press the print icon at the top of your browser.<br/><br/>To return to the Web page, press the escape [ESC] key.</p>"
					}
				]
			}



	} );


$('#ToolTables_eb5RegionalCenters_0').attr('title','Printer Friendly');
$('#ToolTables_eb5RegionalCenters_0').attr('tabindex','0'); 
$('#eb5RegionalCenters_length select').attr('title','Select the number of entries to display');
$('#eb5RegionalCenters_length select').attr('tabindex','0');
$('#paginate_enabled_previous').attr('tabindex','0');
$('#paginate_disabled_previous').attr('tabindex','0');
$('#paginate_enabled_next').attr('tabindex','0');
$('#paginate_disabled_next').attr('tabindex','0');

$('.oneColContent').parents('#content').find('#print').hide();
$('.oneColContent').parents('#content').addClass('oneColumnLayout');

	// Fix for msie opacity and fade issue.  Only works if 
	// font is not bold.
	
	  jQuery.fn.fadeIn = function(speed, callback) { 
	      return this.animate({opacity: 'show'}, speed, function() { 
	          if (jQuery.browser.msie)  
	              this.style.removeAttribute('filter');  
	          if (jQuery.isFunction(callback)) 
	              callback();  
	      }); 
	  }; 
	   
	  jQuery.fn.fadeOut = function(speed, callback) { 
	      return this.animate({opacity: 'hide'}, speed, function() { 
	          if (jQuery.browser.msie)  
	              this.style.removeAttribute('filter');  
	          if (jQuery.isFunction(callback)) 
	              callback();  
	      }); 
	  }; 
	   
	  jQuery.fn.fadeTo = function(speed,to,callback) { 
	      return this.animate({opacity: to}, speed, function() { 
	          if (to == 1 && jQuery.browser.msie)  
	              this.style.removeAttribute('filter');  
	          if (jQuery.isFunction(callback)) 
	              callback();  
	      }); 
	  }; 
 	$.fn.fixImageSizes = function() {   
	
	  return this.each(function () {

  				var obj = $(this);
				var heightAttr = obj.attr('height');
				var widthAttr = obj.attr('width');

				if ((heightAttr=='1') && (widthAttr=='1')){
     				obj.removeAttr('height');
					obj.removeAttr('width');
				
        		}
								 });
 
 			};   

			$('#leftCol .sidebar').css('z-index',0);
			$('#mainContent img').each(function (i) { $(this).fixImageSizes(); });
			$('#slideshow-nav').css('display','block');
			
			
			// Begin slideshow play/pause click event
			$('#slideshow-playpause img').click(function() { 
    			
				if($(this).hasClass('pause')) {
				$('#slideshow-playpause img').removeClass('pause');
				$('#slideshow-playpause img').addClass('play');
				$(this).attr('src','/images/slideshow/mannav-play.jpg');
				$(this).attr('alt','Play');
				$('#slideshow').cycle('pause');
									}
				else {
				$('#slideshow-playpause img').removeClass('play');
				$('#slideshow-playpause img').addClass('pause');
				$(this).attr('src','/images/slideshow/mannav-pause.jpg');
				$(this).attr('alt','Pause');
				$('#slideshow').cycle('resume');
				}
			});
			
			// Rotate through slide index and update button images for active or inactive link
			$.fn.cycle.updateActivePagerLink = function(pager, currSlideIndex) { 
    			$(pager).find('li').removeClass('activeLI') 
        		.filter('li:eq('+currSlideIndex+')').addClass('activeLI'); 
				
			};
			
			//Set up rotating image slideshow with options
			 $('#slideshow').cycle({
				fx: 'fade', 
				speed:2000,
				timeout: 6000,
				sync: 1,
				pager: '#button-nav',
				prev:   '#slideshow-prev', 
    			next:   '#slideshow-fwd', 
    				// callback fn that creates a button image to use as pager anchor 
    			pagerAnchorBuilder: function(idx, slide) { 
        			return '<li><a href="#" class="nav-idx" rel="slide"></a></li>'; 
    			} 
				
	 		});
			 
			//Set up headline ticker with options
			 $('#ticker-detail').cycle({
				fx: 'fade',
				speed: 2000,
				continuous:0,
				timeout: 9000,
				pause: 1,
				sync: 0,
				cleartype:true,
				cleartypeNoBg:true
				
	 		});
			 
			 
			 
			 // Set up Transformation left and secondary navigation items for active/inactive states
			 $('.navGroupItems li a img.active').hide();
			 $('.navGroupItems li a img.inactive').show();
			 $('.navGroupItems li a.selected img.inactive').hide();
			 $('.navGroupItems li a.selected img.active').show();
			 
			 $('.navGroupItems li').hover(function() {
					$(this).find('img.active').show();
					$(this).find('img.inactive').hide();
					
					
												   },
				function() {
					$(this).find('img.active').hide();
					$(this).find('img.inactive').show();
					$('.navGroupItems li a.selected img.inactive').hide();
			 		$('.navGroupItems li a.selected img.active').show();
					
					
												   }
												   
												   );
			 
			 


			 
			 $('.secondaryNavRow li a img.active').hide();
			 $('.secondaryNavRow li a img.inactive').show();
			 $('.secondaryNavRow li a.selected img.inactive').hide();
			 $('.secondaryNavRow li a.selected img.active').show();
			 $('.secondaryNavRow li').hover(function() {
					$(this).find('img.active').show();
					$(this).find('img.inactive').hide();
					
					
												   },
				function() {
					$(this).find('img.active').hide();
					$(this).find('img.inactive').show();
					$('.secondaryNavRow li a.selected img.inactive').hide();
			 		$('.secondaryNavRow li a.selected img.active').show();
					
					
												   }
												   
												   );
			 
			 // Add support for keyboard tabbing through navigation items
			 
			  $('.navGroupItems li a').focus(function() {
					$(this).parents('li').find('img.active').show();
					$(this).parents('li').find('img.inactive').hide();
					
					
												   });
			   $('.navGroupItems li a').blur(function() {
					$(this).parents('li').find('img.inactive').show();
					$(this).parents('li').find('img.active').hide();
					
					
												   });
				
				$('.secondaryNavRow li a').focus(function() {
					$(this).parents('li').find('img.active').show();
					$(this).parents('li').find('img.inactive').hide();
					
					
												   });
			   $('.secondaryNavRow li a').blur(function() {
					$(this).parents('li').find('img.inactive').show();
					$(this).parents('li').find('img.active').hide();
					
					
												   });

	// Multimedia page playlist - add support for current playlist item as 
	// well as displaying current title and description in the Now Playing area.
	
	$('#playlist li:first').addClass('current');
	$('#bodyFormatting #video-desc-list li:first').addClass('current');
	
	$('#playlist ul li').click(function() {  
		$('#playlist').find('li.current').removeClass('current');		
		$(this).addClass('current');
		var listItem = $('#playlist ul li.current');
	
		$('#video-desc-list').find('li.current').removeClass('current');
		$('#video-desc-list li:eq(' + $('#playlist ul li').index(listItem) +')').addClass('current');
		
	});
	
	// Add keyboarding support to playlist items.
	$('#playlist li').keydown(function(event) {  
	   if (event.keyCode == 13) {
		$('#playlist').find('li.current').removeClass('current');		
		$(this).addClass('current');
		var listItem = $('#playlist ul li.current');
	
		$('#video-desc-list').find('li.current').removeClass('current');
		$('#video-desc-list li:eq(' + $('#playlist ul li').index(listItem) +')').addClass('current');
		}
		
	});
		
						  

								
		//Get the existing alt text for the image gallery images to use later
					 var altTextArray = [];
			
			 $('#photos li').each(function(index) {
    						var altText = $(this).find('img').attr('alt');
							
							altTextArray.push(altText);
										   });
				 
			 
		   Galleria.loadTheme('/javascript/lib/galleria/src/themes/classic/galleria.classic.js');
				 $('ul.gallery_demo2').galleria({ 
				 
        										  height:550,
												  width:535,
												  show:0,
												  insert:'#main-image',
				 								  show_imagenav:false,
												  show_counter:false,
												  keepSource: true,
												  show_info:true,
												  carousel_steps:1,
												  thumb_crop:true,
												  thumb_fit:false,
												  extend: function(options) {
													  
													$('.galleria-thumbnails div').each(function(i) {
															
																$(this).children('img').attr('alt',altTextArray[i]);
																										});
													
					
													  
													  
												$('.galleria-info-text').mouseenter(function(){
														return false;
														
													});
													
												$('.galleria-info-text').mouseleave(function(e){
														var related = e.relatedTarget;
														 
														 if (related != null) {
														 	var rClass = e.relatedTarget.className;
															
														 	if (rClass == '' || rClass=='galleria-stage') {
														 		return false;
														 	}
														 	else {
														 		$('.galleria-info-text').slideUp(800, function(e){
																	
														 		});
																return false;
														 	}
														 	return false;
														 }
														
													});
													 
												  	$('.galleria-stage').mouseenter(function(){
														$('.galleria-info-text').slideDown(800,function(e){	
														});
														
														return false;
														
													});
													$('.galleria-stage').mouseleave(function(e){
														 var related = e.relatedTarget;
														 
														 if (related != null) {
														 	var rClass = e.relatedTarget.className;
														 	if (rClass === 'galleria-info-text' || rClass === 'galleria-info-title' || rClass === 'galleria-info-description' || rClass === 'galleria-info-author' || rClass === 'galleria-info') {
														 		$('galleria-info-text').triggerHandler('mouseleave');
														 	}
														 	else {
														 		$('.galleria-info-text').slideUp(800, function(e){
																	
														 		});
																return false;
														 	}
														 	return false;
														 }
														
													});													
													

													
													
										
													
												this.attachKeyboard({
    													left: this.prev, // applies the native prev() function
    													right: this.next,
    													up: function() {
        													// custom up action
        													$('.galleria-stage').triggerHandler('mouseenter');
    													},
														
    													13: function() {
        													// start playing when return (keyCode 13) is pressed:
        													
    														}
														});
												 
												 		  $('.galleria-thumbnails-list .galleria-thumbnails .galleria-image').eq(0).addClass('active');
														  $('.galleria-thumbnails-list .galleria-thumbnails .galleria-image').wrap('<div class="pointer" />');														  
														  $('.galleria-thumbnails-list .galleria-thumbnails .pointer .galleria-image.active').parent().addClass('active');
														  $('.galleria-thumbnails-list .galleria-thumbnails .pointer').click(function(e) {
																	$(this).parent().find('.active').removeClass('active');
																	$(this).addClass('active');
																																			 
																																			 });
														  
												  },
												  data_config: function(img) {
        											return {
            										title: $(img).closest('li').find('.panel-overlay').children('h2').html(), 
            										description: $(img).closest('li').find('.panel-overlay').children('.desc').html() 
        											};
    									}


												  }); // activates the gallery
								
 				var $recordInfo = $('#recordSearchInfo').val();
				
			if($recordInfo != null) {
			var foiaRecordLength = $recordInfo.length;
			var maxRecordLength = 1024;
			var currentRecordLength = 1024;

			if(foiaRecordLength > 0 && foiaRecordLength <= maxRecordLength ) {
			currentRecordLength = maxRecordLength - foiaRecordLength;
		
		}
				else if(foiaRecordLength > maxRecordLength) {
					var truncated = $('#recordSearchInfo').text().substring(0,maxRecordLength);
					$('#recordSearchInfo').val(truncated);
					currentRecordLength = 0;
				}
				$('#textLimit').val(currentRecordLength);
				}		
		   var maxHeight = $('#content').height();
			  if(maxHeight < 400) { maxHeight=400;}	   
		   $('#leftCol .sidebar').height(maxHeight);
		   $('#rightCol .sidebar').height(maxHeight);
		   $('#rightColSub .sidebar').height(maxHeight);	
		   
				
	

});

function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);

// otherwise, update 'characters left' counter
else 
cntfield.value = maxlimit - field.value.length;
}

