function getHTTPObject() {
    var xmlhttp;
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        try {
	    xmlhttp = new XMLHttpRequest();
        } catch (e) {
	    xmlhttp = false;
        }
    }
    return xmlhttp;
}

function showFeedback() {
    $('#contacto').slideToggle('slow');
}
    
function feedback_submit(contacto) {
    var baseURL = "http://www.glug.es/xornadas-dereito-2008/";
    var correoContacto =  "francisco.dieguez@usc.es";
    document.getElementById("sending").style.display = "inline";
    document.getElementById("sendbutton").style.display = "none";
    
    var http = getHTTPObject();
    http.open("POST", baseURL + "enviomail.php", true);
    http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
     
    if (contacto==0){               
		document.getElementById("sending2").style.display = "inline";
		document.getElementById("sendbutton2").style.display = "none";
		var name = document.getElementById("name2").value;
		var mail = document.getElementById("mail2").value;
		var comentarios = document.getElementById("comentarios2").value;
		var conocementos= document.getElementById("conocementos").value; 
		var envio = "contacto=0&name=" + name + "&email=" + mail + "&comentarios=" + comentarios + "&conocementos=" + conocementos;
		http.send(envio);
    }
    else {                                                            
		document.getElementById("sending").style.display = "inline";
		document.getElementById("sendbutton").style.display = "none";
		var name = document.getElementById("nome").value;       
		var mail = document.getElementById("mail").value;
		var comentarios = document.getElementById("feedback").value;
		var envio = "contacto=1&name=" + name + "&email=" + mail + "&comentarios=" + comentarios ;
		http.send(envio);
    }; 
    http.onreadystatechange = function () {
		if (http.readyState == 4) {              
		    if (http.responseText == "1") {
				document.getElementById("aftercontacto").style.color ="#888";
				document.getElementById("afterinscricion").style.color ="#888";
				document.getElementById("aftercontacto").innerHTML = "<strong>Grazas!</strong> O teu contacto foi enviado.";
				document.getElementById("afterinscricion").innerHTML = "<strong>Grazas!</strong> A t&uacute;a subscripci&oacute;n foi enviada.";
				if (contacto ==0) {
				    document.getElementById("afterinscricion").style.display= "block";
				}else {
				    document.getElementById("aftercontacto").style.display= "block";
			};
			$('#contacto').hide('slow');
			$('#inscricion').hide('slow');
		   } else {
			if (contacto ==0 ) {
			    document.getElementById("afterinscricion").style.display= "block";
			}else {
			    document.getElementById("aftercontacto").style.display= "block";   
			};
			$('#contacto').hide('slow');
			$('#inscricion').hide('slow');
			document.getElementById("aftercontacto").innerHTML = "Ocurreu un erro &oacute; enviar o correo, tentao m&aacute;is tarde<br/> ou envia un correo a " + correoContacto;
			document.getElementById("aftercontacto").style.color ="Red";
			document.getElementById("afterinscricion").style.color ="Red";
			document.getElementById("afterinscricion").innerHTML = "Ocurreu un erro &oacute; enviar o correo, tentao m&aacute;is tarde<br/> ou envia un correo a " + correoContacto;
		    };
    	
		}
    }                      
     
    document.getElementById("sending").style.display = "none";
    document.getElementById("sendbutton").style.display = "block";
    document.getElementById("sending2").style.display = "none";
    document.getElementById("sendbutton2").style.display = "block";
     
     
}
    
function badgeHover(text) {
    if (text == null || text == "") { document.getElementById("badgelabel").firstChild.data = " ";  }
    else {
	document.getElementById("badgelabel").firstChild.data = text;                
    }
}
    
$(document).ready(function() {
	  $("info-content").hide();
      $('#badges a').click(function() {  
      		if ($(this).attr("className") == "activo") { return false; };
      		$('#badges a').each(function() { $(this).removeClass("activo"); });
      		$(this).toggleClass("activo");
      		$('#aftercontacto').hide('slow');
      		$('#afterinscricion').hide('slow');
      		$('#sendbutton').show('fast');
      		$('#sendbutton2').show('fast');
      		$('#cuerpo > div').each(function(index) { $(this).hide('slow'); });
      
      		if ($(this).attr("id") == "abrir_inicio") { $('#inicio').show("slow"); };
      		if ($(this).attr("id") == "abrir_ponencias") { $('#ponencias').show("slow"); };
      		if ($(this).attr("id") == "abrir_onde") { $('#onde').show("slow"); map.checkResize(); map.setCenter(new GLatLng(42.873098,-8.560498), 16, G_HYBRID_MAP);  };
      		if ($(this).attr("id") == "abrir_contacto") { $('#contacto').show("slow"); };
      		if ($(this).attr("id") == "abrir_inscricion") { $('#inscricion').show("slow"); };
   
       });
	   $('.boton-mais').click(function () {
			$(this).siblings().each( function (i) {
				$(this).slideToggle();
			});
	   });
      $('.dia .grupo_1').click(function() {
      	$('#grupo_1 .ponencia').slideToggle("slow");
      });
      $('.dia .grupo_2').click(function() {
      	$('#grupo_2 .ponencia').slideToggle("slow");
       });
	    
});