//This code is optimized by the w3compiler from Port80 Software:  BUY w3compiler to remove this comment from your optimized files at www.w3compiler.com!
var hoy=new Date();function dia(hoy){var hoy_dia=hoy.getDay();switch(hoy_dia){case 0:return"Domingo";case 1:return"Lunes";case 2:return"Martes";case 3:return"Miércoles";case 4:return"Jueves";case 5:return"Viernes";case 6:return"Sábado";return"";}}function mes(hoy){var hoy_mes=hoy.getMonth();switch(hoy_mes){case 0:return"Enero";case 1:return"Febrero";case 2:return"Marzo";case 3:return"Abril";case 4:return"Mayo";case 5:return"Junio";case 6:return"Julio";case 7:return"Agosto";case 8:return"Septiembre";case 9:return"Octubre";case 10:return"Noviembre";case 11:return"Diciembre";return"";}}function year(hoy){var hoy_year=hoy.getYear();if(hoy_year<2000)return(1900+hoy_year);else return hoy_year;}function regresar(backURL){this.window.location=backURL;}function actualizarColorTexto(color){this.window.frames['mensaje'].frames['texto'].document.fgColor=color;}function actualizarColorFondo(color){var di;this.window.frames['mensaje'].document.bgColor=color;this.window.frames['mensaje'].frames['estampilla'].document.bgColor=color;this.window.frames['mensaje'].frames['texto'].document.bgColor=color;di=document.getElementById('fondoTarjeta');if(di!=null){di.bgColor=color;}}function actualizarPapelTapiz(papel){di=document.getElementById('fondoTabla');if(di!=null){di.background=papel;}}function actualizarTipoLetra(tipo){actualizarMensaje();}function actualizarTamanoLetra(tipo){actualizarMensaje();}function actualizarEstampilla(estampilla){var linea;linea='<BODY BGCOLOR="'+this.document.frm_personalizacion.color_marco.value+'"><DIV align="right"><img src="'+estampilla+'"></img></DIV></BODY>';this.window.frames['mensaje'].frames['estampilla'].document.location.reload();this.window.frames['mensaje'].frames['estampilla'].document.write(linea);}function actualizarMensaje(){var cadena;cadena='<BODY BGCOLOR="'+this.document.frm_personalizacion.color_marco.value+'">';cadena=cadena+'<FONT face="'+this.document.frm_personalizacion.tipo_letra.value+'" size="'+this.document.frm_personalizacion.tamano_letra.value+'" COLOR="'+document.frm_personalizacion.color_texto.value+'">';cadena=cadena+this.document.frm_personalizacion.mensaje.value+"</FONT></BODY>";var i;for(i=0;i<cadena.length;i++){caracter=String.fromCharCode(13);cadena=cadena.replace(caracter,'<BR>');}this.window.frames['mensaje'].frames['texto'].location.reload();this.window.frames['mensaje'].frames['texto'].document.write(cadena);}function sonar(baseURL){if(this.document.frm_personalizacion.musica.value==''){alert('No ha seleccionado ninguna canción');return;}nombre=this.document.frm_personalizacion.musica.value;popupPageMain(baseURL+'oir_musica.php?sonido='+nombre,300,200);return;}

var totalDestinos=1;
function addField (parentObj, fieldType, fieldName, fieldValue, fieldsize) {
  if (document.getElementById) {
    var input = document.createElement('INPUT');
      if (document.all) { // what follows should work 
                          // with NN6 but doesn't in M14
        input.type = fieldType;
        input.name = fieldName;
        input.id = fieldName;
        input.value = fieldValue;
        input.size = fieldsize;
      }
      else if (document.getElementById) { // so here is the
                                          // NN6 workaround
        input.setAttribute('type', fieldType);
        input.setAttribute('name', fieldName);
        input.setAttribute('id', fieldName);
        input.setAttribute('value', fieldValue);
        input.setAttribute('size', fieldsize);
      }
    parentObj.appendChild(input);
  }
}

/**
* Función que adiciona un campo de destino (nombre, email) a la forma.
**/
function adicionarDestino(parentTable, maxDestinos, size) {
    totalDestinos++;
    if (totalDestinos > maxDestinos) {
        alert('No puede enviar la tarjeta a más de ' + maxDestinos + ' usuarios!');
        return;
    }
    var tableRow = window.document.createElement("TR");
    var tableCol1 = window.document.createElement("TD");
    var tableCol2 = window.document.createElement("TD");
    
    var fieldType = 'text';
    var fieldDestinatarioName = 'nombreDestinatario' + totalDestinos;
    var fieldDestinatarioEmail = 'emailDestinatario' + totalDestinos;
    
    addField (tableCol1, fieldType, fieldDestinatarioName, '', size);
    addField (tableCol2, fieldType, fieldDestinatarioEmail, '', size);

    tableRow.appendChild(tableCol1);
    tableRow.appendChild(tableCol2);
    
    parentTable.appendChild(tableRow);
}

function eliminarObjeto(objeto){
    objeto.style.display="none";
    return true;
}

function valores(nombre,valor){
    var elemento;
    var nombreElemento;elemento=document.getElementById(nombre);
    if(elemento==null){
        return;
    }
    elemento.value=valor;
    nombreElemento=nombre.substr(0,(nombre.length-1));
    elemento=document.getElementById(nombreElemento);
    if(elemento!=null){
        elemento.value=valor;
    }
}

function validarCodigoTarjeta(codigo) {
    var numeros;
    var total;
    var modulo;
    
    if (codigo.length != 8) {
        return false;
    }
    numeros = codigo.substr(2,4);
    
    if (!isInteger(numeros)) {
        return false;
    }
    /*total = 0;
    for(i = 0; i < numeros.length; i++){
        total = total + parseInt(numeros.charAt(i));
    }
    
    modulo = total%2;
    if (modulo != 0) {
        return false;
    }*/
    return true;
}

function reproducirMedia(selectObj, playersoundObj, urlMusica) {
    var browserName = navigator.appName;
    var browserVer = parseInt(navigator.appVersion);
    var msie4 = (browserName == "Microsoft Internet Explorer" && browserVer >= 4);
    if (msie4 == true) {
        playersoundObj.Filename = urlMusica + selectObj.value;
    }else {
        document.getElementById('embedObj').src = urlMusica + selectObj.value;
    }
}

function cambiarImagen() {
    if (document.images['imagen_tarjeta'].src.search("_01") != -1) {
        srcImagen=document.images['imagen_tarjeta'].src.replace("_01", "_02");
    } else {
        srcImagen=document.images['imagen_tarjeta'].src.replace("_02", "_01");
    }
        document.images['imagen_tarjeta'].src=srcImagen;
}