
//  ------------------------------------------------------------------------------------------------------
//	Volgende Scripts zijn voor de externe HTML WYSIWYG/Evident Editor
//  ------------------------------------------------------------------------------------------------------
//	Versie 2
//
//	09 Sep 2002 15:57:22 GMT - Guido Kleijer
//
//	LET OP:	Somige paden dienen te worden gewijzigd.




function eviEdit_rightClickMenu(iFrm, iFrmEvent, sEdName) {
	var mnu = document.getElementById(sEdName + '_menu');
	eviEd_divInPopup(sEdName + '_menu',100, 60, '#FFFFFF', '0px');

}


function eviEd_divInPopup(divID, pWidth, pHeight, pBGColor, pBorderStyle)
{
	//	<div style="visibility:hidden;display:none;">
	//		<div id="myDiv">
	//			this is the div which will be shown in the popup
	//		</div>
	//	</div>
	//	<input type="button" onClick="divInPopup('divfonts', 150,175, 'threedface', 'solid black 1px');" value="show">
	//
	//	use window.parent.myFunction to call functions in the caller document.
	//
	var oPopup = window.createPopup();
    var oPopBody = oPopup.document.body;
    oPopBody.style.backgroundColor = pBGColor;
    oPopBody.style.border = pBorderStyle;
    var lefter = event.clientX+10;
    var topper = event.clientY+10;
    oPopBody.innerHTML = document.getElementById(divID).innerHTML;
    oPopup.show(lefter, topper, pWidth, pHeight, document.body);
}

function button_over(eButton)
	{
	eButton.style.border="threedface 1px solid";
	eButton.style.backgroundColor = "silver";
	eButton.style.borderColor = "threedhighlight threedshadow threedshadow threedhighlight";
	}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




function setMode(iFrameContent, editMode, divEditMode)
	{
	var sTmp;
  	if (editMode.value=='0')
		{		
			sTmp = iFrameContent.document.body.innerHTML;
			iFrameContent.document.body.innerText=sTmp;
			divEditMode.innerHTML = "<table width='60px' height='20px' cellspacing='0' cellpading='0'><tr><td valign='middle' align='center' style='font-family : Arial; font-size : 11px;'>HTML</td></tr></table>";
			editMode.value = '1';
		} else {
			sTmp = iFrameContent.document.body.innerText;
			iFrameContent.document.body.innerHTML=sTmp;
			divEditMode.innerHTML = "<table width='60px' height='20px' cellspacing='0' cellpading='0'><tr><td valign='middle' align='center' style='font-family : Arial; font-size : 11px;'>WYSIWYG</td></tr></table>";
			editMode.value = '0';
		}
  	iFrameContent.focus();
	}


function onBlurSave(iFrameContent, editMode, divEditMode, storeElementName)
	{
		var sTmp;
		if (editMode.value=='1') {		
				sTmp = iFrameContent.document.body.innerText;
				iFrameContent.document.body.innerHTML=sTmp;
				divEditMode.innerHTML = "<table width='60px' height='20px' cellspacing='0' cellpading='0'><tr><td valign='middle' align='center' style='font-family : Arial; font-size : 11px;'>WYSIWYG</td></tr></table>";
				document.getElementById(storeElementName).value = iFrameContent.document.body.innerHTML;
				editMode.value='0';
			} else {
				document.getElementById(storeElementName).value = iFrameContent.document.body.innerHTML;
			}		
	}


//	IFrame execCommand Wrapper functie
function cmdExec(editMode, iFrameContent, cmd, opt) 
	{
		if (editMode=='0')
		{
  			iFrameContent.document.execCommand(cmd,"",opt)
  			iFrameContent.focus();
		}
	}
 
//	waarde van geselecteerde tekst in iframe bepalen en veranderen.
function valueToSelection(editMode, iFrameContent, myValue)
	{
		if (editMode=='0')
		{
			var sel;
			var range;
			sel = iFrameContent.document.selection;
			range = sel.createRange();		
			if (range!=null) {
				range.pasteHTML(myValue);
			}
		}
	}



function setAnchor(editMode, iFrameContent)
	{
	if (editMode=='0') 
		{	
			iFrameContent.focus();
			var arr = window.showModalDialog("/fsmk/include/evi_client_editor/dialog_anchor.html","","dialogHeight: 210px; dialogWidth: 286px; dialogTop: center; dialogLeft: center; edge: Raised; center: Yes; help: No; resizable: No; status: No;"); 
			if (arr!=null) {			
				valueToSelection(editMode, iFrameContent, arr)
			}			
		}
	}


function createLink(editMode, iFrameContent)
	{
	if (editMode=='0') 
		{	
			cmdExec(iFrameContent, "CreateLink");
		}
	}

function foreColor(editMode, iFrameContent, eButton)
	{
	if (editMode=='0') 	
		{
			var arr = window.showModalDialog("/fsmk/include/evi_client_editor/dialog_color.html","","dialogHeight: 341px; dialogWidth: 280px; dialogTop: center; dialogLeft: center; edge: Raised; center: Yes; help: No; resizable: No; status: No;"); 
			if (arr!=null) {
				cmdExec(editMode, iFrameContent, "ForeColor", arr);
			}
		}
	}

function backColor(editMode, iFrameContent, eButton)
	{
	if (editMode=='0') 	 
		{
	
			var arr = window.showModalDialog("/fsmk/include/evi_client_editor/dialog_color.html","","dialogHeight: 341px; dialogWidth: 280px; dialogTop: center; dialogLeft: center; edge: Raised; center: Yes; help: No; resizable: No; status: No;"); 
			if (arr!=null) {
				cmdExec(editMode, iFrameContent, "BackColor", arr);
			}
		}
	}
	
function showEditorHelp()
	{
		window.showModalDialog("/fsmk/include/evi_client_editor/help.html","","dialogHeight: 530px; dialogWidth: 750px; dialogTop: center; dialogLeft: center; edge: Raised; center: Yes; help: No; resizable: No; status: No;"); 
	}

function insertCharacter(editMode, iFrameContent, eButton) 
	{
	if (editMode=='0') 	
		{	
			iFrameContent.focus();
			var arr = window.showModalDialog("/fsmk/include/evi_client_editor/dialog_charmap.html","","dialogHeight: 322px; dialogWidth: 276px; dialogTop: center; dialogLeft: center; edge: Raised; center: Yes; help: No; resizable: No; status: No;"); 
			if (arr!=null) {			
				valueToSelection(editMode, iFrameContent, arr)
			}			
		}
	}


function setFont(editMode, iFrameContent, eButton)
	{
	if (editMode=='0') 	
		{	
			iFrameContent.focus();
			var arr = window.showModalDialog("/fsmk/include/evi_client_editor/dialog_font.html","","dialogHeight: 290px; dialogWidth: 340px; dialogTop: center; dialogLeft: center; edge: Raised; center: Yes; help: No; resizable: No; status: No;"); 
			if (arr!=null) {			
				cmdExec(editMode, iFrameContent, "FontName",  arr[0]);
				cmdExec(editMode, iFrameContent, "FontSize",  arr[1]);
			}			
		}
	}


function setFontDirect(iFrameContent, font_name, font_size) {
	cmdExec(0, iFrameContent, "FontName",  font_name);
	cmdExec(0, iFrameContent, "FontSize",  font_size);	
}

function setFontByDiv(editMode, iFrameContent, eButton) {
	if (editMode=='0') 	
		{	
			divInPopup('divfonts', 353,202, 'threedface', 'solid threedhighlight 1px');
		}
}



function setFontSize(editMode, iFrameContent, eButton)
	{
	if (editMode=='0') 	
		{	
			iFrameContent.focus();
			var arr = window.showModalDialog("/fsmk/include/evi_client_editor/dialog_fontsize.html","","dialogHeight: 250px; dialogWidth: 245px; dialogTop: center; dialogLeft: center; edge: Raised; center: Yes; help: No; resizable: No; status: No;"); 
			if (arr!=null) {			
				cmdExec(editMode, iFrameContent, "FontSize",  arr[0]);
			}			
		}
	}


function insertImage(editMode, iFrameContent, eButton, nameEditor) 
	{
	var oTemplateBuffer = document.getElementById(nameEditor + "_template_buffer")
	if (editMode=='0') 	
		{	
			iFrameContent.focus();
			var arr = window.showModalDialog("/fsmk/include/evi_imagebank/imagebank.asp?view_mode=1",oTemplateBuffer,"dialogHeight: 575px; dialogWidth: 629px; dialogTop: center; dialogLeft: center; edge: Raised; center: Yes; help: No; resizable: No; status: No;"); 
			var s = "";
			if (arr!=null) {
				if ((arr[1]=='')|(arr[1]==null)) {arr[1]='Titel onbekend';}
				if ((arr[2]=='image/pjpeg')|(arr[2]=='image/jpeg')) {
					if (arr[5]==false) {					
						if (arr[4]==false) {
							var s = "<img src='/fsmk/include/evi_imagebank/img.asp?id=" + arr[0] + "&number=1&object_type=0&src=image' alt='" + arr[1] + "' align='" + arr[3] + "' border='0'>"
						} else {
							var s = "<a href='/fsmk/include/evi_imagebank/img.asp?id=" + arr[0] + "&number=1&object_type=0&src=image' target='_blank' border='0'> <img border='0' src='/fsmk/include/evi_imagebank/img.asp?id=" + arr[0] + "&number=1&object_type=0&src=imagethumb' alt='" + arr[1] + "' align='" + arr[3] + "'></a>"
						}
					} else {
						if (arr[4]==false) {
							var s = "<img src='/fsmk/include/evi_imagebank/img.asp?id=" + arr[0] + "&number=1&object_type=0&src=image&download=1' alt='" + arr[1] + "' align='" + arr[3] + "' border='0'>"
						} else {
							var s = "<a href='/fsmk/include/evi_imagebank/img.asp?id=" + arr[0] + "&number=1&object_type=0&src=image&download=1' border='0'> <img border='0' src='/fsmk/include/evi_imagebank/img.asp?id=" + arr[0] + "&number=1&object_type=0&src=imagethumb' alt='" + arr[1] + "' align='" + arr[3] + "'></a>"
						}					
					}
				}
				
				if (arr[2]=='image/gif') {
					if (arr[5]==false) {
						var s = "<img src='/fsmk/include/evi_imagebank/img.asp?id=" + arr[0] + "&number=1&object_type=0&src=image' alt='" + arr[1] + "' align='" + arr[3] + "' border='0'>"
					} else {
						var s = "<a href='/fsmk/include/evi_imagebank/img.asp?id=" + arr[0] + "&number=1&object_type=0&src=image&download=1' alt='" + arr[1] + "'>" + arr[1] + "</a>"
					}
				}
				
				if ((arr[2]=='video/mpeg')|(arr[2]=='video/mpg')|(arr[2]=='video/avi')|(arr[2]=='video/divx')) {
					if (arr[5]==false) {
						var s = "<img dynsrc='/fsmk/include/evi_imagebank/img.asp?id=" + arr[0] + "&number=1&object_type=0&src=image' alt='" + arr[1] + "' align='" + arr[3] + "' border='0'>"				
					} else {
						var s = "<a href='/fsmk/include/evi_imagebank/img.asp?id=" + arr[0] + "&number=1&object_type=0&src=image&download=1' alt='" + arr[1] + "'>" + arr[1] + "</a>"					
					}
				}
				
				if (arr[2]=='application/x-shockwave-flash') {
					if (arr[5]==false) {
						var s = "";
						s = s + "<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='100px' align='" + arr[3] + "' height='100px' codebase='http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0' ID='evident_flash'>"
						s = s + "<PARAM NAME=movie VALUE='/fsmk/include/evi_imagebank/img.asp?id=" + arr[0] + "&number=1&object_type=0&src=image'>"
						s = s + "<PARAM NAME=menu VALUE=false>"
						s = s + "<PARAM NAME=quality VALUE=high>"
						s = s + "<PARAM NAME=bgcolor VALUE=#FFFFFF>" 
						s = s + "<EMBED src='/fsmk/include/evi_imagebank/img.asp?id=" + arr[0] + "&number=1&object_type=0&src=image' menu='false' quality='high' bgcolor='#FFFFFF' WIDTH='100px' HEIGHT='100px' TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'></EMBED>"
						s = s + "</OBJECT>"
					} else {
						var s = "<a href='/fsmk/include/evi_imagebank/img.asp?id=" + arr[0] + "&number=1&object_type=0&src=image&download=1' alt='" + arr[1] + "'>" + arr[1] + "</a>"
					}
				}
				
				if (s=='') {
					if (arr[5]==false) {
						var s = "<a href='/fsmk/include/evi_imagebank/img.asp?id=" + arr[0] + "&number=1&object_type=0&src=image' target='_blank' alt='" + arr[1] + "'>" + arr[1] + "</a>"
					} else {
						var s = "<a href='/fsmk/include/evi_imagebank/img.asp?id=" + arr[0] + "&number=1&object_type=0&src=image&download=1' alt='" + arr[1] + "'>" + arr[1] + "</a>"
					}
				}						
				valueToSelection(editMode, iFrameContent, s)
			}			
		}
	}
	

function setSingleCrossLinkEditor(editMode, iFrameContent, eButton, nameEditor)	 
{
	var portal_site_id = null;
	var site_id = null;
	var language_version_id = null;
	var flexsite_module_name = '';
	
	var oTemplateBuffer = document.getElementById(nameEditor + "_template_buffer")
	if (editMode=='0') 	
	{	
		iFrameContent.focus();
		var arr_input = new Array(2);
		arr_input[0] = site_id;
		arr_input[1] = language_version_id;
		arr_input[2] = flexsite_module_name;
		arr_input[3] = portal_site_id;
	
		// following used for dialog returnvalues (output)
		var arr_output = new Array(4);
		arr_output[0] = ''; // title
		arr_output[1] = ''; // to_module_id
		arr_output[2] = 0; // to_item_id
		arr_output[3] = ''; // item_url
		arr_output[4] = 0; // to_site_id	
		var arr_output = window.showModalDialog("/crosslinks_v2/crosslink_selector_dialog.html", arr_input ,"dialogHeight: 545px; dialogWidth: 520px; dialogTop: center; dialogLeft: center; edge: Raised; center: Yes; help: No; resizable: No; status: Yes;"); 
		if (arr_output!=null)
		{
			var url = arr_output[3];
			var title = arr_output[0];
			valueToSelection(editMode, iFrameContent, "<a href='" + url + "'>" + title + "</a>")
		}
	}
}


function insertTable(editMode, iFrameContent, eButton) 
	{
	if (editMode=='0') 	
		{	
			iFrameContent.focus();
			var arr = window.showModalDialog("/fsmk/include/evi_client_editor/dialog_table.html","Tabel invoegen","dialogHeight: 630px; dialogWidth: 625px; dialogTop: center; dialogLeft: center; edge: Raised; center: Yes; help: No; resizable: No; status: No;"); 
			if (arr!=null) {	
				valueToSelection(editMode, iFrameContent, arr)
			}		 	
		}
	}

function insertEditPlaceHolder(editMode, iFrameContent, eButton) 
	{	
	if (editMode=='0') 	
		{	
			var sel = iFrameContent.document.selection;
			var range = sel.createRange();
			var arr = new Array(2);
			var addNew;
			if ((sel.type=='Control')&&(range(0).alt=='placeholder')) {
				arr[0] = range(0).id; // placeholder_id 
				arr[1] = range(0).name; // plugin_name
				arr[2] = ''; // description
				addNew = true;
			} else {
				arr[0] = null;
				arr[1] = null;
				arr[2] = null;
			}
			iFrameContent.focus();
			var arr = window.showModalDialog("/fsmk/include/evi_client_editor/place_holder.html", arr ,"dialogHeight: 470px; dialogWidth: 620px; dialogTop: center; dialogLeft: center; edge: Raised; center: Yes; help: No; resizable: No; status: No;"); 
			if (arr!=null) {
				sel.clear
				var sel = iFrameContent.document.selection;
				var range = sel.createRange();
				if (arr[0]!='') {
					s = "<TEXTAREA id=\"" + arr[0] + "\" style=\"BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; OVERFLOW: hidden; WIDTH: 200px; COLOR: #000000; FONT-STYLE: normal; HEIGHT: 15px; BACKGROUND-COLOR: #008000; BORDER-RIGHT-WIDTH: 0px; FONT-VARIANT: normal\" disabled name=\"" + arr[1] + "\" rows=1 readOnly cols=10 align=\"justify\" alt=\"placeholder\">" + arr[2] + " - " + arr[0] + "</TEXTAREA>";
				} else {
					s = "<TEXTAREA id=\"0\" style=\"BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; OVERFLOW: hidden; WIDTH: 200px; COLOR: #000000; FONT-STYLE: normal; HEIGHT: 15px; BACKGROUND-COLOR: #008000; BORDER-RIGHT-WIDTH: 0px; FONT-VARIANT: normal\" disabled name=\"" + arr[1] + "\" rows=1 readOnly cols=10 align=\"justify\" alt=\"placeholder\">" + arr[2] + "</TEXTAREA>";
				}
				range.pasteHTML(s);	
			}
			
		}
	}


function insertLink(editMode, iFrameContent, eButton) 
	{
	if (editMode=='0') 	
		{	
			iFrameContent.focus();
			var s = GetSelectedText(editMode, iFrameContent);
			var arr = window.showModalDialog("/fsmk/include/evi_client_editor/dialog_link.html", s, "dialogHeight: 165px; dialogWidth: 320px; dialogTop: center; dialogLeft: center; edge: Raised; center: Yes; help: No; resizable: No; status: No;"); 
			if (arr!=null) {	
				valueToSelection(editMode, iFrameContent, arr)
			}			
		}
	}


function waarde_naar_iFrameContent(iFrameContent, htmlElement)
	{
		iFrameContent.document.write("<body style='font-family : Arial; font-size : x-small;';></body>");
		iFrameContent.document.body.innerHTML = htmlElement.value;
	}


function GetSelectedText(editMode, iFrameContent)
	{
		if (editMode=='0')
		{
			var sel;
			var range;
			sel = iFrameContent.document.selection;
			range = sel.createRange();
			return range.text;
		}
	}

function GetSelectedHTML(editMode, iFrameContent)
	{
		if (editMode=='0')
		{
			var sel;
			var range;
			sel = iFrameContent.document.selection;
			range = sel.createRange();
			return range.htmlText;
		}
	}

