function init(){
	incluidos=init.arguments;
	for(i=0;i<incluidos.length;i++){
		var cuerpo=document.body.innerHTML;
		html="<table><tr><td valign=\"top\"><img src=\"http://www.lanzaroterock.com/imagenes/bbcode/bold.gif\" width=\"21\" height=\"20\" onclick=\"instag('b','"+incluidos[i]+"')\" onmouseover=\"this.style.border='solid 1px #000000';\" onMouseOut=\"this.style.border='solid 1px #B4C6B6';\" style=\"border:solid 1px #B4C6B6;\" title=\"Negrita\">&nbsp;<img src=\"http://www.lanzaroterock.com/imagenes/bbcode/underline.gif\" width=\"21\" height=\"20\" onclick=\"instag('u','"+incluidos[i]+"')\" onmouseover=\"this.style.border='solid 1px #000000';\" onmouseout=\"this.style.border='solid 1px #B4C6B6';\" style=\"border:solid 1px #B4C6B6;\" title=\"Subrayado\">&nbsp;<img src=\"http://www.lanzaroterock.com/imagenes/bbcode/italic.gif\" width=\"21\" height=\"20\" onclick=\"instag('i','"+incluidos[i]+"')\" onmouseover=\"this.style.border='solid 1px #000000';\" onmouseout=\"this.style.border='solid 1px #B4C6B6';\" style=\"border:solid 1px #B4C6B6;\" title=\"Cursiva\">&nbsp;<img src=\"http://www.lanzaroterock.com/imagenes/bbcode/link.gif\" width=\"21\" height=\"20\" onclick=\"inslink('"+incluidos[i]+"')\" onmouseover=\"this.style.border='solid 1px #000000';\" onmouseout=\"this.style.border='solid 1px #B4C6B6';\" style=\"border:solid 1px #B4C6B6;\" title=\"Insertar enlace\">&nbsp;<img src=\"http://www.lanzaroterock.com/imagenes/bbcode/insertimage.gif\" width=\"21\" height=\"20\" onclick=\"captura_imag('"+incluidos[i]+"')\" onmouseover=\"this.style.border='solid 1px #000000';\" onmouseout=\"this.style.border='solid 1px #B4C6B6';\" style=\"border:solid 1px #B4C6B6;\" title=\"Insertar imagen\">&nbsp;<img src=\"http://www.lanzaroterock.com/imagenes/bbcode/youtube.gif\" width=\"21\" height=\"20\" onclick=\"captura_youtube('"+incluidos[i]+"')\" onmouseover=\"this.style.border='solid 1px #000000';\" onmouseout=\"this.style.border='solid 1px #B4C6B6';\" style=\"border:solid 1px #B4C6B6;\" title=\"Insertar vídeo de YouTube\">&nbsp;<img src=\"http://www.lanzaroterock.com/imagenes/bbcode/smile.gif\" width=\"21\" height=\"20\" onclick=\"ventana_emot('"+incluidos[i]+"')\" onmouseover=\"this.style.border='solid 1px #000000';\" onmouseout=\"this.style.border='solid 1px #B4C6B6';\" style=\"border:solid 1px #B4C6B6;\" title=\"Insertar emoticon\">&nbsp;<img src=\"http://www.lanzaroterock.com/imagenes/bbcode/quote.gif\" width=\"21\" height=\"20\" onclick=\"instag('cita','"+incluidos[i]+"')\" onmouseover=\"this.style.border='solid 1px #000000';\" onmouseout=\"this.style.border='solid 1px #B4C6B6';\" style=\"border:solid 1px #B4C6B6;\" title=\"Citar\">&nbsp;</td><td valign=\"top\"><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><img src=\"http://www.lanzaroterock.com/imagenes/bbcode/resize_0.gif\" width=\"21\" height=\"9\"  onclick=\"quitar('"+incluidos[i]+"')\" onmouseover=\"this.style.border='solid 1px #000000';\" onmouseout=\"this.style.border='solid 1px #B4C6B6';\" style=\"border:solid 1px #B4C6B6;\" title=\"Disminuir tama&ntilde;o\"></td></tr><tr><td><img src=\"http://www.lanzaroterock.com/imagenes/bbcode/resize_1.gif\" width=\"21\" height=\"9\" id=\"quita\"  onclick=\"agregar('"+incluidos[i]+"')\" onmouseover=\"this.style.border='solid 1px #000000';\" onmouseout=\"this.style.border='solid 1px #B4C6B6';\" style=\"border:solid 1px #B4C6B6;\" title=\"Aumentar tama&ntilde;o\"></td></tr></table></td></tr></table><textarea name=\""+incluidos[i]+"\" cols=\"75\" rows=\"7\" id=\""+incluidos[i]+"\">";
		pat="<textarea+[^>]*"+incluidos[i]+"+[^<]+"; 	
		patron =new RegExp(pat,"gi");
		coincidencias=new Array();
		coincidencias=cuerpo.match(patron);
		for(j=0;j<coincidencias.length;j++){
			result=new Array();
			result=coincidencias[j].match(/\s+id=[^>\s]+/g);
			result[0]=result[0].split('"').join(''); 
			result[0]=result[0].split('id=').join(''); 
			result[0]=result[0].split(' ').join(''); 
			if(result[0]==incluidos[i]){
				valor=new Array();
				valor2='';
				valor=coincidencias[j].split('>');
				if(valor.length>1){
						for(k=1;k<valor.length;k++){
							valor2+=valor[k];
						}
					}
				cuerpo2=cuerpo.split(coincidencias[j]);
			}
		}
		
		document.body.innerHTML=cuerpo2[0]+html+valor2+cuerpo2[1];
	}
}
function instag(tag,campo){
	var input = document.getElementById(campo);
		if(typeof document.selection != 'undefined' && document.selection) {
			var str = document.selection.createRange().text;
			input.focus();
			var sel = document.selection.createRange();
			sel.text = "[" + tag + "]" + str + "[/" +tag+ "]";
			sel.select();
			return;
		}
		else if(typeof input.selectionStart != 'undefined'){
			var start = input.selectionStart;
			var end = input.selectionEnd;
			var insText = input.value.substring(start, end);
			input.value = input.value.substr(0, start) + '['+tag+']' + insText + '[/'+tag+']'+ input.value.substr(end);
			input.focus();
			input.setSelectionRange(start+2+tag.length+insText.length+3+tag.length,start+2+tag.length+insText.length+3+tag.length);
			return;
		}
		else{
			input.value+=' ['+tag+']Reemplace este texto[/'+tag+']';
			return;
		}
}
function inslink(campo){
	var input = document.getElementById(campo);
		if(typeof document.selection != 'undefined' && document.selection) {
			var str = document.selection.createRange().text;
			input.focus();
			var my_link = prompt("Ingresar URL:","http://");
				if (my_link != null) {
					if(str.length==0){
						str=my_link;
					}
					var sel = document.selection.createRange();
					sel.text = "[url=" + my_link + "]" + str + "[/url]";
					sel.select();
					}
			return;
		}else if(typeof input.selectionStart != 'undefined'){
					var start = input.selectionStart;
					var end = input.selectionEnd;
					var insText = input.value.substring(start, end);
					var my_link = prompt("Ingresar URL:","http://");
						if (my_link != null) {
							if(insText.length==0){
								insText=my_link;
							}
							input.value = input.value.substr(0, start) +"[url=" + my_link +"]" + insText  + "[/url]"+ input.value.substr(end);
							input.focus();
							input.setSelectionRange(start+11+my_link.length+insText.length+4,start+11+my_link.length+insText.length+4);
						}
			return;
		}else{
			var my_link = prompt("Ingresar URL:","http://");
			var my_text = prompt("Ingresar el texto del link:","");
			input.value+=" [url=" + my_link +  "]" + my_text + "[/url]";
			return;
		}
}
var reng=5;
function agregar(area){
	document.getElementById('quita').disabled=false;
	reng=reng+5;
	document.getElementById(area).rows=reng;
}
function quitar(area){
	reng=reng-5;
		if(reng<6){reng=5;
		}
	document.getElementById(area).rows=reng;
}
function ventana_emot(area){
	coordx=screen.width?(screen.width-300)/2:0;
	coordy=screen.height?(screen.height-150)/2:0;
	window.open("http://www.lanzaroterock.com/imagenes/bbcode/emoticons/emoticons.html?campo="+area,"EMOTICONS","width=300,height=150,menubar=no,resizable=yes,left="+coordx+",top="+coordy);
}
function ins_imag(emot,area){
	var input = document.getElementById(area);
		if(typeof document.selection != 'undefined' && document.selection) {
			var str =document.selection.createRange().text;
			input.focus();
			var sel =document.selection.createRange();
			sel.text = str + emot;
			sel.select();
			return;
		}
		else if(typeof input.selectionStart != 'undefined'){
			var start = input.selectionStart;
			var end = input.selectionEnd;
			var insText = input.value.substring(start, end);
			input.value = input.value.substr(0, start) + insText+ emot + input.value.substr(end);
			input.focus();
			input.setSelectionRange(end+emot.length,end+emot.length);
			return;
		}
		else{
			input.value+=emot;
			return;
		}
}
function captura_imag(area){
	var my_link = prompt("Ingresar URL de la imagen:","http://");
		if (my_link != null) {
			ins_imag('[img='+my_link+']',area);
		}
}

function captura_youtube(area){
	var my_link = prompt("Ingresar URL del vídeo de YouTube:","http://");
		if (my_link != null) {
			ins_imag('[youtube='+my_link+']',area);
		}
}