// JavaScript Document
(function ($) {
  Drupal.behaviors.pdf_newwindow = {
    attach: function(context, settings) {		
		var pdf_match = '.pdf';
		var selector = Drupal.settings.extlink.extClass ? "a:not(." + Drupal.settings.extlink.extClass + ", ." + Drupal.settings.extlink.mailtoClass + ")" : "a";
		
		$(selector, context).each(function(el) {
			try {
				var url = this.href;
				if(url.length - url.indexOf(pdf_match) == pdf_match.length) {
					$(this).click(function(e) {
						e.preventDefault();
						window.open(url);
						
					});
				}
			}
			// IE7 throws errors often when dealing with irregular links, such as:
			// <a href="node/10"></a> Empty tags.
			// <a href="http://user:pass@example.com">example</a> User:pass syntax.
			catch(error) {
				return false;
			}
		});
			

			
    }
  };

})(jQuery);;
// JavaScript Document
(function ($) {
  Drupal.behaviors.scheduleFilter = {
    attach: function(context, settings) {	
		
			var $dialog = $('#schedule-filter-modal',context).dialog({ 
			 //modal: true,
			 autoOpen: false,
			 dialogClass : 'modal',
			 open : function(event, ui) {
				$('input[type=checkbox]:checked',$(this)).each( function() {
								Drupal.behaviors.scheduleFilter.click(this);																								 
					}); 
			 }
			 });
			var $overlay = $('<div class="overlay"></div>');
			$overlay.click(function() {
					$dialog.dialog('close');										
			});
			$dialog.append($overlay);
		
		
			var $courses = $('.courses',context);
			
			$('#schedule-filter-technology',context).click( function(e) {
					e.preventDefault();
					$dialog.dialog('open');
					
			});
			
			$('#schedule-filter-show-all',context).click( function(e) {
				e.preventDefault();
				Drupal.behaviors.scheduleFilter.showAll($courses);
			});
			
			$('#schedule-filter-submit',context).click( function(e) {
				e.preventDefault();
				
				$dialog.dialog('close');
				var selected = Drupal.behaviors.scheduleFilter.getSelected($dialog);
				
				if(selected.length) {
					Drupal.behaviors.scheduleFilter.hideAll($courses);
					Drupal.behaviors.scheduleFilter.showSelected($courses,selected);
				} else {
					//if none were selected, show all
					Drupal.behaviors.scheduleFilter.showAll($courses);
				}
				
			});
		
		
    }
  };
	
	Drupal.behaviors.scheduleFilter.showSelected = function(context,selected) {
		selected.each(function() {
				$('table#' + $(this).attr('id')).show();									 
		});
	}
	
	Drupal.behaviors.scheduleFilter.hideAll = function(context) {
		$('table').hide();
	}
	
	Drupal.behaviors.scheduleFilter.showAll = function(context) {
		$('table').show();
	}
	
	Drupal.behaviors.scheduleFilter.getSelected = function(context) {
		return $('input[type=checkbox]:checked',context);
	}
	
	Drupal.behaviors.scheduleFilter.click = function(elm) {
     var evt = document.createEvent('MouseEvents');
     evt.initMouseEvent('click', true, true, window, 0, 1, 1, 1, 1, false, false, false, false, 0, null);
     elm.dispatchEvent(evt);
	} 

})(jQuery);;
// JavaScript Document
(function ($) {
  Drupal.behaviors.customAccordion = {
    attach: function(context, settings) {		
			var accordion = $('.accordion',context);
			if(accordion.length > 0) {
				accordion.accordion({
				active: false,
				a: false,
				collapsible: true,
				header: 'h2',
				autoHeight: false
				});
			}

			
    }
  };

})(jQuery);;
// JavaScript Document
/* 
 *used to trigger jump to anchor
 *Firefox doesn't not do the jump on page load
 *This could be removed if Firefox were fixed to do the jump
 */
(function ($) {
  Drupal.behaviors.customJump = {
    attach: function(context, settings) {		
			var urllocation = location.href; //find url parameter
			var position = urllocation.indexOf("#");
			if(position != -1){
				//has a #
				window.location.hash = urllocation.substr(position); 
			}

			
    }
  };

})(jQuery);;

