function Init() { 
	 iView.document.designMode = 'On'; 
	 iView.focus();
} 

function esegui(comando, opt) {
	if (opt == null) {
		opt = "";
	}
	iView.document.execCommand(comando,false,opt);
}
function creaTabella(larghezza, righe, colonne, bordo, cellpad, cellspa) {
	var tabella = iView.document.createElement("table");
	var mytablebody = iView.document.createElement("TBODY");
	
   tabella.setAttribute("cellpadding",cellpad);
   tabella.setAttribute("cellspacing",cellspa);
   tabella.setAttribute("border",bordo);
   tabella.setAttribute("width",larghezza);
   for (i=1;i<=righe;i++) {
		var mycurrent_row=iView.document.createElement("TR");
		for (j=1;j<=colonne;j++) {
			var mycurrent_cell=iView.document.createElement("TD");
   		var currenttext=iView.document.createTextNode("-");
   		mycurrent_cell.appendChild(currenttext);   		
   		mycurrent_row.appendChild(mycurrent_cell);
   	}
   	mytablebody.appendChild(mycurrent_row);
   }
   tabella.appendChild(mytablebody);
   iView.document.getElementsByTagName("body").item(0).appendChild(tabella);
}

function selezioneTabella() {
	var elemento = iView.document.getElementsByTagName("table").item(0).deleteRow(0);	
}

function cambiaCarattere(modulo) {
	esegui('fontname',modulo.font.value);
	modulo.font.selectedIndex = 0;
	iView.focus();
}

function dimFont(modulo) {
	esegui('fontsize',Number(modulo.dimensione.value));
	//modulo.dimensione.selectedIndex = 2;
	iView.focus();
}

function cambiaBg() {
	esegui('BackColor','#000000');
	iView.focus();
}

function centraTesto() {
	esegui('JustifyCenter');
	iView.focus();
}
function destraTesto() {
	esegui('JustifyRight');
	iView.focus();
}
function sinistraTesto() {
	esegui('JustifyLeft');
	iView.focus();
}

function creaLink(pagina) {
	
	esegui('CreateLink', pagina);
	//iView.document.body.innerHTML += "<a href=\"" + pagina + "\" class=\"Subscribe2\" target=\"_blank\"></a>";
	
}

function insertImage(imagePath) {
	iView.document.body.innerHTML += "<img src=\"" + imagePath + "\" border=\"0\">";
	//alert("ciao");
}

function insertLink(linkPath, imgPath, fileEdit){
	iView.document.body.innerHTML += "<a href=\"" + linkPath + "\" class=\"Subscribe2\" target=\"_blank\">"+ fileEdit +"<img src=\"images/file/" + imgPath + "\" border=\"0\"></a>";
}

function Preview() {
 	var winPro;
 	winPro = "scrollbars=yes,resizable=no,width=300,height=300,status=yes,location=no,toolbar=no";
     
   searchWin = window.open('','prev',winPro);
   
   setTimeout("searchWin.document.write(iView.document.body.innerHTML)",500);
   
}

function OpenToolFrame(page, w, h, instance) {
	var winPro;
 	winPro = "scrollbars=yes,resizable=no,width=" + w + ",height=" + h + ",status=no,location=no,toolbar=no";
   searchWin = window.open(page,instance,winPro);
}

function OpenToolFrame2(page, w, h, instance) {
	var winPro;
 	winPro = "scrollbars=yes,resizable=no,width=" + w + ",height=" + h + ",scrollbars=no, status=no,location=no,toolbar=no";
   searchWin = window.open(page,instance,winPro);
}

function visHtml(modulo) {
	if (modulo.checkbox1.checked) {
		iView.document.body.innerText = iView.document.body.innerHTML;
	} else {
		iView.document.body.innerHTML = iView.document.body.innerText;
	}
}
