
  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('Introduce una dirección de correo válida...');
	    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 = "El email introducido ya existe como Usuario Registrado!!";
            }
        }
    }
    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">El usuario o el password introducido no es correcto. Intentelo de nuevo...<\/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='Se ha enviado el correo correctamente';
				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='Error, el correo especificado no se encuentra en nuestra base de datos, verifique que ha escrito bien la direccion de correo electrónica, o regístrese en el formulario inferior.';            	
				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('Está seguro que desea realizar la compra?');
		if (r==true)
		{
			this.document.secureBuyCreditCardFinal.submit();
		}
	}else if(a==1)
	{
		alert('Antes de continuar has de introducir tus datos personales, si ya estás registrado puedes poner tu usuario y password para continuar con la compra de entradas.');
	}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,dir,id_ciu,otra_ciu,id_prov)
{
    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!="")&(dir!="")& ( ((id_ciu > 0) & (id_ciu != "")&(otra_ciu == '')) | ( ((id_ciu < 0) | (id_ciu == "")) & ( (otra_ciu !='')&(id_prov>0)))) ){
        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==-2)
		        {
		        tmp.style.display='none';
				    tmp.style.width='1px';
				    tmp.style.height='1px';
	            	tmp2.innerHTML='Introduce un Nº de ID con Foto válido, cualquier tipo de ID con Foto (carne de biblioteca,pasaporte ,Nº de documento de país de origen.. etc..) es simplemente para validar que tú y solo tú eres el propietario de la entrada y nadie mas aunque tenga un comprobante de compra podrá cangearlo por la entrada final.';            	
					tmp2.style.display='';
					tmp2.style.color='red';
				    tmp2.style.width='100%';
				    tmp2.style.height='50px';		        	  
		        } 
		        else if(a==-3)
		        {
		        tmp.style.display='none';
				    tmp.style.width='1px';
				    tmp.style.height='1px';
	            	tmp2.innerHTML='El email introducido ya existe como Usuario Registrado!!<br>Utilize el formulario que se ve mas arriba e ingrese email y password directamente.';            	
					tmp2.style.display='';
					tmp2.style.color='red';
				    tmp2.style.width='100%';
				    tmp2.style.height='50px';		        	  
		        } 
				else if(a!=-1)
				{
					loadFormDataUserPasarelaV2(a);
				}
				else
				{
					tmp.style.display='none';
				    tmp.style.width='1px';
				    tmp.style.height='1px';
	            	tmp2.innerHTML='Antes de continuar has de introducir tus datos personales, si ya estás registrado puedes poner tu usuario y password para continuar con la compra de entradas.';            	
					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='+nombre+'&d3='+apellidos+'&d4='+cp+'&d5='+tel+'&d6='+email1+'&d7='+pwd+'&d8='+dir+'&d9='+id_ciu+'&d10='+otra_ciu+'&d11='+id_prov);  
    }
    else
    {
        var texto='';
        if((email1!=email2)||(!res1)||(!res2))
            {
            texto=texto +'<br>Introduce el email correctamente en los dos campos indicados.';
            }
        if((pwd!=pwd2)||(pwd==""))
        {
            texto=texto +'<br>Introduce el Password correctamente en los dos campos indicados.';
        }
        if((nombre==""))
            {
            texto = texto + '<br>Introduce un Nombre.';
            }
        if((apellidos==""))
        {
        texto = texto + '<br>Introduce tu Apellido.';
        }
        if((tel==""))        
        	texto = texto + '<br>Introduce tu Telefono.<br/>';        
        if((dir==""))        
        	texto = texto + 'Ingrese una dirección<br/>';
        
        if((id_ciu=="")||(id_ciu<=0)&&otra_ciu=="")
        	texto = texto + 'Selecciona una Ciudad<br/>';            
    	if(otra_ciu!="" && id_prov<0)
        	texto = texto + 'Seleccione un estado';
       
        document.getElementById("textoCheckForm").innerHTML = texto;
    }
}

function IngresarDatosFaltantes(user,pass)
{
	var p1= this.document.getElementById('pasarela_comun1');
	var p2= this.document.getElementById('pasarela_comun2');
	
	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;	               
			p1.innerHTML=res;
			p2.innerHTML='';				
			/*if(fin2.value==1)
			{
				cont.style.display='';
				cont.style.width='100%';
				cont.style.height='100%';
			}*/
        }
     }
     
     self.xmlHttpReq.send('action=ajax&subaction=getDatosFaltantes&username='+user+'&pwd='+pass);
}

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;	        
	        if(a==0)
	        { 
				IngresarDatosFaltantes(user,pass);
			}
			else if(a!=-1)
			{
				loadFormDataUserPasarelaV2(a);
			}
			else
			{
				temp.style.display='none';
			    temp.style.width='1px';
			    temp.style.height='1px';
            	temp2.innerHTML='Error, el correo especificado no se encuentra en nuestra base de datos, verifique que ha escrito bien la direccion de correo electrónica, o regístrese en el formulario inferior.';            	
				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');
	/*FG-NOV2009-START-direccion-ciudad-estado*/
	var d8=this.document.getElementById('direccionCli');
	var d9=this.document.getElementById('ciudadCli');
	var d10=this.document.getElementById('estadoCli');
	/*FG-NOV2009-END-direccion-ciudad-estado*/
	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];
	        /*FG-NOV2009-END-direccion-ciudad-estado*/
	        d8.value=array[6];
	        d9.value=array[7];
	        d10.value=array[8];
	        /*FG-NOV2009-END-direccion-ciudad-estado*/
	        d7.value=a;
			p1.innerHTML=array[9];
			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;
}
