
  function dateChanged(calendar) {
    // Beware that this function is called even if the end-user only
    // changed the month/year.  In order to determine if a date was
    // clicked you can use the dateClicked property of the calendar:
    if (calendar.dateClicked) {
      // OK, a date was clicked, redirect to /yyyy/mm/dd/index.php
      
      var y = calendar.date.getFullYear();
      var m = calendar.date.getMonth();     // integer, 0..11
      var d = calendar.date.getDate();      // integer, 1..31
      // redirect...
      var m2=m+1
      var location = "Encontrar-tickets-y-comprar-entradas-de-espectii-frac12-culos-para-la-fecha_search.html?action=search&date="+d+"&month="+m2+"&year="+y;
      //var location = "index.php?action=search&date="+d+"&month="+m2+"&year="+y;
      //alert(location);
      
      setCookie("calendario_dia",'"'+y+"/"+m2+"/"+d+'"',null);
      window.location = location;
    }
  };
function showhideEspectaculoDivOculto(i,noshow1,noshow2){
    var no1=document.getElementById("catalogo_"+noshow1);
    no1.style.visibility="hidden";
    no1.style.width="0px";
    no1.style.height="0px";
    var no2=document.getElementById("catalogo_"+noshow2);
    no2.style.visibility="hidden";
    no2.style.width="0px";
    no2.style.height="0px";
    var x=document.getElementById("catalogo_"+i);
    if (x.style.visibility == "visible")
    {
        x.style.visibility="hidden";
        x.style.width="1px";
        x.style.height="1px";
    }
    else
    {
        x.style.visibility="visible";
        x.style.width="98%";
        x.style.height="100%";
    }
}
function checkMAIL(formname)
{
	var x = document.forms[formname].email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) return true;
	else
	{
	    alert('inscrits une adresse electronique valide');
	    return false;
	}
}












function gotohome()
{
    this.document.location = "index.php";
}

function xmlhttpPostNewUser(strURL,str_query,campo) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
			
            if(self.xmlHttpReq.responseText == "0")
            {

                 document.formCTicket.submit();
            }
            else
            {
                 document.getElementById("textoCheckForm").innerHTML = "l`email inscrit existe deja comme utilisateur";
            }
        }
    }
    self.xmlHttpReq.send(str_query);
}




function sendFormRegisteredUser(campo)
{
    //windowOpen('url_extern2');
    var user = document.getElementById("username_").value;
    var pwd = document.getElementById("pwd_").value;
    var temp= document.getElementById(campo);
    var temp2= document.getElementById(campo+"_2");
    temp2.innerHTML = '';
    temp.style.display='';
    temp.style.width='100%';
    temp.style.height='50px';
    xmlhttpPostRegisteredUser("index.php","action=ajax&subaction=checkClient&username="+user+"&pwd="+pwd,campo)
}


function xmlhttpPostRegisteredUser(strURL,str_query,campo) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(campo,self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(str_query);
}
function updatepage(str,res){
    var out;
    document.getElementById(str).style.display='none';
    document.getElementById(str).style.width='1px';
    document.getElementById(str).style.height='1px';
    var temp= document.getElementById(str+"_2");

    temp.style.display='';
    temp.style.width='100%';
    temp.style.height='100%';
    if (res == 0)
    {
        out = '<font color="red">l`utilisateur ou le mot de passe incrits n`est pas correct. reesaie...<\/font>';
    }
    else
    {
        //window.open(url_extern,'','left=75,top=60,height=600,width=800,scrollbars=yes,resizable=yes');
        out="";
        document.formRegisteredUser.submit();
    }
    temp.innerHTML = out;
   // document.getElementById('response_ajax').innerHTML = res;
}
function enviaRemember()
{
    var url_extern = document.getElementById("url_extern2").value;
    if(url_extern.indexOf("http://") == -1)
    {
        url_extern = "http://"+url_extern
    }
    //window.open(url_extern,'','left=75,top=60,height=600,width=800,scrollbars=yes,resizable=yes');
    document.formRegisteredUser.submit();
}
function windowOpen(id)
{
    var url_extern = document.getElementById(id).value;
    if(url_extern.indexOf("http://") == -1)
    {
        url_extern = "http://"+url_extern;
    }
    //window.open(url_extern,'','left=75,top=60,height=600,width=800,scrollbars=yes,resizable=yes');
}


function enviaRememberV2()
{
	var a = this.document.getElementById('rememberPWD');
	var temp= this.document.getElementById('responseCheckUser');
	var temp2=this.document.getElementById('responseCheckUser_2');
	temp.style.display='';
    temp.style.width='100%';
    temp.style.height='50px';
	temp2.style.display='';
    temp2.style.width='100%';
    temp2.style.height='50px';
    temp2.innerHTML='';
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', 'index.php', true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            var res=self.xmlHttpReq.responseText;
           // alert(res);
            if(res==1)
            {
				temp.style.display='none';
			    temp.style.width='1px';
			    temp.style.height='1px';
            	temp2.innerHTML='L`e-mail a ete envoye correctement';
				temp2.style.display='';
				temp2.style.color='red';
			    temp2.style.width='100%';
			    temp2.style.height='50px';            	
            }
            else
            {
				temp.style.display='none';
			    temp.style.width='1px';
			    temp.style.height='1px';
            	temp2.innerHTML='Erreur, le courrier specifique n`a pas ete trouve dans notre base de donnees, verifies que tu as bien ecrit l`adresse email ou enregistre toi dans le formulaire inferieure';            	
				temp2.style.display='';
				temp2.style.color='red';
			    temp2.style.width='100%';
			    temp2.style.height='50px';            	
            }
        }
    }
    self.xmlHttpReq.send('action=ajax&subaction=rememberMail&data='+a.value);
}

function secureBuyCreditCardFinalV2()
{
	var a=checkRegisteredUser();
	if(a==0)
	{
		var r=confirm('Es-tu sûr de vouloir realiser l`achat');
		if (r==true)
		{
			this.document.secureBuyCreditCardFinal.submit();
		}
	}else if(a==1)
	{
		alert('Avant de continuer tu dois introduire tes donnees personnelles, si tu es deja enregistre tu peux inscrire ton nom d`utilisateur et ton mot de passe pour continuer l`achat des entrees');
	}else if(a==3)
	{
		//nada del resto se encarga la función llamada desde checkRegisteredUser()
	}
	
}

function sendFormNewUserV2(docid,nombre,apellidos,cp,tel,email1,email2,pwd,pwd2)
{
    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    var res1 = filter.test(email1);
    var res2 = filter.test(email2);
    if((email1==email2)&&(res1)&&(res2)&&(nombre!="")&&(apellidos!="")&&(tel!="")&&(pwd==pwd2)&&(pwd!="")){
        var tmp=this.document.getElementById('waitCheckForm');
        var tmp2=this.document.getElementById("textoCheckForm");
        tmp.style.display='';
        tmp.style.widht='100%';
        tmp.style.height='50px';
	    var xmlHttpReq = false;
	    var self = this;
	    // Mozilla/Safari
	    if (window.XMLHttpRequest) {
	        self.xmlHttpReq = new XMLHttpRequest();
	    }
	    // IE
	    else if (window.ActiveXObject) {
	        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	    }
	    self.xmlHttpReq.open('POST', 'index.php', true);
	    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	    self.xmlHttpReq.onreadystatechange = function() {
	        if (self.xmlHttpReq.readyState == 4) {
		        var a=self.xmlHttpReq.responseText;
				if((a!=-1)&&(a!=-2))
				{
					loadFormDataUserPasarelaV2(a);
				}
				else
				{
					if(a==-1)
					{
						tmp.style.display='none';
					    tmp.style.width='1px';
					    tmp.style.height='1px';
		            	tmp2.innerHTML='Avant de continuer tu dois introduire tes donnees personnelles, si tu es deja enregistre tu peux inscrire ton nom d`utilisateur et ton mot de passe pour continuer l`achat des entrees';            	
						tmp2.style.display='';
						tmp2.style.color='red';
					    tmp2.style.width='100%';
					    tmp2.style.height='50px';
	            	}else
	            	{
						tmp.style.display='none';
					    tmp.style.width='1px';
					    tmp.style.height='1px';
		            	tmp2.innerHTML='Entrez un numéro valide, un certain nombre de papiers (carte de bibliothèque, d`un passeport, pas de papier du pays d`origine .. etc ..) est juste pour valider que vous et vous seul êtes le propriétaire de l`entrée et à personne d`autre même si un achat peut Cangas la dernière entrée.';            	
						tmp2.style.display='';
						tmp2.style.color='red';
					    tmp2.style.width='100%';
					    tmp2.style.height='50px';	            	
	            	}
				}
	        }
	    }
	    self.xmlHttpReq.send('action=ajax&subaction=newUserV2&d1='+docid+'&d2='+parseAcentos(nombre)+'&d3='+parseAcentos(apellidos)+'&d4='+cp+'&d5='+tel+'&d6='+email1+'&d7='+pwd);  
    }
    else
    {
        var texto='';
        if((email1!=email2)||(!res1)||(!res2))
            {
            texto=texto +'<br>Inscrits le mail correctement dans les champs indiques';
            }
        if((pwd!=pwd2)||(pwd==""))
        {
            texto=texto +'<br>Inscrits le mot de passe correctement dans les champs indiques';
        }
        if((nombre==""))
            {
            texto = texto + '<br>Inscrits un prenom';
            }
        if((apellidos==""))
        {
        texto = texto + '<br>Inscrits ton nom';
        }
        if((tel==""))
        {
        texto = texto + '<br>Inscits ton numero de telephone';
        }
        document.getElementById("textoCheckForm").innerHTML = texto;
    }
}

function sendFormRegisteredUserV2(user,pass)
{
	var temp= this.document.getElementById('responseCheckUser');
	var temp2=this.document.getElementById('responseCheckUser_2');
	temp.style.display='';
    temp.style.width='100%';
    temp.style.height='50px';
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //alert('action=ajax&subaction=checkClientV2&username='+user+'&pwd='+pass);
    self.xmlHttpReq.open('POST', 'index.php', true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
	        var a=self.xmlHttpReq.responseText;
	        //alert(a);
			if(a!=-1)
			{
				loadFormDataUserPasarelaV2(a);
			}
			else
			{
				temp.style.display='none';
			    temp.style.width='1px';
			    temp.style.height='1px';
            	temp2.innerHTML='Erreur, le courrier specifique n`a pas ete trouve dans notre base de donnees, verifies que tu as bien ecrit l`adresse email ou enregistre toi dans le formulaire inferieure';            	
				temp2.style.display='';
				temp2.style.color='red';
			    temp2.style.width='100%';
			    temp2.style.height='50px';
			}
        }
    }
    self.xmlHttpReq.send('action=ajax&subaction=checkClientV2&username='+user+'&pwd='+pass);  
}
function loadFormDataUserPasarelaV2(a)
{
	var p1= this.document.getElementById('pasarela_comun1');
	var p2= this.document.getElementById('pasarela_comun2');
	var d1=this.document.getElementById('docidCli');
	var d2=this.document.getElementById('nombreCli');
	var d3=this.document.getElementById('apellidosCli');
	var d4=this.document.getElementById('emailCli');
	var d5=this.document.getElementById('cpCli');
	var d6=this.document.getElementById('telCli');
	var d7=this.document.getElementById('idCli');
	var cont=this.document.getElementById('show_siguienteV2');
	var fin1=this.document.getElementById("finalizedUser");
	var fin2=this.document.getElementById("finalizedButacas");
	fin1.value=1;
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', 'index.php', true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
	        var res=self.xmlHttpReq.responseText;
	        var array=res.split('/*-split-*/');
	        d1.value=array[0];
	        d2.value=array[1];
	        d3.value=array[2];
	        d4.value=array[3];
	        d5.value=array[4];
	        d6.value=array[5];
	        d7.value=a;
			p1.innerHTML=array[6];
			p2.innerHTML='';
			if(fin2.value==1)
			{
				cont.style.display='';
				cont.style.width='100%';
				cont.style.height='100%';
			}
        }
    }
    self.xmlHttpReq.send('action=ajax&subaction=getUserValues&id='+a);
}
function parseAcentos(dat)
{
	dat=dat.replace("á","#aacute:");
	dat=dat.replace("é","#eacute:");
	dat=dat.replace("í","#iacute:");
	dat=dat.replace("ó","#oacute:");
	dat=dat.replace("ú","#uacute:");
	dat=dat.replace("à","#agrave:");
	dat=dat.replace("è","#egrave:");
	dat=dat.replace("ì","#igrave:");
	dat=dat.replace("ò","#ograve:");
	dat=dat.replace("ù","#ugrave:");
	dat=dat.replace("ä","#a2puntos:");
	dat=dat.replace("ë","#e2puntos:");
	dat=dat.replace("ï","#i2puntos:");
	dat=dat.replace("ö","#o2puntos:");
	dat=dat.replace("ü","#u2puntos:");
	dat=dat.replace("Ä","#A2puntos:");
	dat=dat.replace("Ë","#E2puntos:");
	dat=dat.replace("Ï","#I2puntos:");
	dat=dat.replace("Ö","#O2puntos:");
	dat=dat.replace("Ü","#U2puntos:");
	dat=dat.replace("Á","#Aacute:");
	dat=dat.replace("É","#Eacute:");
	dat=dat.replace("Í","#Iacute:");
	dat=dat.replace("Ó","#Oacute:");
	dat=dat.replace("Ú","#Uacute:");
	dat=dat.replace("À","#Agrave:");
	dat=dat.replace("È","#Egrave:");
	dat=dat.replace("Ì","#Igrave:");
	dat=dat.replace("Ò","#Ograve:");
	dat=dat.replace("Ù","#Ugrave:");
	dat=dat.replace("ñ","#nn:");
	dat=dat.replace("Ñ","#Nn:");
	dat=dat.replace("º","-n-o:");
	dat=dat.replace("ª","-n-a:");
	dat=dat.replace("&","#amp:");
	dat=dat.replace("ç","#ctranc:");
	return dat;
}
function checkAndSubmitSupportForm()
{
	var a=this.document.getElementById('email_sender');
	var b=this.document.getElementById('email_destination');
	var c=this.document.getElementById('mensaje');
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(filter.test(a.value))
	{
		a.style.backgroundColor='White';
		if(b.value!='-1')
		{
			if(c.value!='')
			{
				c.style.backgroundColor='White';
				document.formSupport.submit();
			}else c.style.backgroundColor='#f7cdd0';
		}
	}else
	{
		a.style.backgroundColor='#f7cdd0';
	}
}
