

$(document).ready(function()
{
	$(".checkall").click(function()
	{
		var checked_status = this.checked;
		$id = $(this).attr('id');
		$wildcard = "input[@type=checkbox]." + $id;
	
		$($wildcard).each(function()
		{
		this.checked = checked_status;
		});
	});
});

var text_editor, data_source;
var confirm_cancel_message;

$confirm_cancel_message = "You have attempted to cancel this window.  If you have made any changes to the information without clicking the Save button, your changes will be lost.  Are you sure you want to cancel this window?";

$(document).ready(function()
{

	$("a.edit_page").click(function()
	{
		data_source = $(this).attr('data_source');
		
		$("#text_editor_panel").dialog('open'); 

		text_page = $( "#ci_" + data_source ).val();
		$("#text_editor").val( text_page ); 
		
		text_editor = new nicEditor({iconsPath: '/effects/nicEdit/nicEditorIcons.gif', fullPanel:true}).panelInstance("text_editor");

		$("#save_button").hide(); 

	});
});

$(document).ready(function()
{



	$("#text_editor_panel").dialog({
		bgiframe: true,
		autoOpen: false,
		height: 400,
		width: 600,
		modal: true,
		position: '0,0',
		beforeclose: function(event, ui) {
			text_editor.removeInstance('text_editor');
			$("#text_editor").val(' ');
			$("#save_button").show(); 
			},
		buttons: {
				Save: function() {
					text_editor.removeInstance('text_editor');
					$( "#ci_" + data_source ).val($("#text_editor").val( ));
					$(this).dialog('close');
				},
				Cancel: function() {
					confirm ($confirm_cancel_message) && $(this).dialog('close');
				}
			}
		}).parents(".ui-dialog:first").find(".ui-dialog-titlebar-close").hide();

});

//dbg - we need to consolidate this logic somewhere else
$(document).ready(function()
{
		$(".datepicker").datepicker({
			showOn: 'button', 
			buttonImage: '/images/calendar.gif', 
			buttonImageOnly: true
		});
});

$(document).ready(function()
{
	$(function() {
		$( "#whats_happening" ).accordion({ 
			collapsible: true, 
			active: false,
			autoHeight: false 
			});
	});
});

