function checkForm(id,div) {
        var error = false;
	var msgError="";	
        $$('form#'+id+' .required').each(function(node){
            if (node.value == "") {
                error = true;
		msgError+="<li>El campo "+node.id+" es obligatorio</li>";
                node.style.background = "#F00";
            }
        });
        $$('form#'+id+' .email').each(function(node){
            if (node.value.indexOf(".") < 2 || node.value.indexOf("@") < 0) {
		msgError+="<li>El campo "+node.id+" no tiene el formato correcto</li>";	
                error = true;
                node.style.background = "#F00";
            }
        });
        $$('form#'+id+' .numeric').each(function(node){
            var strChars = "0123456789.-";
            for (i = 0; i < node.value.length; i++) {
                strChar = node.value.charAt(i);
                if (strChars.indexOf(strChar) == -1) {
		    msgError+="<li>El campo "+node.id+" debe ser numérico</li>	>";
                    error = true;
                    node.style.background = "#F00";
                }
            }
        });
        if (error == true && div!=null) {
            document.getElementById(div).innerHTML=msgError;
        }
	return !error;
    }
  
function enviaEmail(){
        if(!checkForm('frmContacto','mensaje'))return false;
        var nombre   = document.getElementById("nombre").value;
        var email    = document.getElementById("email").value;
        var consulta = document.getElementById("consulta").value;
        var param="subject=Enviado desde darioblanco.com.ar&nombre="+nombre+"&email="+email+"&consulta="+consulta;
        new Ajax.Updater('tablaEmail', 'enviarMailMdm.php', {
                  method: 'post',
                  asynchronous: true,
                  parameters: param,
                  onFailure: muestraError
                  })
	return true;
	}
	
function cambiar(obj,menu,llave){
		obj.src="images/"+menu;
		document.getElementById("llave").src = "images/db_08_"+llave+".jpg";
		Reproducir("clickerx.wav");
	}
	
	
function Reproducir(soundfile){ 
		document.all.sound.src = soundfile;
	}
function eligeTabla(pagina){
	      new Ajax.Updater('destino', 'tablas/'+pagina+"?nocache=" + Math.random(), {
			method: 'get',
			asynchronous: true,
			
			onFailure: muestraError
			});
      }
  
function muestraError(){
	      alert("Oops...ajax error!!");
      }

function convertir(){
	  var texto = document.getElementById('miarea').innerHTML;
	  var param = 'texto='+texto;
	  new Ajax.Updater('area', 'ajaxConvert.php', {
				method: 'post',
				asynchronous: true,
				parameters: param,
				onFailure: muestraError
				});
	  
}	