// JavaScript Document
function includeJs(file) { 
	// Handle multiple include attempts 
	if($("script[src='" + file + "']").size() == 0) { 
		var scpt = jQuery('<script></script>').attr('type','text/javascript');
		scpt.attr('src',file);
		$('head').append(scpt);
	} 
} 
jQuery(document).ready(function(){
	
	jQuery("div.people h4").click(function(e) {
		jQuery(this).parent().find("div").addClass("active");
		jQuery("div.people div:not(div.active)").each(function(e){
			if ($(this).attr("display","none")){
				jQuery(this).slideUp('slow');
			}
		});/**/
		
		jQuery("div.active").slideDown('slow').removeClass("active");
		e.preventDefault();
		
	});
	
	jQuery("div.people h4#subsidiary_selector").parent().find("div a").click(function(e) {
		arg = $(this).attr("href").split("/");
		$("#contacts_list").prepend($("#contacts_list li#contact_"+arg[arg.length-1]));
		$("#contact-form #to").val($("#contacts_list li#contact_"+arg[arg.length-1]+" p.email a").html());
		
		e.preventDefault();
	});
	
	jQuery("#financial_calendar form.month_selection #unique_months").live("change",function(e){
		  $.post('/resources/helpers/announcements/get.php', { year: $(this).val() }, function(data) {
				jQuery("#financial_calendar").replaceWith(data);
			});
		  e.preventDefault();
	  });
	
	jQuery("#period").change(function(){
		val = $(this).val();
		val = (val == 'intra')? "-intra/intra" : "/"+val;
		jQuery("#share_chart").attr("src","http://charts.iguana2.com/decmil/chart"+val);
	});
	
	/*jQuery('a[href*=email_alert]').each(function(e){
		includeJs('/resources/js/thickbox-compressed.js');
		$(this).click(function(e){e.preventDefault();});
		$(this).lightBox();
	 });*/
	
});	

