// JavaScript Document

function instag(tag,Acampo){
	var input = document.getElementById(Acampo);
	//para mac
	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+ ">";
		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);
		return;
	}
	else
	{
		input.value+=' <'+tag+'>Reemplace este texto</'+tag+'>';
		return;
	}
}

function inslink(Acampo)
{
	var input = document.getElementById(Acampo);
//	var input = document.form_ser.textoNoti;
	if(typeof document.selection != 'undefined' && document.selection)
	{
		var str = document.selection.createRange().text;
		input.focus();
		var my_link = prompt("Enter URL:","http://");
		if (my_link != null)
		{
			var sel = document.selection.createRange();
			sel.text = '<a href=\'' + my_link + '\' target=\'_blank\'>' + str + '</a>';
		}
		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("Enter URL:","http://");
		if (my_link != null)
		{
			input.value = input.value.substr(0, start) +'<a href=\'' + my_link + '\' target=\'_blank\'>' + insText  + '</a>'+ input.value.substr(end);
		}
		return;
	}
	else
	{
		var my_link = prompt("Ingresar URL:","http://");
		var my_text = prompt("Ingresar el texto del link:","");
		input.value+=' <a href=\'' + my_link + ' \' target=\'_blank\'>' + my_text + ' </a>';
		return;
	}
}


// funcion para moestrar el div que informa sobre el thumb
function muestra(obj) {
	var el = document.getElementById(obj);
	el.style.display = 'block';
}

// funcion para esconder el div que informa sobre el thumb
function esconde(obj) {
	var el = document.getElementById(obj);
	el.style.display = 'none';
}
