// SLA DE PAGINA OP IN EEN DATABASE => if($_POST[content])
function sendForm(ConfirmText,CancelText) {
		if (confirm(ConfirmText)) {
			if (viewMode == 2) {
			doToggleView()
			}
			var htmlCode = iView.document.body.innerHTML; 
			document.editor.content.value = htmlCode; 
			document.editor.submit();
		}
		else {
			alert(CancelText)
		}
		
}	

// VERWIJDER DE PAGINA UIT EEN DATABASE => if($_POST[mode] == "delete")
function deleteRecord() {
		alert("dit is een demo, je moet ff in de source regel 29,30 en 35 verwijderen.");
		if(false){
		if (confirm("Sure you want to delete this page?")) {
			document.editor.mode.value = "delete";
			document.editor.submit();
		}
		}
}

function readyDiv() {
	var theHTML;
	theHTML = document.all.tags('div')['pageHTML'].innerText;
	document.all.tags('div')['pageHTML'].innerHTML = theHTML;
}

function cmdExec(cmd,opt) {
	if (viewMode == 1) {
		iView.document.execCommand(cmd,"",opt);
		iView.focus();
	}
}

function insertHTML(htm) {
	sRange = iView.document.selection.createRange();
	sRange.pasteHTML(htm);
	//iView.focus();
}

function insertLink() {
	newLink = window.showModalDialog( Pad+'cms/link.php','Link','dialogHeight: 420px; dialogWidth: 300px; resizable: Yes; status: No;');
	if (newLink) {
		start = "<a href="+newLink.url+" target="+newLink.target+">";
		end = "</a>";
		selectedRange = iView.document.selection.createRange();
		if (selectedRange.htmlText) {	
			htm = start + selectedRange.htmlText + end ;
			insertHTML(htm);
		}
	}
}

function insertPic(naamForm,naamVeld) {
	window.open( 'modules/produkten/imagesprod.php?naamform=' +naamForm+ '&naamveld=' +naamVeld ,'pic','Height=550, Width=550');
}

function insertDoc(naamForm,naamVeld) {
	window.open( 'modules/produkten/docsprod.php?naamform=' +naamForm+ '&naamveld=' +naamVeld ,'doc','Height=550, Width=550, status ');
}

function insertMail() {
	newLink = window.showModalDialog( Pad+'cms/mail.php','Mail','dialogHeight: 420px; dialogWidth: 300px; resizable: Yes; status: No;');
	if (newLink) {
		start = "<a href=mailto:"+newLink.url+" >";
		end = "</a>";
		selectedRange = iView.document.selection.createRange();
		if (selectedRange.htmlText) {	
			htm = start + selectedRange.htmlText + end ;
			insertHTML(htm);
		}
	}
}


function changeColor() {
	newColor = window.showModalDialog( Pad+'cms/color.php','Color','dialogHeight: 250px; dialogWidth: 400px; resizable: Yes; status: No;');
	cmdExec('foreColor',newColor);
}

function createTable(val) {
	iView.focus();
	cols = val.charAt(1);
	rows = val.charAt(0);
	var table = '<table border="0" width="100%">\n';
    for (var i = 0; i < rows; ++i){
      table += "<tr>\n"
      for (var j=0; j < cols; ++j){
        table += '<td bgcolor="#f0f0f0">&nbsp;</td>\n';
      }
      table += "</tr>\n";
    }
    table += "</table>\n";
	insertHTML(table);
}

function doUploadDocs(file) {
	iView.focus();
	html = "<a target=_blank href='"+ULpad+"docs/"+file+"'>"+file+"</a>" ;
	insertHTML(html);
}


function doUpload(pictureName, align, vspace, hspace) {
	iView.focus();
	imgSrc = ULpad+"images/"+pictureName ;
	htm = "<img src="+imgSrc+" border=0  hspace="+hspace+"  vspace="+vspace+"  align="+align+">" ;
	selectedRange = iView.document.selection.createRange();
	insertHTML(htm);
}

function doToggleView() 
{ 
	if(viewMode == 1) 
	{ 
	iHTML = iView.document.body.innerHTML; 
	iView.document.body.innerText = iHTML; 
	viewMode = 2; // Code 
	} else { 
	iText = iView.document.body.innerText; 
	iView.document.body.innerHTML = iText; 
	viewMode = 1; // WYSIWYG 
	} 
} 
