/** Author: Daniel Stephenson // Jumpstart Design
  *  Date: --/--/2007
  *  Filename: editorAPI.js
  *  Function: stuff for accessing fckeditor API
  *  History: 
*/


/* fckeditor API - fck_ExecuteCommand */

function fck_ExecuteCommand( commandName, id )
{
  var oEditor = FCKeditorAPI.GetInstance(id) ;

  oEditor.Commands.GetCommand( commandName ).Execute() ;
}

/* fckeditor API - fck_InsertImage */

function fck_InsertImage(base_path, username, img_file)
{
	var oEditor = FCKeditorAPI.GetInstance('page_data2') ;

	if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
	{
    /* NB::: needs changing.. still setup for codejibe */
    oEditor.InsertHtml( '<!--FUBAR--><a class="linkopacity06" href="' + base_path + 'users/' + username + '/user_tempfiles/' + img_file + '" rel="lightbox" title="Image posted by ' + username + '"><img src="' + base_path + 'thumbs/phpthumbs/phpThumb.php?src=' + base_path + 'users/' + username + '/user_tempfiles/' + img_file + '&h=110&w=165" alt="" border="0"></a><!--FUBAR-->' ) ;
	}
	else
		alert( 'You must be on WYSIWYG mode!' ) ;
}

/* fckeditor API - fck_InsertHTML */

function fck_InsertHTML(html_data, editor)
{
  var oEditor = FCKeditorAPI.GetInstance(editor) ;

  if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
  {
		oEditor.InsertHtml( html_data ) ;
  }
  Else
		alert( 'You must be on WYSIWYG mode!' ) ;
}

/* fck_copyData - insert xhtml in editor to element value  */

function fck_copyData(id) {
  var editor = document.getElementById(id);
  var oEditor = FCKeditorAPI.GetInstance(id);

  editor.value = oEditor.GetXHTML( true );
}

/* fck_resetEditor - resets an fck editors text  */

function fck_resetEditor(id, newtext) {
  var editor = document.getElementById(id);
  var oEditor = FCKeditorAPI.GetInstance(id);

  editor.value = oEditor.SetHTML( newtext );
}

