function loadIframe(iframe){
		if(document.getElementById){
			getIFrameDocument(iframe).designMode = "On";
		}
		if (document.all){
			document.frames[iframe].document.onkeydown = carrigereturn;
		}
    }
    
    function getIFrameDocument(aID){
      if (document.getElementById(aID).contentDocument ){ 
        return document.getElementById(aID).contentDocument;
      } else{
        return document.frames[aID].document;
       }
	
     }

function putTags(iframe,tag,atributo)	
{
		setFocus(iframe);
		var iframeDocument=getIFrameDocument(iframe);
		var direccion="";
		var pathImg="/foro/smilies/";
		
		if (tag=="insertimage"){
			atributo=pathImg+atributo.substring(atributo.lastIndexOf("/")+1);
			}
			
		 if (tag=="createLink"){ 
		 	
		 	if (document.all){		 	
			 	if (isEmpty(iframeDocument.selection.createRange().text))
					alert("Seleccione un texto para crear un enlace");
	 			else{
			 		direccion=prompt("Introduzca la dirección  del enlace:","http://");
			 		if (direccion!=null && !isEmpty(direccion))
	 				{
	 					var texto=iframeDocument.selection.createRange().text;
	 					iframeDocument.selection.createRange().pasteHTML('<A href="'+direccion+'" target=_blank>'+texto+'</A>');
	 				}
	 			    }
	 		}
	 		else{
	 			var textoMarcado=iframeDocument.getSelection();
	 			
	 			if (isEmpty(textoMarcado)){
	 				alert("Seleccione un texto para crear un enlace");
	 			}
	 			else{
			 		direccion=prompt("Introduzca la dirección  del enlace:","http://");
			 		if (direccion!=null && !isEmpty(direccion))
	 				{
	 					iframeDocument.execCommand(tag,false,direccion);
	 				}
	 			    }
	 		
	 		}
	 	}
		else{
 			iframeDocument.execCommand(tag,false,atributo);
 		}

		setFocus(iframe);

}

function setFocus(iframe){
	if (document.all){
		document.frames[iframe].focus();
	}
	else{
		document.getElementById(iframe).contentWindow.focus();
	}
}

function clearIframe(iframe){
	document.getElementById(iframe).src="blank.html";
	getIFrameDocument(iframe).designMode = "On";

}
