﻿function initAdminAccordion() {
	$("#accordion").accordion({
		autoHeight: false
	});
	if (jQuery.browser.msie) {
		$("#accordion div").css("zoom", "1");
	}
}

function initCalendars() {
	$(".calendar").datepicker({
		showOn: 'button',
		buttonImage: '/Themes/Shared/Content/images/icons/calendar.png',
		buttonImageOnly: true,
		changeMonth: true,
		changeYear: true,
		firstDay: 1,
		dateFormat: 'dd/mm/yy'
	});
}

function initTinyMCE() {
	tinyMCE.init({
		mode: "textareas",
		theme: "advanced",
		editor_selector: "mceText",
		plugins: "safari,spellchecker,pagebreak,style,layer,table,advimage,advlink,iespell,inlinepopups,insertdatetime,media,contextmenu,paste,nonbreaking,xhtmlxtras",
		theme_advanced_buttons1: "cut,copy,paste,pastetext,pasteword,|,bold,italic,underline,separator,bullist,numlist,undo,redo,link,unlink,|,spellchecker",
		theme_advanced_buttons2: "",
		theme_advanced_buttons3: "",
		theme_advanced_toolbar_location: "top",
		theme_advanced_toolbar_align: "left",
		theme_advanced_path_location: "bottom",
		extended_valid_elements: "a[name|href|target|title|onclick],img[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]",
		relative_urls: false,
		urlconverter_callback: "convertToFullUrl",
		spellchecker_rpc_url: "/TinyMCE.ashx?module=SpellChecker"
	});
}

function convertToFullUrl(url, node, on_save) {
	if (url.indexOf("http") == 0 || url.indexOf("mailto:") == 0) {
		return url;
	}

	return "http://www.jerrygreendogs.org.uk" + url;
}
