<!-- 
function checkTextareaLength(theTextarea, maxChars, alertUser) {
	if(theTextarea.value.length > maxChars){ 
		theTextarea.value= theTextarea.value.substring(0,maxChars) 
		theTextarea.blur() 
		if (alertUser) alert("There is a maximum of  "+maxChars+" for this field.")	
	}
}

function AddText(Action, Field){
var AddTxt="";
var txt="";
var color="";
	if(Action==1){  
		txt=prompt("Text for the main heading.","Text");      
		if(txt!=null)           
			AddTxt="<font class='head'>"+txt+"</font> ";  
	}
	else if(Action==2){  
		txt=prompt("Text for the sub heading.","Text");      
		if(txt!=null)           
			AddTxt="<font class='shead'>"+txt+"</font> ";  
	}
	else if(Action==3){  
		txt=prompt("Text for the sub sub heading.","Text");      
		if(txt!=null)           
			AddTxt="<font class='body'><b>"+txt+"</b></font> ";  
	}
	else if(Action==4) {  
		txt=prompt("Text to be made BOLD.","Text");     
		if(txt!=null)           
			AddTxt="<b>"+txt+"</b> ";        
	}
	else if(Action==5) {  
		txt=prompt("Text to be italicized","Text");     
		if(txt!=null)           
			AddTxt="<i>"+txt+"</i> ";        
	}
	else if(Action==6) AddTxt="<p>";
	else if(Action==7) AddTxt="<BR>";
	else if(Action==8) AddTxt="<hr>";
	else if(Action==9) {  
		txt=prompt("URL for the link.","http://");      
		if(txt!=null){          
			AddTxt="<a href="+txt+">";              
			txt=prompt("Text to be show for the link","Text");              
			AddTxt+=txt+"</a> ";         
	   }
	}
	else if(Action==10) { 
		txt=prompt("URL for graphic","URL");    
		if(txt!=null)           
			AddTxt="<img src="+txt+">"; 
	}
	else if(Action==11) {  
		txt=prompt("Text to be centred","Text");     
		if(txt!=null)           
			AddTxt="<center>"+txt+"</center>";
	}
	else if(Action==12) AddTxt="&#149; ";
	else if(Action==99) {
		color=prompt("Color of the text.","red, blue, orange, or green");      
		if(color!=null){
			if (color == "red") {
				AddTxt="<font color=\"#CC0000\"><b>";  
			} else if (color == "orange") {
				AddTxt="<font color=\"#FF9900\"><b>";  
			} else if (color == "blue") {
				AddTxt="<font color=\"#003399\"><b>";  
			} else if (color == "green") {
				AddTxt="<font color=\"#009999\"><b>";  
			} else {
				color = "red";
				AddTxt="<font color=\"#CC0000\">";  
			}
			txt=prompt("Text to be shown in " + color + ".","Text");              
			AddTxt+=txt+"</b></font>";         
	   }
	}
	editor [Field].value+=AddTxt;
	document.editor [Field].focus();
}


function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

function previewWindow(Field) {
	text = document.editor [Field].value
	var sMarkup = "<HTML><HEAD><TITLE>Preview</TITLE></HEAD>";
	sMarkup += "<LINK REL=stylesheet HREF='../ssi/style.css' TYPE='text/css'>"
	sMarkup += "<BODY BGCOLOR='#FFFFFF'><font class='sbody'>" + replace(text,"\n","<BR>") + "</font><BR>"
	sMarkup += "<P><TABLE WIDTH='100%' BORDER='0' CELLSPACING='0' CELLPADDING='5' BGCOLOR='#DDDDDD'><TR><TD><FONT CLASS='sbody'><CENTER><a href='javascript:window.close()'>Close Window</a></CENTER></FONT></TD></TR></TABLE>";
//	<FONT SIZE='-2' FACE='Verdana, Arial'><a href='javascript:window.close()'>Close Window</a></FONT></CENTER></BODY></HTML>";

   winStats='resizable=no,toolbar=no,location=no,directories=no,menubar=no,'
   winStats+='scrollbars=yes,width=380,height=300'
	var win = window.open("", "Preview", winStats); // a window object
	var doc = win.document;
	doc.open("text/html", "replace");
	doc.write(sMarkup);
	doc.close();
}
// End -->
