function none() { }

function redondear(cantidad, decimales) {
	var cantidad = parseFloat(cantidad);
	var decimales = parseFloat(decimales);
	decimales = (!decimales ? 2 : decimales);
	return Math.round(cantidad * Math.pow(10, decimales)) / Math.pow(10, decimales);
} 

function FormatFloat(pFloat, decimales){
    var m = Math.pow(10, decimales);
    return parseInt(pFloat * m, 10) / m;
}

function validar(e) { 
    tecla = (document.all) ? e.keyCode : e.which;
    if (tecla == 8 || e.which == 0) return true; 
    patron =/\d/; 
    te = String.fromCharCode(tecla); 
    return patron.test(te);
}

function validardecimal(e) { 
    tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla == 8 || tecla == 44 || e.which == 0) return true; 
    patron =/\d/; 
    te = String.fromCharCode(tecla); 
    return patron.test(te);
}

function replaceString(oldS,newS,fullS) {
   for (var i=0; i<fullS.length; i++) {
      if (fullS.substring(i,i+oldS.length) == oldS) {
         fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length)
      }
   }
   return fullS
}

function validarNumero(valor) {
	if (valor=="") valor=0;
	valor = replaceString(",",".", valor);
	valor = parseFloat(valor);
	if (isNaN(valor)) {
		return "";
	} else {
		return valor;
	}
}

function DlgBorrar(direccion) {
var x=window.confirm("El registro será borrado. ¿Esta seguro?")
if (x) window.location = direccion
}

function stopRKey(evt) {
	var evt = (evt) ? evt : ((event) ? event : null);
	var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
	if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}

function loading(value) {
	if (value) {
		document.getElementById('load').style.visibility='visible';
		document.getElementById('load').style.display='block';
		//document.getElementById('load').style.opacity='.6';
		//document.getElementById('load').style.filter='alpha(opacity=60)';
	} else {
		document.getElementById('load').style.visibility='visible';
		document.getElementById('load').style.display='none';
		//document.getElementById('load').style.opacity='1';
		//document.getElementById('load').style.filter='alpha(opacity=100)';
	}
}

function showHide(EL) {
      ELpntr=document.getElementById(EL);
      if (ELpntr.style.display=='none'){ ELpntr.style.display='block'; }
      							else   { ELpntr.style.display='none';  }
}

function seleccionar_todo(){
  for (i=0;i<document.save.elements.length;i++)
      if ((document.save.elements[i].type == "checkbox") && (document.save.elements[i].name == "id_grupos[]"))
         document.save.elements[i].checked=1
}

function seleccionar_todos_recibos(){
  for (i=0;i<document.save.elements.length;i++)
      if ((document.save.elements[i].type == "checkbox") && (document.save.elements[i].name == "id_recibos[]"))
         document.save.elements[i].checked=1
}

function seleccionar_elementos(){
  for (i=0;i<document.save.elements.length;i++)
      if ((document.save.elements[i].type == "checkbox") && (document.save.elements[i].name == "lista_alumnos[]"))
         document.save.elements[i].checked=1;
}

function des_seleccionar_elementos(){
  for (i=0;i<document.save.elements.length;i++)
      if ((document.save.elements[i].type == "checkbox") && (document.save.elements[i].name == "lista_alumnos[]"))
         document.save.elements[i].checked=0
}

function alternarDiv(id){ 
    aux=document.getElementById(id);
    if (aux.style.display=="none"){aux.style.display=""}
    else{aux.style.display="none"} 
}

function SetChecked(name, value) {
	$('input[name='+name+']').attr('checked', value);
}

function insertAtCursor(myField, myValue) {
	  //IE support
	  if (document.selection) {
	    myField.focus();
	    sel = document.selection.createRange();
	    sel.text = myValue;
	  }
	  //MOZILLA/NETSCAPE support
	  else if (myField.selectionStart || myField.selectionStart == '0') {
	    var startPos = myField.selectionStart;
	    var endPos = myField.selectionEnd;
	    myField.value = myField.value.substring(0, startPos)
	                  + myValue
	                  + myField.value.substring(endPos, myField.value.length);
	  } else {
	    myField.value += myValue;
	  }
}

function resetRadioButtons(Form, nombre){
	for(i=0; i<Form.elements.length; i++){
		if(Form.elements[i].type=="radio"){
			if(Form.elements[i].name == nombre.toString())
				Form.elements[i].checked=false;
		}
	}
}

function strpos (haystack, needle, offset) {
	var i = (haystack+'').indexOf(needle, (offset || 0));
	return i === -1 ? false : i;
}

function escapeISO88591(texto) {
	var strISO88591 = ' ¡¢£¤¥¦§¨©ª«¬-®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ';
	var salida = '';
	
	for(i=0;i<=texto.length;i++) {
		//primero comprobamos si está en el rango ascii (32 es el espacio ' '; 126 es la tilde '~'; 10 salto de línea)
		if ((texto.charCodeAt(i) >= 32 && texto.charCodeAt(i) <= 126) || texto.charCodeAt(i) == 10) salida += texto.charAt(i); 
			else salida += (strpos(strISO88591, texto.charAt(i)) != false) ? texto.charAt(i) : ''; //si no lo encontramos en ascii...
	}
	return salida;
}