

function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) { endstr = document.cookie.length; }
	return unescape(document.cookie.substring(offset, endstr));
	}

function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) {
			return getCookieVal (j);
			}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
		}
	return null;
	}




var RichEditor = false;
var ipath = "http://directory.thelovelinks.com/img/smiley/";
var tmp = "";

if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.charAt(0) >= 4)
{
RichEditor = true;
document.write('<IFRAME ID="iframe" name="iframe" width="280" height="200"></IFRAME>');
document.write('<input type=hidden name=message>'); 
document.write('<input type=hidden name=re value=1>'); 
var Editor = iframe.document;
Editor.designMode = "On";
}else{
document.write('<TEXTAREA style="width:280px; height:200px" onkeyup=javascript:store(this); onmouseover=this.focus() onclick=javascript:store(this); name=message onchange=javascript:store(this);></TEXTAREA>'); 
document.write('<input type=hidden name=re value=0>'); 
}


function getEditor() {
	return Editor.body.innerHTML;
}

function upForm() {

if (!RichEditor) return;
tmp = getEditor();

tmp = tmp.replace(/<img src=\"http:\/\/directory.thelovelinks.com\/img\/smiley\/rolleyes.gif\">/ig," ::) ");
tmp = tmp.replace(/<img src=\"http:\/\/directory.thelovelinks.com\/img\/smiley\/smiley.gif\">/ig," :) ");
tmp = tmp.replace(/<img src=\"http:\/\/directory.thelovelinks.com\/img\/smiley\/wink.gif\">/ig," ;) ");
tmp = tmp.replace(/<img src=\"http:\/\/directory.thelovelinks.com\/img\/smiley\/cheesy.gif\">/ig," :D ");
tmp = tmp.replace(/<img src=\"http:\/\/directory.thelovelinks.com\/img\/smiley\/grin.gif\">/ig," ;D ");
tmp = tmp.replace(/<img src=\"http:\/\/directory.thelovelinks.com\/img\/smiley\/angry.gif\">/ig," >:( ");
tmp = tmp.replace(/<img src=\"http:\/\/directory.thelovelinks.com\/img\/smiley\/sad.gif\">/ig," :( ");
tmp = tmp.replace(/<img src=\"http:\/\/directory.thelovelinks.com\/img\/smiley\/shocked.gif\">/ig," :o ");
tmp = tmp.replace(/<img src=\"http:\/\/directory.thelovelinks.com\/img\/smiley\/cool.gif\">/ig," 8) ");
tmp = tmp.replace(/<img src=\"http:\/\/directory.thelovelinks.com\/img\/smiley\/tongue.gif\">/ig," :P ");
tmp = tmp.replace(/<img src=\"http:\/\/directory.thelovelinks.com\/img\/smiley\/lipsealed.gif\">/ig," :-X ");
tmp = tmp.replace(/<img src=\"http:\/\/directory.thelovelinks.com\/img\/smiley\/embarassed.gif\">/ig," :-[ ");
tmp = tmp.replace(/<img src=\"http:\/\/directory.thelovelinks.com\/img\/smiley\/undecided.gif\">/ig," :-/ ");
tmp = tmp.replace(/<img src=\"http:\/\/directory.thelovelinks.com\/img\/smiley\/kiss.gif\">/ig," :-* ");
tmp = tmp.replace(/<img src=\"http:\/\/directory.thelovelinks.com\/img\/smiley\/cry.gif\">/ig," :'( ");

tmp = tmp.replace(/<hr>/ig,"[hr]");
tmp = tmp.replace(/<hr color=(.{7})>/ig,"[hr color='$1']");
tmp = tmp.replace(/<STRONG>/ig,"[b]");
tmp = tmp.replace(/<\/STRONG>/ig,"[/b]");
tmp = tmp.replace(/<EM>/ig,"[i]");
tmp = tmp.replace(/<\/EM>/ig,"[/i]");
tmp = tmp.replace(/<U>/ig,"[u]");
tmp = tmp.replace(/<\/U>/ig,"[/u]");
tmp = tmp.replace(/<UL>/ig,"[ul]");
tmp = tmp.replace(/<\/UL>/ig,"[/ul]");
tmp = tmp.replace(/<OL>/ig,"[ol]");
tmp = tmp.replace(/<\/OL>/ig,"[/ol]");
tmp = tmp.replace(/<LI>/ig,"[li]");
tmp = tmp.replace(/<\/LI>/ig,"[/li]");
tmp = tmp.replace(/<MARQUEE>/ig,"[move]");
tmp = tmp.replace(/<\/MARQUEE>/ig,"[/move]");
tmp = tmp.replace(/<FIELDSET>/ig,"[quote]");
tmp = tmp.replace(/<\/FIELDSET>/ig,"[/quote]");

tmp = tmp.replace(/<p>/ig,"[p]");
tmp = tmp.replace(/<\/p>/ig,"[/p]");
tmp = tmp.replace(/<p align=(\w+)>/ig,"[p align=$1]");

tmp = tmp.replace(/<img src=\"?(.+)(.jpg|.gif)\"?>/ig,"[img src='$1$2']");
tmp = tmp.replace(/<img src=\"?(.+)(.jpg|.gif)\"? style=\"?(.+)\"?>/ig,"[img src='$1$2' style='$3']");
tmp = tmp.replace(/<A href="(.+)">(.+)<\/A>/ig,"[a href='$1']$2[/a]");
tmp = tmp.replace(/<A mailto:"(.+)">(.+)<\/A>/ig,"[a mailto:'$1']$2[/a]");

tmp = tmp.replace(/<\/font>/ig,"[/font]");
tmp = tmp.replace(/<font style=\"BACKGROUND-COLOR: (.{7})\">/ig,"[font style='BACKGROUND-COLOR: $1']");
tmp = tmp.replace(/<font color=(.{7})>/ig,"[font style='color:$1']");
tmp = tmp.replace(/<font size=(\d+)>/ig,"[font size=$1]");
tmp = tmp.replace(/<font face=\"?([\w\,\s]+)\"?>/ig,"[font style='font-family:$1']");
tmp = tmp.replace(/<font color=(.{7}) size=(\d+)>/ig,"[font style='color:$1' size=$2]");
tmp = tmp.replace(/<font color=(.{7}) face=\"?([A-Za-z,\s]+)\"?>/ig,"[font style='color:$1; font-family:$2']");
tmp = tmp.replace(/<font color=(.{7}) style=\"BACKGROUND-COLOR: (.{7})\">/ig,"[font style='color:$1; BACKGROUND-COLOR: $2']");
tmp = tmp.replace(/<font face=\"?([A-Za-z,\s]+)\"? size=(\d+)>/ig,"[font style='font-family:$1' size=$2]");
tmp = tmp.replace(/<font face=\"?([A-Za-z,\s]+)\"? style=\"BACKGROUND-COLOR: (.{7})\">/ig,"[font style=' style='font-family:$1'; BACKGROUND-COLOR: $2']");
tmp = tmp.replace(/<font size=(\d+) style=\"BACKGROUND-COLOR: (.{7})\">/ig,"[font size=$1 style='BACKGROUND-COLOR: $2']");
tmp = tmp.replace(/<font color=(.{7}) face=\"?([A-Za-z,\s]+)\"? size=(\d+)>/ig,"[font style='color:$1; font-family:$2' size=$3]");
tmp = tmp.replace(/<font color=(.{7}) face=\"?([A-Za-z,\s]+)\"? style=\"BACKGROUND-COLOR: (.{7})\">/ig,"[font style='color:$1; font-family:$2; BACKGROUND-COLOR: $3']");
tmp = tmp.replace(/<font color=(.{7}) size=(\d+) style=\"BACKGROUND-COLOR: (.{7})\">/ig,"[font size=$2 style='color:$1; BACKGROUND-COLOR: $3']");
tmp = tmp.replace(/<font face=\"?([A-Za-z,\s]+)\"? size=(\d+) style=\"BACKGROUND-COLOR: (.{7})\">/ig,"[font size=$2 style='font-family:$1; BACKGROUND-COLOR: $3']");
tmp = tmp.replace(/<font color=(.{7}) face=\"?([A-Za-z,\s]+)\"? size=(\d+) style=\"BACKGROUND-COLOR: (.{7})\">/ig,"[font size=$3 style='color:$1; font-family:$2; BACKGROUND-COLOR: $4']");

comnt.message.value = tmp;

}


var colorArray = new Array();
colorArray[0] = new Array("#FFFFFF","#F8F8FF","#F5F5F5","#DCDCDC","#D3D3D3","#C0C0C0","#A9A9A9","#808080","#696969","#000000");
colorArray[1] = new Array("#FFB6C1","#FA8072","#FF6347","#FF4500","#FF0000","#DC143C","#B22222","#A52A2A","#8B0000","#800000");
colorArray[2] = new Array("#FF00FF","#FF00FF","#FF69B4","#C71585","#FF1493","#9400D3","#BA55D3","#9932CC","#8B008B","#800080");
colorArray[3] = new Array("#D8BFD8","#DDA0DD","#EE82EE","#DA70D6","#CD5C5C","#DB7093","#7B68EE","#9370DB","#8A2BE2","#4B0082");
colorArray[4] = new Array("#00BFFF","#1E90FF","#0000FF","#4169E1","#6A5ACD","#0000CD","#483D8B","#00008B","#000080","#191970");
colorArray[5] = new Array("#87CEFA","#DAA520","#E9967A","#FFFF00","#FFD700","#D2691E","#FF8C00","#FF7F50","#A0522D","#8B4513");
colorArray[6] = new Array("#40E0D0","#AFEEEE","#E6E6FA","#B0E0E6","#00CED1","#00FFFF","#00FFFF","#6495ED","#87CEEB","#4682B4");
colorArray[7] = new Array("#00FF7F","#7CFC00","#7FFF00","#00FF00","#32CD32","#228B22","#008000","#2E8B57","#006400","#2F4F4F");
colorArray[8] = new Array("#778899","#B0C4DE","#48D1CC","#ADFF2F","#7FFFD4","#8FBC8B","#3CB371","#6B8E23","#808000","#556B2F");
colorArray[9] = new Array("#66CDAA","#00FA9A","#98FB98","#EEE8AA","#20B2AA","#5F9EA0","#708090","#9ACD32","#008B8B","#008080");
colorArray[10] = new Array("#F08080","#D2B48C","#BDB76B","#BC8F8F","#FFA07A","#DEB887","#F4A460","#FFA500","#B8860B","#CD853F");
colorArray[11] = new Array("#FFFFE0","#FFEBCD","#FFE4C4","#FFE4E1","#F5DEB3","#FFF8DC","#FFFACD","#E0FFFF","#F0F8FF","#ADD8E6");
colorArray[12] = new Array("#F0FFFF","#F0FFF0","#FFFFF0","#FFFAF0","#F5FFFA","#FDF5E6","#FFF5EE","#FFFAFA","#F5F5DC","#FFC0CB");
colorArray[13] = new Array("#FFF0F5","#FAF0E6","#FAFAD2","#FFEFD5","#FAEBD7","#FFDAB9","#FFDEAD","#FFDEAD","#FFE4B5","#F0E68C");


function getsColor(targets) {

var	htmlSet = "<TABLE CELLSPACING=1 CELLPADDING= border=0 align=center style='cursor:hand'>";
	for (var x = 0; x < 10 ; x++) {
		htmlSet += "<TR>";
		for (var y = 0; y < 14; y++) {
		cl = colorArray[y][x];
			htmlSet += "<TD style='font-size:4px' width=8 height=8 align=center onclick='"+targets+"(\""+cl+"\")\;' bgcolor='"+cl+"'>";
			htmlSet += '&nbsp;';
			htmlSet += "</TD>";
		}
		htmlSet += "</TR>";
	}
	htmlSet += "</TABLE>";
	
	return htmlSet;

}






















function proses() {
	if (window.submitted) return false;
	window.submitted = true;
	return true;
}

function store(text) { 
	if (text.createTextRange) text.caretPos = document.selection.createRange().duplicate();
}

function AddT(text) {
	if (document.comnt.message.caretPos) document.comnt.message.caretPos.text=text;
	else document.comnt.message.value+=text;
	document.comnt.message.focus();
}

function AddST(start, end) {
	if (document.comnt.message.caretPos) document.comnt.message.caretPos.text = start + document.comnt.message.caretPos.text + end;
	else document.comnt.message.value += start + end;
	document.comnt.message.focus()
}


function copy() {
if (RichEditor){ 
	iframe.focus();	
	Editor.execCommand("copy");
	}
}

function paste() {
if (RichEditor){ 
	iframe.focus();	
	Editor.execCommand("paste");
	}
}

function cut() {
if (RichEditor){ 
	iframe.focus();	
	Editor.execCommand("cut");
	}
}


function hr() {
if (!RichEditor){ AddT("[hr]");}
else{
	iframe.focus();	
	Editor.execCommand("InsertHorizontalRule");
	}
}

function size() {

if (!RichEditor){ AddST("[font size=2]","[/font]");}
else{
	iframe.focus();
	newsize = parseInt(Editor.queryCommandValue("FontSize")) + parseInt(1);
	Editor.execCommand("FontSize", true , newsize );
	}
}


function font() {

if (!RichEditor){ AddST("[font style='font-family: Verdana']","[/font]");}
else{
fname = prompt("Enter correct FONT name you want to insert: ","Arial, Verdana, Courier, Helvetica, Script, Terminal, Comic Sans MS");
		iframe.focus();
		Editor.execCommand("FontName",true,fname);
		}
}


function center() {

if (!RichEditor){ AddST("[p align=center]","[/p]");}
else{
		iframe.focus();
		Editor.execCommand("JustifyCenter");
		}
}

function right() {

if (!RichEditor){ AddST("[p align=right]","[/p]");}
else{
		iframe.focus();
		Editor.execCommand("JustifyRight");
		}
}


function left() {

if (!RichEditor){ AddST("[p align=left]","[/p]");}
else{
		iframe.focus();
		Editor.execCommand("JustifyLeft");
		}
}


function image() {

if (!RichEditor){ AddST("[img src='","']");}
else{
img = prompt("Enter full URL location of your IMAGE: \n( JPG or GIF extension only )","http://");
		iframe.focus();
		Editor.execCommand("InsertImage",false,img);
		}
}


function move() {

if (!RichEditor){ AddST("[move]","[/move]");}
else{
		iframe.focus();
		Editor.execCommand("InsertMarquee");
		}
}


function underline() {

if (!RichEditor){ AddST("[u]","[/u]");}
else{
		iframe.focus();
		Editor.execCommand("UnderLine");
		}
}


function bold() {

if (!RichEditor){ AddST("[b]","[/b]");}
else{
		iframe.focus();
		Editor.execCommand("Bold");
		}
}

function italic() {

if (!RichEditor){ AddST("[i]","[/i]");}
else{
		iframe.focus();
		Editor.execCommand("Italic");
		}
}

function hyperlink() {

if (!RichEditor){ AddST("[a href='']","[/a]");}
else{
		iframe.focus();
		Editor.execCommand("CreateLink");
		}
}

function emai1() {

if (!RichEditor){ AddST("[a mailto:'']","[/a]");}
else{
		iframe.focus();
		Editor.execCommand("CreateLink");
		}
}

function showcode() {
if (RichEditor){
		iframe.focus();
		Editor.execCommand("RemoveFormat");
		}
}

function list() {
if (!RichEditor){ AddST("[UL]\n[LI]", "[/LI]\n[/UL]");}
else{
		iframe.focus();
		Editor.execCommand("InsertUnorderedList");
		}
}

function listnamber() {
if (!RichEditor){ AddST("[OL]\n[LI]", "[/LI]\n[/OL]");}
else{
		iframe.focus();
		Editor.execCommand("InsertOrderedList");
		}
}

function showcolor(colors) {

if (!RichEditor){ AddST("[font style='color: "+colors+"']","[/font]");}
else{
		iframe.focus();
		Editor.execCommand("foreColor",false,colors);
		}
}


function showcolorbg(colors) {

if (!RichEditor){ AddST("[font style='BACKGROUND-COLOR: "+colors+"']","[/font]");}
else{
		iframe.focus();
		Editor.execCommand("BackColor",true,colors);
		}
}

function quote() {

if (!RichEditor){ AddST("[quote]","[/quote]");}
else{
		iframe.focus();
		Editor.execCommand("InsertFieldset");
		}
}


function br() {
if (!RichEditor){ AddT("[br]");}
}














function smiley() {
if (!RichEditor){ AddT(" :)");}
else{
		iframe.focus();
		Editor.execCommand("InsertImage",false,ipath+"smiley.gif");
		}
}

function wink() {
if (!RichEditor){ AddT(" ;)");}
else{
		iframe.focus();
		Editor.execCommand("InsertImage",false,ipath+"wink.gif");
		}
}

function cheesy() {
if (!RichEditor){ AddT(" :D");}
else{
		iframe.focus();
		Editor.execCommand("InsertImage",false,ipath+"cheesy.gif");
		}
}

function grin() {
if (!RichEditor){ AddT(" ;D");}
else{
		iframe.focus();
		Editor.execCommand("InsertImage",false,ipath+"grin.gif");
		}
}

function angry() {
if (!RichEditor){ AddT(" >:(");}
else{
		iframe.focus();
		Editor.execCommand("InsertImage",false,ipath+"angry.gif");
		}
}

function sad() {
if (!RichEditor){ AddT(" :(");}
else{
		iframe.focus();
		Editor.execCommand("InsertImage",false,ipath+"sad.gif");
		}
}

function shocked() {
if (!RichEditor){ AddT(" :o");}
else{
		iframe.focus();
		Editor.execCommand("InsertImage",false,ipath+"shocked.gif");
		}
}

function cool() {
if (!RichEditor){ AddT(" 8)");}
else{
		iframe.focus();
		Editor.execCommand("InsertImage",false,ipath+"cool.gif");
		}
}

function rolleyes() {
if (!RichEditor){ AddT(" ::)");}
else{
		iframe.focus();
		Editor.execCommand("InsertImage",false,ipath+"rolleyes.gif");
		}
}

function tongue() {
if (!RichEditor){ AddT(" :P");}
else{
		iframe.focus();
		Editor.execCommand("InsertImage",false,ipath+"tongue.gif");
		}
}

function lipsealed() {
if (!RichEditor){ AddT(" :-X");}
else{
		iframe.focus();
		Editor.execCommand("InsertImage",false,ipath+"lipsealed.gif");
		}
}

function embarassed() {
if (!RichEditor){ AddT(" :-[");}
else{
		iframe.focus();
		Editor.execCommand("InsertImage",false,ipath+"embarassed.gif");
		}
}

function undecided() {
if (!RichEditor){ AddT(" :-/");}
else{
		iframe.focus();
		Editor.execCommand("InsertImage",false,ipath+"undecided.gif");
		}
}

function kiss() {
if (!RichEditor){ AddT(" :-*");}
else{
		iframe.focus();
		Editor.execCommand("InsertImage",false,ipath+"kiss.gif");
		}
}

function cry() {
if (!RichEditor){ AddT(" :'(");}
else{
		iframe.focus();
		Editor.execCommand("InsertImage",false,ipath+"cry.gif");
		}
}

