
// edit_format.asp file  -->
// Dir: admin/functions		-->
// Version: 1.0 	  		-->
// Created on: 17/05/2007 	-->
// Created by: Ben Drury  	-->

// Released: 31/11/2007	 	-->

//------------------------------------------------------------------------------------>
// 						Post Release Amendment History                         		-->
//------------------------------------------------------------------------------------>
//--  Amend Date --   Amend Author   --  Amendment Details      					-->
//------------------------------------------------------------------------------------>
//--             --    				 --												-->
//--             --    				 --												-->
//--             --    				 --												-->
//--             --    				 --												-->
//------------------------------------------------------------------------------------>			  


//**************************************************************************************
//**  Copyright Notice
//**
//**  Ben Drury - Table Matrix Systems
//**
//**  Copyright 2007. Ben Drury. All Rights Reserved.
//**
//**  This program is software that you purchase and can modify (at your own risk) 
//**  any part of it under the terms of the license that accompanies this software.
//**
//**  All copyright notices must remain in tacked in the scripts and the
//**  outputted HTML.
//**
//**  You may use parts of this program in your own private work, but you may NOT
//**  redistribute, repackage, or sell the whole or any part of this program even
//**  if it is modified or reverse engineered in whole or in part without express
//**  permission from the author.
//**
//**  You may not pass the whole or any part of this application off as your own work.
//**
//**  All links to Table Matix Systems and powered by logo//s must remain unchanged and in place
//**  and must remain visible when the pages are viewed unless permission is first granted
//**  by the copyright holder.
//**
//**  This program is distributed in the hope that it will be useful,
//**  but WITHOUT ANY WARRANTY; without even the implied warranty of
//**  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR ANY OTHER
//**  WARRANTIES WHETHER EXPRESSED OR IMPLIED.
//**
//**  You should have received a copy of the License along with this program;
//**  if not tablematrix@phoenixcreative.co.uk
//**
//**  No official support is available for this program but you may post support questions at: -
//**  http://www.phoenixcreative.co.uk/forum
//**
//**  For correspondence or non support questions contact: -
//**  info@phoenixcreative.co.uk
//**
//****************************************************************************************

function insertAtCursor(myField, myValue) {
	//IE support
	if (document.selection) 
	{
		myField.focus();
		sel = document.selection.createRange();
		sel.text = myValue;
	}
	//MOZILLA/NETSCAPE support
	else if (myField.selectionStart || myField.selectionStart == '0') 
	{
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos)
		+ myValue
		+ myField.value.substring(endPos, myField.value.length);
	} 		  
	// anyone else
	else 
	{
		myField.value += myValue;
	}
}

function add_bold(obj) 
{		  				
	// declare internal variable to hold passed variable 
	var el = document.getElementById(obj);	 
	 						 	   		   
								   
	insertAtCursor(el, "[b][/b]");
}

function add_image(obj)
{
	// declare internal variable to hold passed variable 
	var el = document.getElementById(obj);	 

	insertAtCursor(el, "[img]");
}

function remove_image(obj)
{
	// declare internal variable to hold passed variable 
	var el = document.getElementById(obj);	 
	el.value = el.value.replace(/<img\/?[^>]+(>|$)/g, "");
	el.value = el.value.replace(/[img\/?[^>]+(]|$)/g, "");
}

function add_link(form,obj)
{				  
	var el = document.getElementById(obj);	
	var elURL = document.getElementById('link_input_url');		 
	var elTXT = document.getElementById('link_input_text');		 		 
	var addedTXT = '<a href="' + elURL.value + '" >' + elTXT.value + '</a>'
	insertAtCursor(el, addedTXT);

	// declare internal variable to hold passed variable 
	var frm = document.getElementById(form);	 
	frm.style.display = "none"	
}

function show_link(obj)
{
	// declare internal variable to hold passed variable 
	var el = document.getElementById(obj);	 
	el.style.display = "block"
}
