﻿$(document).ready(function() {
    switch(document.location.pathname) {
    case '/galeria.asp':
        var $gallery = $("a[rel='slideshow']").colorbox({slideshow:true});
        $('a#slideshowOpen').click(function(e){
            e.preventDefault();
            $gallery.eq(0).click();
        });
        break;
    }
});

function validarTexto(formulario, campo, mensaje) {
	if(document.forms[formulario].elements[campo].value == '') {
		alert(mensaje);
		document.forms[formulario].elements[campo].focus();
		return false;
	}
	return true;
}

function validarEmail(formulario, campo, mensaje) {
   if(!document.forms[formulario].elements[campo].value.match(/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)) {
		alert(mensaje);
		document.forms[formulario].elements[campo].focus();
		return false;
   }
	return true;
}

function validarTalleres() {
	if(!validarTexto('talleres', 'documento', 'Debe ingresar un DOCUMENTO.')) return false;
	if(document.forms['talleres'].elements['nombre']) {
    	if(!validarTexto('talleres', 'apellido', 'Debe ingresar un APELLIDO.')) return false;
    	if(!validarTexto('talleres', 'nombre', 'Debe ingresar un NOMBRE.')) return false;
    	if(!validarEmail('talleres', 'email', 'Debe ingresar un E-MAIL.')) return false;
        var inputs = document.forms['talleres'].getElementsByTagName('input'), c = 0;
        for(var i = 0; i < inputs.length; i++)
            if(inputs[i].type.toLowerCase() == 'checkbox' && inputs[i].name.toLowerCase() != 'socio' && inputs[i].checked)
                c++;
//        if(c == 0) {
//      		alert('Debe elegir por lo menos 1 TALLER');
//    		return false;
//        }
//        if(c > 3) {
//      		alert('Debe elegir un máximo de 3 TALLERES');
//    		return false;
//        }
	}
	return true;
}

function mostrarTaller(id) {
    if(document.getElementById('t' + id).className == 'oculto')
        document.getElementById('t' + id).className = '';
    else
        document.getElementById('t' + id).className = 'oculto';
}
