var ajaxlocation = '/tsparkCMS/ajax/';

$(document).ready(function() {
	//alert('sorry, error');
	$(document).keyup(function(e) {
		if (e.keyCode == '27' || e.keyCode == '113') {
		    toggleMode();
		}
	});
	$.ajax({
		type: "POST",
		url: ajaxlocation+"cmstoolbar.cfm",
		data: "frompage="+escape(location.href),
		success: function(msg){
			$('body').prepend(msg);
		}
	});
});

/* MODE TOGGLE */
toggleMode = function() {
	$.ajax({
		type: "POST",
		url: ajaxlocation+"zones.cfm",
		data: "action=toggle",
		success: function(msg){
			location.reload(true);
		}
	});	
};

/* CK EDITOR FUNCTIONS */
loadEditor = function(id,settings) {
    var instance = CKEDITOR.instances[id];
    if(instance)
    {
        CKEDITOR.remove(instance);
    }
    CKEDITOR.replace(id,settings);
};
destroyEditor = function(id) {
	var instance = CKEDITOR.instances[id];
    if(instance) {
    	instance.destroy(true);
    }

};


