var isHTMLMode = false
var isHTMLMsg = "You cannot apply formatting when in source mode.  Uncheck 'Source'.";

function button_over(btn) {
	btn.style.backgroundColor = "#eeeeee";
	btn.style.borderColor = "#ffffff #000000 #000000 #ffffff";
}
function button_out(btn) {
	btn.style.backgroundColor = "#ffffff";
	btn.style.borderColor = "#ffffff";
}
function button_down(btn) {
	btn.style.backgroundColor = "#dddddd";
	btn.style.borderColor = "#000000 #ffffff #ffffff #000000";
}
function button_up(btn) {
	btn.style.backgroundColor = "#eeeeee";
	btn.style.borderColor = "#ffffff #000000 #000000 #ffffff";
	btn = null; 
}

function get_link()
{
window.open("create_link.html","link","toolbar=0,location=0,directories=0,status=0,menubar=0, scrollbars=1,resizable=1,copyhistory=0,width=330,height=130");
}

function upload_image()
{
window.open("list.asp","upload","toolbar=0,location=0,directories=0,status=0,menubar=0, scrollbars=1,resizable=1,copyhistory=0,width=650,height=400");
}

function upload_attach(folder)
{
window.open("attach_list.asp?folder="+folder,"upload","toolbar=0,location=0,directories=0,status=0,menubar=0, scrollbars=1,resizable=1,copyhistory=0,width=650,height=400");
}

function upload_attach2(folder)
{
window.open("attach_list2.asp?folder="+folder,"upload","toolbar=0,location=0,directories=0,status=0,menubar=0, scrollbars=1,resizable=1,copyhistory=0,width=650,height=400");
}

function insertImage()
	{
  	if (isHTMLMode) {
  		alert(isHTMLMsg);
  		return;
  	}
	var sImgSrc=prompt("Please enter the location of the image: ", "");
	if(sImgSrc!=null) exec("InsertImage",sImgSrc);
	}

function insertImage2(pass_filename)
	{
  	if (isHTMLMode) {
  		alert(isHTMLMsg);
  		return;
  	}
	var sImgSrc=pass_filename;
	if(sImgSrc!=null) exec("InsertImage",sImgSrc);
	}

function insertattach_new(pass_file)
 {
	if (isHTMLMode) {
		alert(isHTMLMsg);
		return;
	}
	exec("CreateLink",pass_file+" target=_blank");
}

function insertattach_new_parent(pass_file)
 {
	if (isHTMLMode) {
		alert(isHTMLMsg);
		return;
	}
	exec("CreateLink",pass_file);
	//exec("CreateLink",pass_file+">");
}

function insertattach_new_parent2(pass_file)
 {
	if (isHTMLMode) {
		alert(isHTMLMsg);
		return;
	}
	exec2("CreateLink",pass_file);
	//exec("CreateLink",pass_file+">");
}
	
function insertattach2(pass_file)
 {
	if (isHTMLMode) {
		alert(isHTMLMsg);
		return;
	}
 exec("CreateLink",pass_file+" <tagit>");
}

function insertattach3(pass_file)
 {
	if (isHTMLMode) {
		alert(isHTMLMsg);
		return;
	}
	exec("CreateLink",pass_file);
}
	
function start() {
	document.getElementById("idContent").contentWindow.document.designMode = "On";
}
	
function start2() {
	document.getElementById("idContent2").contentWindow.document.designMode = "On";
}

	
function start3() {
	document.getElementById("idContent3").contentWindow.document.designMode = "On";
}
	
function start4() {
	document.getElementById("idContent4").contentWindow.document.designMode = "On";
}
	
function start5() {
	document.getElementById("idContent5").contentWindow.document.designMode = "On";
}
function exec(cmd,opt) {
  	if (isHTMLMode) {
  		alert(isHTMLMsg);
  		return;
  	}
  	document.getElementById("idContent").contentWindow.document.execCommand(cmd, "", opt);
  	document.getElementById("idContent").contentWindow.focus()

}

function remove() {
	alert("true");
  	if (isHTMLMode) {
  		alert(isHTMLMsg);
  		return;
  	}
  	document.getElementById("idContent").contentWindow.document.execCommand("RemoveFormat", "");
  	document.getElementById("idContent").contentWindow.focus()

}

function exec2(cmd,opt) {
  	if (isHTMLMode) {
  		alert(isHTMLMsg);
  		return;
  	}
  	document.getElementById("idContent2").contentWindow.document.execCommand(cmd, "", opt);
  	document.getElementById("idContent2").contentWindow.focus()

}

function exec3(cmd,opt) {
  	if (isHTMLMode) {
  		alert(isHTMLMsg);
  		return;
  	}
  	document.getElementById("idContent3").contentWindow.document.execCommand(cmd, "", opt);
  	document.getElementById("idContent3").contentWindow.focus()

}

function exec4(cmd,opt) {
  	if (isHTMLMode) {
  		alert(isHTMLMsg);
  		return;
  	}
  	document.getElementById("idContent4").contentWindow.document.execCommand(cmd, "", opt);
  	document.getElementById("idContent4").contentWindow.focus()

}

function exec5(cmd,opt) {
  	if (isHTMLMode) {
  		alert(isHTMLMsg);
  		return;
  	}
  	document.getElementById("idContent5").contentWindow.document.execCommand(cmd, "", opt);
  	document.getElementById("idContent5").contentWindow.focus()

}

function setMode(bMode) {
	var t;
  	isHTMLMode = bMode;
  	if (isHTMLMode) {
  		t = document.getElementById("idContent").contentWindow.document.body.innerHTML;
  		document.getElementById("idContent").contentWindow.document.body.innerText = t;
  	} else {
  		t = document.getElementById("idContent").contentWindow.document.body.innerText;
  		document.getElementById("idContent").contentWindow.document.body.innerHTML = t;
  	}
  	document.getElementById("idContent").contentWindow.focus()

}

function setMode2(bMode) {
	var t;
  	isHTMLMode = bMode;
  	if (isHTMLMode) {
  		t = document.getElementById("idContent2").contentWindow.document.body.innerHTML;
  		document.getElementById("idContent2").contentWindow.document.body.innerText = t;
  	} else {
  		t = document.getElementById("idContent2").contentWindow.document.body.innerText;
  		document.getElementById("idContent2").contentWindow.document.body.innerHTML = t;
  	}
  	document.getElementById("idContent2").contentWindow.focus()

}

function setMode3(bMode) {
	var t;
  	isHTMLMode = bMode;
  	if (isHTMLMode) {
  		t = document.getElementById("idContent3").contentWindow.document.body.innerHTML;
  		document.getElementById("idContent3").contentWindow.document.body.innerText = t;
  	} else {
  		t = document.getElementById("idContent3").contentWindow.document.body.innerText;
  		document.getElementById("idContent3").contentWindow.document.body.innerHTML = t;
  	}
  	document.getElementById("idContent3").contentWindow.focus()

}


function setMode4(bMode) {
	var t;
  	isHTMLMode = bMode;
  	if (isHTMLMode) {
  		t = document.getElementById("idContent4").contentWindow.document.body.innerHTML;
  		document.getElementById("idContent4").contentWindow.document.body.innerText = t;
  	} else {
  		t = document.getElementById("idContent4").contentWindow.document.body.innerText;
  		document.getElementById("idContent4").contentWindow.document.body.innerHTML = t;
  	}
  	document.getElementById("idContent4").contentWindow.focus()

}

function setMode5(bMode) {
	var t;
  	isHTMLMode = bMode;
  	if (isHTMLMode) {
  		t = document.getElementById("idContent5").contentWindow.document.body.innerHTML;
  		document.getElementById("idContent5").contentWindow.document.body.innerText = t;
  	} else {
  		t = document.getElementById("idContent5").contentWindow.document.body.innerText;
  		document.getElementById("idContent5").contentWindow.document.body.innerHTML = t;
  	}
  	document.getElementById("idContent5").contentWindow.focus()

}

function createLink() {
	if (isHTMLMode) {
		alert(isHTMLMsg);
		return;
	}
	exec("CreateLink");
}

function createLink2() {
	if (isHTMLMode) {
		alert(isHTMLMsg);
		return;
	}
	exec2("CreateLink");
}

function createLink3() {
	if (isHTMLMode) {
		alert(isHTMLMsg);
		return;
	}
	exec3("CreateLink");
}


function createLink4() {
	if (isHTMLMode) {
		alert(isHTMLMsg);
		return;
	}
	exec4("CreateLink");
}

function createLink5() {
	if (isHTMLMode) {
		alert(isHTMLMsg);
		return;
	}
	exec5("CreateLink");
}

function save() {
	if (isHTMLMode) {
		setMode(false);
	}
	idContentForm.page_text.value = document.getElementById("idContent").contentWindow.document.body.innerHTML;
  	idContentForm.submit();
}

function save2() {
	if (isHTMLMode) {
		setMode(false);
	}
	idContentForm.page_text.value = document.getElementById("idContent2").contentWindow.document.body.innerHTML;
  	idContentForm.submit();
}

function save3() {
	if (isHTMLMode) {
		setMode(false);
	}
	idContentForm.page_text.value = document.getElementById("idContent3").contentWindow.document.body.innerHTML;
  	idContentForm.submit();
}

function save4() {
	if (isHTMLMode) {
		setMode(false);
	}
	idContentForm.page_text.value = document.getElementById("idContent4").contentWindow.document.body.innerHTML;
  	idContentForm.submit();
}
function save5() {
	if (isHTMLMode) {
		setMode(false);
	}
	idContentForm.page_text.value = document.getElementById("idContent5").contentWindow.document.body.innerHTML;
  	idContentForm.submit();
}

function foreColor() {
	if (isHTMLMode) {
		alert(isHTMLMsg);
		return;
	}
	var retval = showModalDialog("colour_select.htm","","font-family:arial; font-size:12; dialogWidth:350px; dialogHeight:350px;");
	if (retval != null) exec("ForeColor", retval);
}
