$(document).ready(function(){
	Date.format = 'yyyy-mm-dd';
	$('.datepicker').datePicker({startDate:'1996-01-01'});
	$('.slideShow1').cycle('fade');
	$('.slideShow2').cycle('fade');

	$("#faculty_function").change(function(){
		var func = $(this).attr("value");
	
		if(func == "add")
		{
			document.personaMod.reset();
	
			tinyMCE.execCommand('mceFocus', false, 'paragraph');
			tinyMCE.activeEditor.setContent('');
	
			tinyMCE.execCommand('mceFocus', false, 'education');
			tinyMCE.activeEditor.setContent('');

			tinyMCE.execCommand('mceFocus', false, 'funding');
			tinyMCE.activeEditor.setContent('');
	
			tinyMCE.execCommand('mceFocus', false, 'appointment');
			tinyMCE.activeEditor.setContent('');
			
			tinyMCE.execCommand('mceFocus', false, 'appointmentpast');
			tinyMCE.activeEditor.setContent('');
	
			$("#persona_list").hide();
			$("#information").show();
		}
		else if(func == "edit")
		{
			$("#persona_list").show();
	
			var id = $("option:first", "#persona_list").attr("value");
	
			$.getJSON('/admin/json_persona.php?id=' + id, function(json){
				document.personaMod.idSupport.value = id;
				document.personaMod.department.value = json.department;
				document.personaMod.lastname.value = json.lastname;
				document.personaMod.firstname.value = json.firstname;
				document.personaMod.title.value = json.title;
				document.personaMod.phone.value = json.phone;
				document.personaMod.lab_phone.value = json.lab_phone;
				document.personaMod.fax.value = json.fax;
				document.personaMod.email.value = json.email;
				document.personaMod.link.value = json.link;
				document.personaMod.institution.value = json.institution;
				document.personaMod.pubmed.value = json.pubmed;
				document.personaMod.old_member_picture.value = json.memberpicture;
				document.personaMod.old_lab_picture.value = json.labpicture;
				document.personaMod.labcaption.value = json.labcaption;
				document.personaMod.faculty_type.value = json.type;
				document.personaMod.lab_value.value = json.labgroup_id;

				$("#faculty_list").change();

				tinyMCE.execCommand('mceFocus', false, 'paragraph');
				tinyMCE.activeEditor.setContent(json.paragraph);
			
				tinyMCE.execCommand('mceFocus', false, 'education');
				tinyMCE.activeEditor.setContent(json.education);

				tinyMCE.execCommand('mceFocus', false, 'funding');
				tinyMCE.activeEditor.setContent(json.funding);
			
				tinyMCE.execCommand('mceFocus', false, 'appointment');
				tinyMCE.activeEditor.setContent(json.appointments);
				
				tinyMCE.execCommand('mceFocus', false, 'appointmentpast');
				tinyMCE.activeEditor.setContent(json.appointmentspast);

				tinyMCE.execCommand('mceFocus', false, 'awards');
				tinyMCE.activeEditor.setContent(json.awards);
			
				tinyMCE.execCommand('mceFocus', false, 'education');
			});
	
			$("#information").show();
		}
		else if(func == "remove")
		{
			$("#persona_list").show();
			$("#information").hide();	
		}
	});
	
	$("#persona_list").change(function(){
		var id = $("option:selected", "#persona_list").attr("value");
	
		$.getJSON('/admin/json_persona.php?id=' + id, function(json){
			document.personaMod.idSupport.value = id;
			document.personaMod.department.value = json.department;
			document.personaMod.lastname.value = json.lastname;
			document.personaMod.firstname.value = json.firstname;
			document.personaMod.title.value = json.title;
			document.personaMod.phone.value = json.phone;
			document.personaMod.lab_phone.value = json.lab_phone;
			document.personaMod.fax.value = json.fax;
			document.personaMod.email.value = json.email;
			document.personaMod.link.value = json.link;
			document.personaMod.institution.value = json.institution;
			document.personaMod.pubmed.value = json.pubmed;
			document.personaMod.old_member_picture.value = json.memberpicture;
			document.personaMod.old_lab_picture.value = json.labpicture;
			document.personaMod.labcaption.value = json.labcaption;
			document.personaMod.faculty_type.value = json.type;
			document.personaMod.lab_value.value = json.labgroup_id;

			$("#faculty_list").change();

			tinyMCE.execCommand('mceFocus', false, 'paragraph');
			tinyMCE.activeEditor.setContent(json.paragraph);
			
			tinyMCE.execCommand('mceFocus', false, 'education');
			tinyMCE.activeEditor.setContent(json.education);

			tinyMCE.execCommand('mceFocus', false, 'funding');
			tinyMCE.activeEditor.setContent(json.funding);

			tinyMCE.execCommand('mceFocus', false, 'appointment');
			tinyMCE.activeEditor.setContent(json.appointments);
			
			tinyMCE.execCommand('mceFocus', false, 'appointmentpast');
			tinyMCE.activeEditor.setContent(json.appointmentspast);

			tinyMCE.execCommand('mceFocus', false, 'awards');
			tinyMCE.activeEditor.setContent(json.awards);
			
			tinyMCE.execCommand('mceFocus', false, 'education');
		});
	});

	$("#calendar_function").change(function(){
		var func = $(this).attr("value");
	
		if(func == "add")
		{
			document.calMod.reset();
	
			tinyMCE.execCommand('mceFocus', false, 'info');
			tinyMCE.activeEditor.setContent('');

			tinyMCE.execCommand('mceFocus', false, 'conf_info');
			tinyMCE.activeEditor.setContent('');
	
			$("#cal_list").hide();
			$("#cal_fields").show();
		}
		else if(func == "edit")
		{
			$("#cal_list").show();
	
			var id = $("option:first", "#cal_list").attr("value");
	
			$.getJSON('/admin/json_calendar.php?id=' + id, function(json){
				document.calMod.idSupport.value = id;
				document.calMod.event.value = json.event;

				var date_parts = json.date.split(" ");
				var date = date_parts[0];
				var time_parts = date_parts[1].split(":");
				var hour = time_parts[0];
				var minute = time_parts[1];
				var ampm = "am";

				if(hour > 12)
				{
					hour -= 12;
					ampm = "pm";
				}

				$("option[value='" + hour + "']", "#hour").attr("selected", "selected");	
				$("option[value='" + minute + "']", "#minute").attr("selected", "selected");	
				$("option[value='" + ampm + "']", "#ampm").attr("selected", "selected");
				
				document.calMod.date.value = date;
				document.calMod.location.value = json.location;
				document.calMod.address.value = json.address;
				document.calMod.city.value = json.city;
				document.calMod.state.value = json.state;
				document.calMod.zip.value = json.zip;
				document.calMod.conf.value = json.conf;
				
				if(json.cme_credit == undefined)
				{
					json.cme_credit = '';
				}
				tinyMCE.execCommand('mceFocus', false, 'cme_credit');
				tinyMCE.activeEditor.setContent(json.cme_credit);
				
				if(json.info == undefined)
				{
					json.info = '';
				}
				tinyMCE.execCommand('mceFocus', false, 'info');
				tinyMCE.activeEditor.setContent(json.info);

				if(json.conf_info == undefined)
				{
					json.conf_info = '';
				}
				tinyMCE.execCommand('mceFocus', false, 'conf_info');
				tinyMCE.activeEditor.setContent(json.conf_info);
			});
	
			$("#cal_fields").show();
		}
		else if(func == "remove")
		{
			$("#cal_list").show();
			$("#cal_fields").hide();	
		}
	});
	
	$("#cal_list").change(function(){
		var id = $("option:selected", "#cal_list").attr("value");
	
		$.getJSON('/admin/json_calendar.php?id=' + id, function(json){
			document.calMod.idSupport.value = id;
			document.calMod.event.value = json.event;

			var date_parts = json.date.split(" ");
			var date = date_parts[0];
			var time_parts = date_parts[1].split(":");
			var hour = time_parts[0];
			var minute = time_parts[1];
			var ampm = "am";

			if(hour > 12)
			{
				hour -= 12;
				ampm = "pm";
			}

			$("option[value='" + hour + "']", "#hour").attr("selected", "selected");	
			$("option[value='" + minute + "']", "#minute").attr("selected", "selected");	
			$("option[value='" + ampm + "']", "#ampm").attr("selected", "selected");
				
			document.calMod.date.value = date;
			document.calMod.location.value = json.location;
			document.calMod.address.value = json.address;
			document.calMod.city.value = json.city;
			document.calMod.state.value = json.state;
			document.calMod.zip.value = json.zip;
			document.calMod.conf.value = json.conf;

			if(json.cme_credit == undefined)
			{
				json.cme_credit = '';
			}
			tinyMCE.execCommand('mceFocus', false, 'cme_credit');
			tinyMCE.activeEditor.setContent(json.cme_credit);
			
			if(json.info == undefined)
			{
				json.info = '';
			}
			tinyMCE.execCommand('mceFocus', false, 'info');
			tinyMCE.activeEditor.setContent(json.info);

			if(json.conf_info == undefined)
			{
				json.conf_info = '';
			}
			tinyMCE.execCommand('mceFocus', false, 'conf_info');
			tinyMCE.activeEditor.setContent(json.conf_info);
		});
	});

	$("#employment_function").change(function(){
		var func = $(this).attr("value");
	
		if(func == "add")
		{
			document.empMod.reset();
	
			tinyMCE.activeEditor.setContent('');
	
			$("#emp_list").hide();
			$("#emp_fields").show();
		}
		else if(func == "edit")
		{
			$("#emp_list").show();
	
			var id = $("option:first", "#emp_list").attr("value");

			$.getJSON('/admin/json_employment.php?id=' + id, function(json){
				document.empMod.idSupport.value = json.empID;
				document.empMod.posType.value = json.posType;
				document.empMod.association.value = json.association;
				document.empMod.department.value = json.depts;
				document.empMod.extra.value = json.extra;
				document.empMod.contact.value = json.contact;
				document.empMod.contactEmail.value = json.contactEmail;
				document.empMod.contactPhone.value = json.contactPhone;
				document.empMod.contactFax.value = json.contactFax;
				document.empMod.contactInstitution.value = json.contactInstitution;

				tinyMCE.activeEditor.setContent(json.description);
			});
	
			$("#emp_fields").show();
		}
		else if(func == "remove")
		{
			$("#emp_list").show();
			$("#emp_fields").hide();	
		}
	});
	
	$("#emp_list").change(function(){
		var id = $("option:selected", "#emp_list").attr("value");

		$.getJSON('/admin/json_employment.php?id=' + id, function(json){
			document.empMod.idSupport.value = json.empID;
			document.empMod.posType.value = json.posType;
			document.empMod.association.value = json.association;
			document.empMod.department.value = json.depts;
			document.empMod.extra.value = json.extra;
			document.empMod.contact.value = json.contact;
			document.empMod.contactEmail.value = json.contactEmail;
			document.empMod.contactPhone.value = json.contactPhone;
			document.empMod.contactFax.value = json.contactFax;
			document.empMod.contactInstitution.value = json.contactInstitution;

			tinyMCE.activeEditor.setContent(json.description);
		});
	});

	$("#news_function").change(function(){
		var func = $(this).attr("value");
	
		if(func == "add")
		{
			document.newsMod.reset();
	
			tinyMCE.activeEditor.setContent('');
	
			$("#news_list").hide();
			$("#news_fields").show();
		}
		else if(func == "edit")
		{
			$("#news_list").show();
	
			var id = $("option:first", "#news_list").attr("value");

			$.getJSON('/admin/json_news.php?id=' + id, function(json){
				document.newsMod.idSupport.value = json.id;
				document.newsMod.published.value = json.published;
				document.newsMod.author.value = json.author;
				document.newsMod.where_published.value = json.where_published;
				document.newsMod.title.value = json.title;
				document.newsMod.link.value = json.link;

				tinyMCE.activeEditor.setContent(json.story);
			});
	
			$("#news_fields").show();
		}
		else if(func == "remove")
		{
			$("#news_list").show();
			$("#news_fields").hide();	
		}
		else if(func == "archive")
		{
			$("#news_list").show();
			$("#news_fields").hide();	
		}
	});
	
	$("#news_list").change(function(){
		var id = $("option:selected", "#news_list").attr("value");

		$.getJSON('/admin/json_news.php?id=' + id, function(json){
			document.newsMod.idSupport.value = json.id;
			document.newsMod.published.value = json.published;
			document.newsMod.author.value = json.author;
			document.newsMod.where_published.value = json.where_published;
			document.newsMod.title.value = json.title;
			document.newsMod.link.value = json.link;

			tinyMCE.activeEditor.setContent(json.story);
		});
	});
	
	$("#faculty_list").change(function(){
		var faculty_type = $("option:selected","#faculty_list").attr("value");
		$("#lab_label").empty();
		$("#lab_group").empty();
		$(".adminTitleLower").show();
		$(".adminInputLower").show();
	
		if(faculty_type == "labMember")
		{
			$.getJSON('/admin/json_managers.php', function(json){
				var label = 'Lab';
				var html = '<select name="lab">';
				var lab_id = $('#lab_value').val();

				for(var faculty_id in json)
				{
					if(typeof json[faculty_id] != "string")
					{
						continue;
					}

					var selected = '';
					if(faculty_id == lab_id)
					{
						selected = 'selected="selected"';
					}

					html += '<option value="' + faculty_id + '" ' + selected + '>' + json[faculty_id] + '</option>';
				}

				html += '</select>';

				$("#lab_label").html(label);
				$("#lab_group").html(html);
			});
		}
		if(faculty_type != "faculty")
		{
			$(".adminTitleLower").hide();
			$(".adminInputLower").hide();
		}
		
	});
});

function initMCE_Page()
{
	tinyMCE.init({
			mode : "textareas",
			editor_selector : "pageadmin",
			elements : "ajaxfilemanager",
			file_browser_callback : "ajaxfilemanager",
			theme : "advanced",
			width : "522",
			height : "420",
			plugins : "advlink,visualchars,table,style,save,preview,contextmenu,autosave,advimage,paste,xhtmlxtras",
			theme_advanced_buttons1 : "save,separator,cut,copy,pastetext,pasteword,selectall,separator,bold,italic,underline,styleprops,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo",
			theme_advanced_buttons2 : "tablecontrols,separator,link,unlink,image,hr,charmap",
			theme_advanced_buttons3 : "formatselect,separator,visualaid,visualchars,removeformat,cleanup,help,separator,code,preview",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "center",
			theme_advanced_path_location : "bottom",
			extended_valid_elements : "b/strong,i/em,h1[style],h2[style],h3[style],a[name|href|target|title|onclick|class|style],img[style|class|src|border=0|alt=|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],div[class|align|style]",
			content_css : "/style/cdbc.css",
			save_enabledwhendirty : true,
			plugin_preview_width :  800,
			plugin_preview_height :  600,
			//plugin_preview_pageurl :  "/templates/default.html",
			remove_script_host : false,
			remove_linebreaks : false,
			apply_source_formatting : true,
			relative_urls : false
	});
}

function initMCE_Faculty()
{
	tinyMCE.init({
		mode : "textareas",
		editor_selector : "facultydescription",
		elements : "ajaxfilemanager",
		file_browser_callback : "ajaxfilemanager",
		theme : "advanced",
		width : "515",
		height : "400",
		plugins : "advlink,visualchars,table,style,preview,contextmenu,advimage,paste,xhtmlxtras",
		theme_advanced_buttons1 : "cut,copy,pastetext,pasteword,selectall,separator,bold,italic,underline,styleprops,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo",
		theme_advanced_buttons2 : "tablecontrols,separator,link,unlink,image,hr,charmap",
		theme_advanced_buttons3 : "formatselect,separator,visualaid,visualchars,removeformat,cleanup,help,separator,code",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "center",
		theme_advanced_path_location : "bottom",
		extended_valid_elements : "b/strong,i/em,h1,h2,h3,a[name|href|target|title|onclick|class|style],img[style|class|src|border=0|alt=|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],div[class|align|style]",
		content_css : "/style/cdbc.css",
		save_enabledwhendirty : true,
		remove_script_host : false,
		remove_linebreaks : false,
		apply_source_formatting : true,
		relative_urls : false
	});
	tinyMCE.init({
		mode : "textareas",
		editor_selector : "facultyappointments",
		elements : "ajaxfilemanager",
		file_browser_callback : "ajaxfilemanager",
		theme : "advanced",
		width : "515",
		height : "200",
		plugins : "advlink,visualchars,table,style,preview,contextmenu,advimage,paste,xhtmlxtras",
		theme_advanced_buttons1 : "cut,copy,pastetext,pasteword,selectall,separator,bold,italic,underline,styleprops,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo",
		theme_advanced_buttons2 : "tablecontrols,separator,link,unlink,image,hr,charmap",
		theme_advanced_buttons3 : "formatselect,separator,visualaid,visualchars,removeformat,cleanup,help,separator,code",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "center",
		theme_advanced_path_location : "bottom",
		extended_valid_elements : "b/strong,i/em,h1,h2,h3,a[name|href|target|title|onclick|class|style],img[style|class|src|border=0|alt=|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],div[class|align|style]",
		content_css : "/style/cdbc.css",
		save_enabledwhendirty : true,
		remove_script_host : false,
		remove_linebreaks : false,
		apply_source_formatting : true,
		relative_urls : false
	});
	tinyMCE.init({
		mode : "textareas",
		editor_selector : "facultyawards",
		elements : "ajaxfilemanager",
		file_browser_callback : "ajaxfilemanager",
		theme : "advanced",
		width : "515",
		height : "200",
		plugins : "advlink,visualchars,table,style,preview,contextmenu,advimage,paste,xhtmlxtras",
		theme_advanced_buttons1 : "cut,copy,pastetext,pasteword,selectall,separator,bold,italic,underline,styleprops,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo",
		theme_advanced_buttons2 : "tablecontrols,separator,link,unlink,image,hr,charmap",
		theme_advanced_buttons3 : "formatselect,separator,visualaid,visualchars,removeformat,cleanup,help,separator,code",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "center",
		theme_advanced_path_location : "bottom",
		extended_valid_elements : "b/strong,i/em,h1,h2,h3,a[name|href|target|title|onclick|class|style],img[style|class|src|border=0|alt=|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],div[class|align|style]",
		content_css : "/style/cdbc.css",
		save_enabledwhendirty : true,
		remove_script_host : false,
		remove_linebreaks : false,
		apply_source_formatting : true,
		relative_urls : false
	});
	tinyMCE.init({
		mode : "textareas",
		editor_selector : "facultyeducation",
		elements : "ajaxfilemanager",
		file_browser_callback : "ajaxfilemanager",
		theme : "advanced",
		width : "515",
		height : "200",
		plugins : "advlink,visualchars,table,style,preview,contextmenu,advimage,paste,xhtmlxtras",
		theme_advanced_buttons1 : "cut,copy,pastetext,pasteword,selectall,separator,bold,italic,underline,styleprops,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo",
		theme_advanced_buttons2 : "tablecontrols,separator,link,unlink,image,hr,charmap",
		theme_advanced_buttons3 : "formatselect,separator,visualaid,visualchars,removeformat,cleanup,help,separator,code",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "center",
		theme_advanced_path_location : "bottom",
		extended_valid_elements : "b/strong,i/em,h1,h2,h3,a[name|href|target|title|onclick|class|style],img[style|class|src|border=0|alt=|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],div[class|align|style]",
		content_css : "/style/cdbc.css",
		save_enabledwhendirty : true,
		remove_script_host : false,
		remove_linebreaks : false,
		apply_source_formatting : true,
		relative_urls : false
	});
	tinyMCE.init({
		mode : "textareas",
		editor_selector : "facultyfunding",
		elements : "ajaxfilemanager",
		file_browser_callback : "ajaxfilemanager",
		theme : "advanced",
		width : "515",
		height : "200",
		plugins : "advlink,visualchars,table,style,preview,contextmenu,advimage,paste,xhtmlxtras",
		theme_advanced_buttons1 : "cut,copy,pastetext,pasteword,selectall,separator,bold,italic,underline,styleprops,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo",
		theme_advanced_buttons2 : "tablecontrols,separator,link,unlink,image,hr,charmap",
		theme_advanced_buttons3 : "formatselect,separator,visualaid,visualchars,removeformat,cleanup,help,separator,code",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "center",
		theme_advanced_path_location : "bottom",
		extended_valid_elements : "b/strong,i/em,h1,h2,h3,a[name|href|target|title|onclick|class|style],img[style|class|src|border=0|alt=|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],div[class|align|style]",
		content_css : "/style/cdbc.css",
		save_enabledwhendirty : true,
		remove_script_host : false,
		remove_linebreaks : false,
		apply_source_formatting : true,
		relative_urls : false
	});
}

function initMCE_Calendar()
{
	tinyMCE.init({
		mode : "textareas",
		editor_selector : "calendarinformation",
		elements : "ajaxfilemanager",
		file_browser_callback : "ajaxfilemanager",
		theme : "advanced",
		width : "515",
		height : "400",
		plugins : "advlink,visualchars,table,style,preview,contextmenu,advimage,paste,xhtmlxtras",
		theme_advanced_buttons1 : "cut,copy,pastetext,pasteword,selectall,separator,bold,italic,underline,styleprops,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo",
		theme_advanced_buttons2 : "tablecontrols,separator,link,unlink,image,hr,charmap",
		theme_advanced_buttons3 : "formatselect,separator,visualaid,visualchars,removeformat,cleanup,help,separator,code",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "center",
		theme_advanced_path_location : "bottom",
		extended_valid_elements : "b/strong,i/em,h1,h2,h3,a[name|href|target|title|onclick|class|style],img[style|class|src|border=0|alt=|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],div[class|align|style]",
		content_css : "/style/cdbc.css",
		save_enabledwhendirty : true,
		remove_script_host : false,
		remove_linebreaks : false,
		apply_source_formatting : true,
		relative_urls : false
	});
	tinyMCE.init({
		mode : "textareas",
		editor_selector : "calendarconfinformation",
		elements : "ajaxfilemanager",
		file_browser_callback : "ajaxfilemanager",
		theme : "advanced",
		width : "515",
		height : "400",
		plugins : "advlink,visualchars,table,style,preview,contextmenu,advimage,paste,xhtmlxtras",
		theme_advanced_buttons1 : "cut,copy,pastetext,pasteword,selectall,separator,bold,italic,underline,styleprops,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo",
		theme_advanced_buttons2 : "tablecontrols,separator,link,unlink,image,hr,charmap",
		theme_advanced_buttons3 : "formatselect,separator,visualaid,visualchars,removeformat,cleanup,help,separator,code",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "center",
		theme_advanced_path_location : "bottom",
		extended_valid_elements : "b/strong,i/em,h1,h2,h3,a[name|href|target|title|onclick|class|style],img[style|class|src|border=0|alt=|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],div[class|align|style]",
		content_css : "/style/cdbc.css",
		save_enabledwhendirty : true,
		remove_script_host : false,
		remove_linebreaks : false,
		apply_source_formatting : true,
		relative_urls : false
	});
}

function initMCE_Employment()
{
	tinyMCE.init({
		mode : "textareas",
		editor_selector : "employmentdescription",
		elements : "ajaxfilemanager",
		file_browser_callback : "ajaxfilemanager",
		theme : "advanced",
		width : "515",
		height : "400",
		plugins : "advlink,visualchars,table,style,preview,contextmenu,advimage,paste,xhtmlxtras",
		theme_advanced_buttons1 : "cut,copy,pastetext,pasteword,selectall,separator,bold,italic,underline,styleprops,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo",
		theme_advanced_buttons2 : "tablecontrols,separator,link,unlink,image,hr,charmap",
		theme_advanced_buttons3 : "formatselect,separator,visualaid,visualchars,removeformat,cleanup,help,separator,code",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "center",
		theme_advanced_path_location : "bottom",
		extended_valid_elements : "b/strong,i/em,h1,h2,h3,a[name|href|target|title|onclick|class|style],img[style|class|src|border=0|alt=|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],div[class|align|style]",
		content_css : "/style/cdbc.css",
		save_enabledwhendirty : true,
		remove_script_host : false,
		remove_linebreaks : false,
		apply_source_formatting : true,
		relative_urls : false
	});
}

function initMCE_News()
{
	tinyMCE.init({
		mode : "textareas",
		editor_selector : "newsstory",
		elements : "ajaxfilemanager",
		file_browser_callback : "ajaxfilemanager",
		theme : "advanced",
		width : "515",
		height : "400",
		plugins : "advlink,visualchars,table,style,preview,contextmenu,advimage,paste,xhtmlxtras",
		theme_advanced_buttons1 : "cut,copy,pastetext,pasteword,selectall,separator,bold,italic,underline,styleprops,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo",
		theme_advanced_buttons2 : "tablecontrols,separator,link,unlink,image,hr,charmap",
		theme_advanced_buttons3 : "formatselect,separator,visualaid,visualchars,removeformat,cleanup,help,separator,code",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "center",
		theme_advanced_path_location : "bottom",
		extended_valid_elements : "b/strong,i/em,h1,h2,h3,a[name|href|target|title|onclick|class|style],img[style|class|src|border=0|alt=|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],div[class|align|style]",
		content_css : "/style/cdbc.css",
		save_enabledwhendirty : true,
		remove_script_host : false,
		remove_linebreaks : false,
		apply_source_formatting : true,
		relative_urls : false
	});
}

function initMCE_Education()
{
	tinyMCE.init({
		mode : "textareas",
		editor_selector : "education",
		elements : "ajaxfilemanager",
		file_browser_callback : "ajaxfilemanager",
		theme : "advanced",
		width : "515",
		height : "400",
		plugins : "advlink,visualchars,table,style,preview,contextmenu,advimage,paste,xhtmlxtras",
		theme_advanced_buttons1 : "cut,copy,pastetext,pasteword,selectall,separator,bold,italic,underline,styleprops,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo",
		theme_advanced_buttons2 : "tablecontrols,separator,link,unlink,image,hr,charmap",
		theme_advanced_buttons3 : "formatselect,separator,visualaid,visualchars,removeformat,cleanup,help,separator,code",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "center",
		theme_advanced_path_location : "bottom",
		extended_valid_elements : "b/strong,i/em,h1,h2,h3,a[name|href|target|title|onclick|class|style],img[style|class|src|border=0|alt=|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],div[class|align|style]",
		content_css : "/style/cdbc.css",
		save_enabledwhendirty : true,
		remove_script_host : false,
		remove_linebreaks : false,
		apply_source_formatting : true,
		relative_urls : false
	});
}

function ajaxfilemanager(field_name, url, type, win)
{
	var ajaxfilemanagerurl = "/script/tiny_mce/plugins/ajaxfilemanager/ajaxfilemanager.php";

	switch (type) {
		case "image":
			ajaxfilemanagerurl += "?type=img";
			break;
		case "media":
			ajaxfilemanagerurl += "?type=media";
			break;
		case "flash": //for older versions of tinymce
			ajaxfilemanagerurl += "?type=media";
			break;
		case "file":
			ajaxfilemanagerurl += "?type=files";
			break;
		default:
			return false;
	}

        tinyMCE.activeEditor.windowManager.open({
                url: "/script/tiny_mce/plugins/ajaxfilemanager/ajaxfilemanager.php",
                width: 782,
                height: 440,
                inline : "yes",
		resizable: "yes",
                close_previous : "no"
            },{
                window : win,
                input : field_name
            });

	/*
	var fileBrowserWindow = new Array();
	fileBrowserWindow["file"] = ajaxfilemanagerurl;
	fileBrowserWindow["title"] = "File Manager";
	fileBrowserWindow["width"] = "782";
	fileBrowserWindow["height"] = "440";
	fileBrowserWindow["close_previous"] = "no";
	tinyMCE.openWindow(fileBrowserWindow, {
	  window : win,
	  input : field_name,
	  resizable : "yes",
	  inline : "yes",
	  editor_id : tinyMCE.getWindowArg("editor_id")
	});
	*/
	
	//return false;
}


