//------------------------//
// Default Sprach-Strings //
//------------------------//

if ( !lang ) { var lang = new Array(); }

// Meldungstexte
lang['messages'] = new Array();
lang['messages']['delete_blog']  = 'Really delete this blog ?';
lang['messages']['lock_blog']    = 'Really lock this blog ?';
lang['messages']['delete_post']  = 'Really delete this post ?';
lang['messages']['feature_post'] = 'Really feature this post ?';

/**
 * Sicherheits-Abfrage vor einer Aktion in den Blogs
 *
 * Wird false zurueckgeliefert wird das Aufrufen
 * des Links abgebrochen.
 *
 * @param   int   action   Aufgerufene Aktion
 * @param   int   post_id  ID des Postings (fuer Highlight benoetigt)
 * @return  bool           Abfrage bestaetigt ?
 */
function confirm_blog_action( action, post_id ) {
	
	// Highlightning, falls Beitrags-ID > 0
	if ( post_id > 0 )
		document.getElementById('post_'+post_id).style.background = '#fbfbe2';
	
	if ( confirm(lang['messages'][action]) ) {
		
		return true;
	}
	
	if ( post_id > 0 )
		document.getElementById('post_'+post_id).style.background = '#ffffff';
	
	return false;
}

/**
 * Laedt den TinyMce-Editor mit den Default-Einstellungen
 * fuer Blog-Beitraege. Dazu gehoeren Plugin- und
 * Toolbar-Settings.
 *
 * @param  string  element_id    ID der Textarea in der der Editor geladen werden soll
 * @param  string  tinymce_base  Basis-URL zum Editor-Verzeichnis (zum Laden des Editor-JS)
 * @param  string  img_base      Basis-URL zu statischen Inhalten (zum Laden des Editor-CSS)
 * @return void
 */
function load_post_editor( element_id, tinymce_base, img_base ) {
	
	tinyMCE.init({
		
		// Allgemeine Einstellungen
		base:     tinymce_base,
		mode:     "exact",
		elements: element_id,
		theme:    "advanced",
		language: "de",
		entity_encoding : "raw",
		
		// Plugins
		plugins: "safari,inlinepopups,contextmenu,paste,advhr,media,searchreplace,style,xhtmlxtras,",
		
		// Theme Optionen
		theme_advanced_buttons1 : "bold,italic,strikethrough,underline,|,bullist,numlist,outdent,indent,|,justifyleft,justifycenter,justifyright,justifyfull,|,link,unlink,anchor,|,image,|,search,replace,pastetext,pasteword,",
		theme_advanced_buttons2 : "fontsizeselect,formatselect,removeformat,|,charmap,|,forecolor,|,sup,sub,media,|,undo,redo",
		theme_advanced_buttons3 : "",
		theme_advanced_buttons4 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,
		theme_advanced_resize_horizontal : false,
		theme_advanced_resizing_use_cookie : true,
		
		// CSS Datei fuer die Formatierung innerhalb des Editors
		content_css : img_base + "/css/blogs-tinymce.css"
	});
}

/**
 * Wechselt den Eingabemodus der Textarea beim Verfassen /
 * Bearbeiten von Blog-Beitraegen und wird ueber die
 * Reiter ueber dem Editor ausgeloest.
 *
 * @param  string  mode  Modus (gui / html)
 * @return void
 */
function change_editor_mode( mode ) {
	
	if ( mode == 'gui' ) {
		
		// CSS-Wechsel fuer alle anderen Browser
		document.getElementById('change_editor_mode_gui').setAttribute('class', 'current');
		document.getElementById('change_editor_mode_html').setAttribute('class', 'none');
		
		// CSS-Wechsel fuer den Internet Explorer
		document.getElementById('change_editor_mode_gui').setAttribute('className', 'current');
		document.getElementById('change_editor_mode_html').setAttribute('className', 'none');
		
		// TinyMce einblenden
		tinyMCE.execCommand('mceAddControl', false, 'post_content');
		
	} else if ( mode == 'html' ) {
		
		// CSS-Wechsel fuer alle anderen Browser
		document.getElementById('change_editor_mode_gui').setAttribute('class', 'none');
		document.getElementById('change_editor_mode_html').setAttribute('class', 'current');
		
		// CSS-Wechsel fuer den Internet Explorer
		document.getElementById('change_editor_mode_gui').setAttribute('className', 'none');
		document.getElementById('change_editor_mode_html').setAttribute('className', 'current');
		
		// TinyMce ausblenden
		tinyMCE.execCommand('mceRemoveControl', false, 'post_content');
	}
	
	document.getElementById('post_content').focus();
}
