function FormatoTexto(tipo,link) {
var formato;
if (document.selection.createRange().text!="") {
    if (tipo==1) {
        formato="<b>"+document.selection.createRange().text+"</b>";
    }
    else if (tipo==2) {
        formato="<i>"+document.selection.createRange().text+"</i>";
    }
    else if (tipo==3) {
        formato="<a href="+ link +" target=_blank>"+document.selection.createRange().text+"</a>";
    }
    else if (tipo==4) {
        formato="<a href=mailto:"+ link +">"+document.selection.createRange().text+"</a>";
    }
    document.selection.createRange().text=formato;
    }
}

function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll;
win = window.open(mypage, myname, winprops);
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function textCounter(field,maxlimit) 
{
if (field.value.length > maxlimit)
{
field.value = field.value.substring(0, maxlimit);
}
}

function FechaCorrecta(dia,mes,ano) {
	var bOk=true;
	
	if ((dia=="") || (mes=="") || (ano=="")) {
		if ((dia=="") && (mes=="") && (ano=="")) {
			bOk=true;
		} else {
			bOk=false;
		}
	} else {
		if ((isNaN(dia)) || (isNaN(mes)) || (isNaN(ano))) {
			bOk=false;
		}
		if ((dia>31) || (mes>12))   {
			bOk=false;
		}
		
	}
	
	if (bOk==false) {
		alert("La fecha es incorrecta");
	}
		
	return bOk;			  
}
function op(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';
  window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}