function activar_desactivar(checkbox,casilla){
  if(checkbox.checked==true){ document.getElementById(casilla).disabled=true; }
  else { document.getElementById(casilla).disabled=false; }
}


function preguntar_eliminar(url){
  respuesta=confirm("¿Está seguro que desea eliminar este elemento?");
  if(respuesta==true){ window.location=url; }
}


function caracteres(contar,mostrar,maximo){
  restantes=maximo-contar.value.length;
  texto="{CHAR} caracteres restantes.";
  if(restantes<0){ contar.value=contar.value.substr(0,maximo); restantes=0; }
  document.getElementById(mostrar).innerHTML = texto.replace("{CHAR}",restantes);
}

function nueva_ventana(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
  //onclick="nueva_ventana(this.href, 'nombre_de_la_ventana', ancho, alto, scrollbars, resizable, menubar, toolbar, addressbar, statusbar, fullscreen);
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      obj_window.window.focus();
    }
}

function mostrar(id,cual){
  	cualmostrar="form_"+id+cual;
  	todos=new Array();
	for(i=1;i<=9;i++){
	  todos.push(id+i);
    }
	for(i=0;i<todos.length;i++){
		if ("form_"+todos[i] == cualmostrar) {
		  document.getElementById("form_"+id+cual).style.display="block";
		  document.getElementById("foto_"+id+cual).style.borderColor="#fc0";
		  document.getElementById("opciones_"+id+cual).style.borderColor="#fc0";
		  document.getElementById("opciones_"+id+cual).style.backgroundColor="#fc0";
		}
		else {
		  document.getElementById("form_"+todos[i]).style.display="none";
		  document.getElementById("foto_"+todos[i]).style.borderColor="#666";
		  document.getElementById("opciones_"+todos[i]).style.borderColor="#666";
		  document.getElementById("opciones_"+todos[i]).style.backgroundColor="#666";
		}
	}
}


function recomendarId(origen,destino){
	uni225="a";uni233="e";uni237="i";uni243="o";uni241="n";uni250="u";
	acentos=/[áéíóúñ]/g;
	convertir=origen.value.replace(/ /g,"_").toLowerCase();
	convertir2=convertir.replace(acentos, function($1){return eval("uni"+$1.charCodeAt(0));} );
	document.getElementById(destino).value=convertir2.replace(/\W/g,"_");
}
