//---------------------------------------------------------------------------//
//																			 //
//								LITEFUNCTIONS.js 							 //
//								Version 1.2
//																			 //
//---------------------------------------------------------------------------//
//																			 //
//  These are the functions which are necessary for TextArea Rich to operate //
//	Each functions is shown below with a description of it's process.	     //
//																			 //
//	If you require any help installing TextArea Rich or have any questions,  //
//	please visit http://www.textarearich.com/forum/ and post us a question.	 //
//																			 //
//---------------------------------------------------------------------------//
//																			 //
//	Many Thanks for purchasing TextArea Rich,								 //
//	Kind Regards,															 //
//	The TextArea Rich Team													 //
//																			 //
//---------------------------------------------------------------------------//

<!--htmlgstart -->


//---------------------------------------------------------------------
//function name: 	doImage
//added: 			pre 27/11/02
//desc: 			open the image window
//---------------------------------------------------------------------
	
function doImage()
{
	iView.focus();
	imageWin = window.open('insert_image.htm','','width=500,height=430,scrollbars=yes,resizable=yes,titlebar=1');
}


//---------------------------------------------------------------------
//function name: 	Init
//added: 			19/10/02
//desc: 			init is called when the body is loaded. This will draw the editor
//					buttons and set the table borders.
//---------------------------------------------------------------------
	
function Init()
  {
    iView.document.designMode = 'On';
	viewMode = 1;
	 
    // Show all controls
    controls_basic.style.display = 'inline';
	controls_wysiwyg1.style.display = 'inline';
	view_source.style.display = 'none';
	view_source_mode.style.display = 'none';
	view_wysiwyg.style.display = 'inline';
	view_wysiwyg_mode.style.display = 'inline';	
   
  }
 

  
//---------------------------------------------------------------------
//function name: 	isSelected
//added: 			19/10/02
//desc: 			check that there is a selection. this can be text or an image (control)
//---------------------------------------------------------------------
  
  function isSelected() {
			if ((iView.document.selection.type == "Text") || (iView.document.selection.type == "Control")) {
				return true;
			} else {
				alert("Please highlight the text before pressing this button!");
				return false;
			}
  }
  
  
//---------------------------------------------------------------------
//function name: 	cancel save
//added: 			21/10/02
//desc: 			not used in the editor, but can be used.
//					assign the function to a button, and when pressed it will open a dialoge box
//					asking if the user is sure they want to exit without saving.
//---------------------------------------------------------------------
  

	function cancelSave() {
		var agree=confirm("Are you sure you want to cancel without saving changes?");
			if (agree)
				return true;
			else
				return true;
}

//---------------------------------------------------------------------
//function name: 	save
//added: 			21/10/02
//desc: 			takes the contents of the Editor window and saves
//					the data in a hidden field in the form called "content"
//---------------------------------------------------------------------
  
function savedocument()
  	{	
 		document.saveform.content.value = iView.document.documentElement.outerHTML;
	}

//---------------------------------------------------------------------
//function name: 	MOUSE OVER / MOUSE OUT class styles
//added: 			15/10/02
//desc: 			init is called when the body is loaded. This will draw the editor
//					buttons and set the table borders.
//---------------------------------------------------------------------

	function selOn_dis(ctrl)
	{
		ctrl.style.borderBottom = "buttonshadow solid 1px";
		ctrl.style.borderLeft = "buttonhighlight solid 1px";
		ctrl.style.borderRight = "buttonshadow solid 1px";
		ctrl.style.borderTop = "buttonhighlight solid 1px";
		
	}
	  
	function selOn_tab(ctrl)
	{
		ctrl.style.cursor = 'hand';	
	}
  
  
	function selOn(ctrl)
	{
		ctrl.style.borderColor = '#EE9332'; 
		ctrl.style.cursor = 'hand';
		ctrl.style.backgroundColor = '#E2C3A4';	
	}
  

	function selOff(ctrl)
	{
		ctrl.style.backgroundColor = '#F0E1CA';
		ctrl.style.borderColor = '#F0E1CA';
	}
	  
	
	function selDown(ctrl)
	{
		ctrl.style.borderBottom = "buttonhighlight solid 1px";
		ctrl.style.borderLeft = "buttonshadow solid 1px";
		ctrl.style.borderRight = "buttonhighlight solid 1px";
		ctrl.style.borderTop = "buttonshadow solid 1px";
	}
	  
	
	function selUp(ctrl)
	{
		ctrl.style.backgroundColor = '#E2C3A4';
		ctrl = null; 
	}
	
//---------------------------------------------------------------------
// BEGIN STANDARD MSHTML CONTROLS
//---------------------------------------------------------------------

// pass the code like:
// onClick="cmdExec('undo','null')"


function cmdExec(cmd,opt) {
 	iView.focus();
  	iView.document.execCommand(cmd,"",opt);
}


//---------------------------------------------------------------------
//function name: 	doForeCol
//added: 			25/10/02
//desc: 			opens a popup window with selection of colours to choose from
//					once choice is made, popup closes and forecolor is added
//---------------------------------------------------------------------  
  
function doForeCol(val)
{
    
	if (isSelected())
	{
	
		window.open('editor/files/pick_forecol.htm','popuppage','width=500,height=500,top=100,left=100');	
		
		if (val != null)
		{
			iView.document.execCommand('forecolor', false, val);
		}
		
	}
	
}
  
//---------------------------------------------------------------------
//function name: 	doBackCol
//added: 			25/10/02
//desc: 			opens a popup window with selection of colours to choose from
//					once choice is made, popup closes and forecolor is added
//---------------------------------------------------------------------  

  
function doBackCol(val)
{
    
	if (isSelected())
	{
	
		window.open('editor/files/pick_backcol.htm','popuppage','width=500,height=500,top=100,left=100');	
		
		if (val != null)
		{
			iView.document.execCommand('backcolor', false, val);
		}
		
	}
	
}


//---------------------------------------------------------------------
//function name: 	doLink
//added: 			15/11/02
//desc: 			opens a link pop up box. If selection is already a link, the 
//					default values are loaded. otherwise they are left blank.
//---------------------------------------------------------------------
  
  function doLink()
  {
	if (isSelected()) {
	window.open('editor/files/insert_link.htm','popuppage','width=420,height=350,top=100,left=100');
	}
  }
  

//---------------------------------------------------------------------
//function name: 	doFont
//added: 			25/10/02
//desc: 			change the font from the drop down box
//---------------------------------------------------------------------

  
  function doFont(fName)
  {
    if(fName != '')
      iView.document.execCommand('fontname', false, fName);
  }
  
//---------------------------------------------------------------------
//function name: 	doSize
//added: 			25/10/02
//desc: 			change the size from the drop down box
//---------------------------------------------------------------------
  
  function doSize(fSize)
  {
    if(fSize != '')
      iView.document.execCommand('fontsize', false, fSize);
  }

//---------------------------------------------------------------------
//function name: 	toggle
//added: 			12/10/02
//desc: 			Toggle between SOURCE and WYSIWYG modes
//---------------------------------------------------------------------
  
  function toggle()
  {  
    if(viewMode == 1)
    {
      
	  iHTML = iView.document.body.outerHTML;
      iView.document.body.innerText = iHTML;
      
      // Hide or show controls
      controls_basic.style.display = 'inline';
	  controls_wysiwyg1.style.display = 'none';
	  view_source.style.display = 'inline';
	  view_source_mode.style.display = 'inline';
	  view_wysiwyg.style.display = 'none';
	  view_wysiwyg_mode.style.display = 'none';	 
	  

	  //get the current font/face values
	  fontFamily = iView.document.body.style.fontFamily
	  fontSize = iView.document.body.style.fontSize
	  text = iView.document.body.text
	  bgColor = iView.document.body.bgColor
	  background = iView.document.body.background
	  
	  //change the font to editor code
	  iView.document.body.style.fontFamily = "Courier"
	  iView.document.body.style.fontSize = "10pt"
	  iView.document.body.text = '#333366';
	  iView.document.body.bgColor = '#ffffff';
	  iView.document.body.background = '';
      iView.focus();
      
      viewMode = 2; // Code
    }
    else
    {
      iText = iView.document.body.innerText;
      iView.document.body.innerHTML = iText;
      
      // Show all controls
      controls_basic.style.display = 'inline';
	  controls_wysiwyg1.style.display = 'inline';
	  view_source.style.display = 'none';
	  view_source_mode.style.display = 'none';
	  view_wysiwyg.style.display = 'inline';
	  view_wysiwyg_mode.style.display = 'inline';	 
	  
	  
	  iView.document.body.style.fontFamily = fontFamily;
	  iView.document.body.style.fontSize = fontSize;
	  iView.document.body.text = text;
	  iView.document.body.bgColor = bgColor;
	  iView.document.body.background = background;
      iView.focus();
      
      viewMode = 1; // WYSIWYG
    }
  }



//end litefunctions

<!--htmlgstop -->

