/***************************************************************************************************************/
/*Función que muestra y oculta datos                                                                           */
/***************************************************************************************************************/
function muestra_oculta(id){
	//alert(id)
	if(document.getElementById(id) != null){
	if(document.getElementById(id).style.display == "none"){
		document.getElementById(id).style.display="";
	}
	else document.getElementById(id).style.display="none";
	}
	
}
/***************************************************************************************************************/
/*Función abrir nueva ventana                                                                                  */
/***************************************************************************************************************/
function Abrir_ventana (pagina,anchura,altura,scrollbars) {
    var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars="+scrollbars+", resizable=no, width="+anchura+", height="+altura+", top=85, left=140";
    window.open(pagina,"",opciones);
}
/***************************************************************************************************************/
/*Función abre nueva ventana e imprime el contenido                                                                                 */
/***************************************************************************************************************/
function imprSelec(nombre){
  var ficha = document.getElementById(nombre);
  var ventimp = window.open(' ', 'popimpr');
  
  ventimp.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
  ventimp.document.write('<html xmlns="http://www.w3.org/1999/xhtml">');
  ventimp.document.write('<head><title>Micro-Web</title>');
  ventimp.document.write('<link href="templates/azul3/css/estilos.css" rel="stylesheet" type="text/css"/>');
  ventimp.document.write('<style type="text/css">@media print { .nover {display:none}}</style>');
  ventimp.document.write( ficha.innerHTML );
  ventimp.document.write( '</body></html>' ); 
  ventimp.document.close();
  ventimp.print( );
  ventimp.close();
}
/***************************************************************************************************************/
/*Función para agregar a favoritos                                                                             */
/***************************************************************************************************************/
function Favoritos(titulo,url) {
        if (window.sidebar) {
               window.sidebar.addPanel(titulo, url,"");
        } 
        else if( document.all ) {
               window.external.AddFavorite( url, titulo);
        } 
        else if( window.opera && window.print ) {
               return true;
         }
 }
/***************************************************************************************************************/
/*Función para comprobar correo                                                                           */
/***************************************************************************************************************/ 
 function comprueba_mail(mail) {
  var re_mail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
  if (re_mail.test(mail)) {
    return true;
  } else {
    alert(mail + " no es una dirección de correo válida.");
    return false;
  }
}
/**************** Función para comprobar que un campo no esté en blanco ****************/

function CompruebaBlanco(Campo, NombreCampo) {

  if (Campo == "") {

    alert('El campo ' + NombreCampo + ' es obligatorio');
    return false;

  } else {

    return true;

  }
}
function validar_contacto(obj){
    var frmName = document.getElementById('form').value;
    var formulario = eval( 'document.forms.' + frmName );
    //var message="Los siguientes campos no son válidos:\n";
    var conformidad = document.getElementById('conformidad');
    var nombre = document.getElementById('nombre').value;
    var email = document.getElementById('email').value;
    var asunto = document.getElementById('asunto').value;
    var mensaje = document.getElementById('mensaje').value;
    var code = document.getElementById('code').value;
   if(conformidad.checked){
        if(CompruebaBlanco(nombre, 'Nombre') && comprueba_mail(email) && CompruebaBlanco(asunto, 'Asunto') && CompruebaBlanco(mensaje, 'Mensaje') && CompruebaBlanco(code, 'Código de la imagen')){       
            formulario.submit();
        } 
   }
   else alert('Debe marcar la pestaña de conformidad'); 
}