/*Para mostrar y cerrar prod*/
function ver_prod(id_con){
	
	producto = document.getElementById('prod');
	//producto.style.display='';
	ventana('prod');
	producto.innerHTML = ajax("producto_a.php?id="+id_con,"prod")
}

function cerrar_prod(id_con){
	producto = document.getElementById('prod');
	cerrar_ventana('prod');
	//producto.style.display='none';
}
/****************************/

/*Para comprar y cerrar prod*/
function comprar_prod(id_con){
	producto = document.getElementById('comprar_prod');
	//producto.style.display='';
	ventana('comprar_prod');
	producto.innerHTML = ajax("comprar_a.php?id="+id_con,"comprar_prod")
}

function cerrar_comprar_prod(id_con){
	producto = document.getElementById('comprar_prod');
	cerrar_ventana('comprar_prod');
	//producto.style.display='none';
}
/****************************/

/*FADE IN y OUT Para abrir y cerrar ventanas*/
function ventana(idnom){
	//muestra con fadeIn el fondo
	$(document.getElementById('prod_fondo')).fadeIn('slow', function() {
        // Animation complete
    });
	//muestra con fadeIn el cuado especificado ;)
	$(document.getElementById(idnom)).fadeIn('slow', function() {
        // Animation complete
    });
	$(document).scrollTop(0);
}

function cerrar_ventana(idnom){
	//quita con fadeOut el fondo
	$(document.getElementById('prod_fondo')).fadeOut('slow', function() {
        // Animation complete
    });
	//quita con fadeOut el cuadro especificado
	$(document.getElementById(idnom)).fadeOut('slow', function() {
        // Animation complete
    });
	$(document).scrollTop(0);
}

/****************************/

/* Verificar email */
function mail(texto){ 

    var mailres = true;             
    var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-";
     
    var arroba = texto.indexOf("@",0); 
    if ((texto.lastIndexOf("@")) != arroba) arroba = -1; 
     
    var punto = texto.lastIndexOf("."); 
                 
     for (var contador = 0 ; contador < texto.length ; contador++){ 
        if (cadena.indexOf(texto.substr(contador, 1),0) == -1){ 
            mailres = false; 
            break; 
     } 
    } 

    if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1)) 
     mailres = true; 
    else 
     mailres = false; 
                 
    return mailres; 
} 

