// JavaScript Document

function CMSformatText(formatting){
	document.getElementById("CMSeditor").contentWindow.document.execCommand(formatting, false, null);
}
function CMSclearFormat(){
	document.getElementById("CMSeditor").contentWindow.document.execCommand("removeformat", false, null);
	document.getElementById("CMSeditor").contentWindow.document.execCommand("unlink", false, null);
}

function cmsresize($value){
	vsize=$value;
	if (vsize!="Size"){
		document.getElementById("CMSeditor").contentWindow.document.execCommand('fontsize', false, vsize);
	}
}

function cmsfontcol($value){
	vcol="#"+$value;
	if(vcol!="Color"){
		document.getElementById("CMSeditor").contentWindow.document.execCommand('forecolor', false, vcol);
	}
}

function CMSinsertImage(){
	$image=showModalDialog("cms/image.php?random="+Math.random(999999), "Image Window", "dialogWidth:300px;dialogHeight:420px");
	if($image!="none" && $image!="undefined"){
		if (document.all){
			document.frames(0).focus();
			var vselection=document.frames(0).document.selection;
			var vrange=vselection.createRange();
			vrange.pasteHTML($image);
		} else {
			document.getElementById("CMSeditor").contentDocument.execCommand('insertHTML', false, string);
		}
	}
}

function CMSsave(){
	$html=document.getElementById("CMSeditor").contentWindow.document.body.innerHTML;
	document.getElementById("CMScontent").value=$html;
	document.getElementById("CMSupdateform").submit();
}

function CMSinsertLink(){
	document.getElementById("CMSeditor").contentWindow.document.execCommand('createlink', true, null);
}

function CMSeditTestimonials(){
	showModalDialog("cms/test.php?random="+Math.random(999999), "Image Window", "dialogWidth:300px;dialogHeight:420px");
}