﻿diasAntelacion = 2;//boton reservas no aparecera n dias antes de la actuación

//para listado actuaciones mini
var miniFecha = new Array();
var miniTexto = new Array();
var miniLink = new Array();
var ctMini = 0;//contador para posicion array

ImgCierra = new Image();
ImgCierra.src = 'img/cerrar.gif';
ImgAbre = new Image();
ImgAbre.src = 'img/seguir.gif';

function abre(cual){
	if(cual!=4){
		location.href = 'index.htm?quetemp='+actual+'&qpublico='+cual
	}else{
		location.href = '../contratacion/';		
	}
}

function directo(cual){
location.href = 'index.htm#p'+cual;
}

function solo(cual){
location.href = 'index.htm?quetemp='+actual+'&qitem='+cual;
}

function TARinit(){
var htm='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="760" height="190">';
htm+='<param name="movie" value="../comun/monitor/monitor.swf">';
htm+='<param name="quality" value="high">';
htm+='<embed src="../comun/monitor/monitor.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="760" height="190"></embed></object>';

document.getElementById("monitor").innerHTML = htm;
}

function TARinitb(){
var htm='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="970" height="225">';
htm+='<param name="movie" value="../comun/monitor/monitor.new.swf">';
htm+='<param name="quality" value="high">';
htm+='<embed src="../comun/monitor/monitor.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="970" height="225"></embed></object>';

document.getElementById("monitor").innerHTML = htm;
}


function poppub(){
wm=window.open('alquiler.htm','pub','width=520,height=650');
setTimeout("if(wm)wm.focus()",200);
}

function carga(num){
location.href = 'index.htm?quetemp='+num.selectedIndex+'&qpublico='+qpublico;
}

function wrlista() {
var htm='<form name="form1" method="post" action="">';
htm+='<select name="select" class="parrafo" onChange="carga(this)">';
htm+='<option>Seleccionar Cartelera</option>';
for(i=1;i<=temporada.length-1;i++){
	htm+='<option>'+temporada[i]+'</option>';
}
htm+='</select>';
htm+='</form>';
document.write(htm);
}

function swcelda(celda){
	n=document.all["td"+celda].style.display;
	if(n=='none'){
		document.all["td"+celda].style.display = '';
		document.all["tda"+celda].style.display = 'none';
		document.images["boton"+celda].src = ImgCierra.src;
	}else{
		document.all["td"+celda].style.display = 'none';
		document.all["tda"+celda].style.display = '';
		document.images["boton"+celda].src = ImgAbre.src;
	}
}

function plegartodo(){
	for(i=1;i<=fecha1.length-1;i++){
		document.all["td"+i].style.display = 'none';	
		document.all["tda"+i].style.display = '';
		document.images["boton"+i].src = ImgAbre.src;
	}
	location.href = '#top';
}

function popreserva(cual,qfecha,qprecio){

wm=window.open('reserva.htm?artista=' + artista[cual] + '&fecha=' + qfecha + '&queprecio=' + qprecio,'lav','width=520,height=580');
setTimeout("if(wm)wm.focus()",200);
}

function slista(){

wm=window.open('apuntate.htm','lav','width=520,height=620');
setTimeout("if(wm)wm.focus()",200);
}
function botonprecio(qfecha,qprecio,orden){
var htm = '';
	if(actual>=tempActual){
	  if(tipo[orden]!=8){//no poner boton precio en exposiciones
		htm+= '<td width="1"><a href="JavaScript:popreserva('+i+',\''+qfecha+'\',\''+qprecio+'\')"><img src="img/reserva.gif" width="99" height="15" border="0"></a></td>\n';
	  }
	}
	return(htm);
}

function botonsinres(){
	return('<td width="1"><img src="img/sinres.gif" width="99" height="15" border="0"></td>');
}

function botonsinlocalidad(){
	return('<td width="1"><img src="img/sinloc.gif" border="0"></td>');

}

function concluida(){
	return('<td width="180" class="parrafo3" align="right">» Entradas agotadas!</td>');
}

var meses = new Array();
meses[1] = 'Enero';
meses[2] = 'Febrero';
meses[3] = 'Marzo';
meses[4] = 'Abril';
meses[5] = 'Mayo';
meses[6] = 'Junio';
meses[7] = 'Julio';
meses[8] = 'Agosto';
meses[9] = 'Septiembre';
meses[10] = 'Octubre';
meses[11] = 'Noviembre';
meses[12] = 'Diciembre';

var diasem = new Array();
diasem[1] = 'lunes';
diasem[2] = 'martes';
diasem[3] = 'miércoles';
diasem[4] = 'jueves';
diasem[5] = 'viernes';
diasem[6] = 'sábado';
diasem[0] = 'domingo';



function parseafecha(qfecha,elem,orden){
	var dia,mes,ano,hora,minutos;
	var miradiasem = new Date();
	var salida = '';

	
	dia = qfecha.slice(0,qfecha.indexOf('/'));
	qfecha = qfecha.substr(qfecha.indexOf('/')+1,qfecha.length);
	mes = qfecha.slice(0,qfecha.indexOf('/'));

	qfecha = qfecha.substr(qfecha.indexOf('/')+1,qfecha.length);
	ano = qfecha.slice(0,qfecha.indexOf(' '));
	qfecha = qfecha.substr(qfecha.indexOf(' ')+1,qfecha.length);
	hora = qfecha.slice(0,qfecha.length-6);
	qfecha = qfecha.substr(qfecha.indexOf(':')+1,qfecha.length);
	minutos = qfecha.slice(0,qfecha.length-3);

	//parche por un error inexplicable con agosto y septiembre (08 y 09) who knows
	if(mes=='08'){
		mes = '8';
	}
	if(mes=='09'){
		mes = '9';
	}

	miradiasem.setYear(parseInt(ano));
	miradiasem.setMonth(parseInt(mes)-1,dia);
//	miradiasem.setDate(parseInt(dia));

	diatxt = diasem[miradiasem.getDay()];
	
	//quitar el 0 izquierda
	if(dia.substr(0,1)=='0'){
		dia = dia.substr(1,1);
	}
	if(minutos=='00:00'){
		minutos = '!';
	}

	if(!elem){
//		return (dia +' de ' +meses[parseInt(mes)]+ ' de '+ ano + ' a las ' +hora);//con año
	  if(tipo[orden]!=8){
//		return (diatxt + ', ' + dia + ' de ' +meses[parseInt(mes)]+ ' a las ' +hora+':'+minutos);
		return (diatxt + ' ' + dia + ', a las ' +hora+':'+minutos);//parche septiembre
	  }else{
		return ('hasta el ' + diatxt + ', ' + dia + ' de ' +meses[parseInt(mes)]);//si es exposicion
	  }
	}else{
		return eval(elem);
	}
}



function wractuaciones(){
qano+=2000;
var htm='<table width="100%" border="0" cellspacing="5" cellpadding="0">', publicar = true,comp='';
FechaActual = new Date(parseInt(qano), (parseInt(qmes)-1), parseInt(qdia));

dac = FechaActual.getTime();



var txtvisible = 'display:none';
var txtvisibleB = '';
var qimagencierre = 'seguir';


if(actual<tempActual){
	desplegar = 'si';
}

if(desplegar=='si'){
	txtvisible = '';
	txtvisibleB = 'display:none';
	qimagencierre = 'cerrar';
}



for(i=1;i<=fecha1.length-1;i++){

//si hay enlace directo para que aparezca sólo un elemento
if(itemsolo=='false'||itemsolo==i){

if(itemsolo!='false'){
	txtvisible = '';
	txtvisibleB = 'display:none';
	qimagencierre = 'cerrar';
}

hastacompara = 0;



F1 = new Date(parseInt(parseafecha(fecha1[i],'ano')), parseInt(parseafecha(fecha1[i],'mes'))-1, parseInt(parseafecha(fecha1[i],'dia')))
F2 = new Date(parseInt(parseafecha(fecha2[i],'ano')), parseInt(parseafecha(fecha2[i],'mes'))-1, parseInt(parseafecha(fecha2[i],'dia')))
F3 = new Date(parseInt(parseafecha(fecha3[i],'ano')), parseInt(parseafecha(fecha3[i],'mes'))-1, parseInt(parseafecha(fecha3[i],'dia')))
F4 = new Date(parseInt(parseafecha(fecha4[i],'ano')), parseInt(parseafecha(fecha3[i],'mes'))-1, parseInt(parseafecha(fecha4[i],'dia')))



for(x=1;x<=4;x++){
cX = eval("fecha"+x+"["+i+"]");
  if(cX!=' '){
	hastacompara++;
  }
}

comp='dac>F1.getTime()';
for(y=2;y<=hastacompara;y++){
  comp+='&&dac>F'+y+'.getTime()';
}

if(eval(comp)){
  publicar = false;
}else{
  publicar = true;
}



if(hastacompara==1){
  if(dac>F1.getTime()){
    publicar = false;
  }else{
    publicar = true;
  }
}


 if(visible[i]=='Falso'||visible[i]=='False'){
  publicar = false;
 }

 if(actual!=tempActual){
   publicar = true;
 }

 if(qpublico!=0&&tipo[i]!=qpublico){
		 publicar = false;
 }
 
 //si qpublico es hora golfa o es cricot (11) y tipo es teatro, entonces publicar
 if(qpublico==1&&tipo[i]==12){
		publicar = true;	  
 }
 if(qpublico==1&&tipo[i]==11){
		publicar = true;	  
 }

  if(publicar){
    htm+= '<tr><td><a name="p'+i+'"></a><table width="100%" border="0" cellspacing="0" cellpadding="0">\n';
    htm+= '        <tr> \n';
    htm+= '          <td><table width="100%" border="0" cellspacing="0" cellpadding="0">\n';
    htm+= '              <tr> \n';
    htm+= '                <td width="1"><img src="img/cuad-izd.gif" width="13" height="12"></td>\n';
    htm+= '                <td background="img/cuad-fon.gif"><img src="img/spacer.gif" width="1" height="1"></td>\n';
    htm+= '                <td width="1"><a href="#top" class="cierre"><img src="img/cuad-der.gif" width="13" height="12" border="0"></a></td>\n';
    htm+= '              </tr>\n';
    htm+= '            </table></td>\n';
    htm+= '        </tr>\n';
    htm+= '        <tr> \n';
    htm+= '          <td bgcolor="CCCCCC"><table width="100%" border="0" cellspacing="1" cellpadding="0">\n';
    htm+= '              <tr>\n';
    htm+= '                <td bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="5" cellpadding="0">\n';
    htm+= '                    <tr> \n';/*<img src="img/publico'+tipo[i]+'.gif" width="130" height="25">*/
    htm+= '                      <td width="1" valign="top"><img src="img/publico'+tipo[i]+'.gif" width="130" height="25"><br><img src="contenidos/temporada'+actual+'/'+imagen[i]+'"></td>\n';
    htm+= '                      <td valign="top"><table width="100%" border="0" cellspacing="5" cellpadding="0">\n';
	
    htm+= '                          <tr> \n';
    htm+= '                            <td class="titulo2">'+artista[i]+'</td>\n';
    htm+= '                          </tr>\n';
 if(actual>=tempActual){
    htm+= '                          <tr> \n';

if(tipo[i]!=8){//excepto si es exposicion
    htm+= '<td class="reserva">Entrada: '+precio[i]+'</td>\n';
}else{
    htm+= '<td class="reserva">desde el '+precio[i]+'</td>\n';
}

    htm+= '                          </tr>\n';
	}else{
		htm+='<td class="parrafo2">'+fecha1[i]+'<br/>'+fecha2[i]+'<br/>'+fecha3[i]+'<br/>'+fecha4[i]+'<br/></td>';	
	}


			ctMini++;
			miniTexto[ctMini] = artista[i];
			miniLink[ctMini] = '#p'+i;


	if(fecha1[i]!=' '){
		 if(FechaActual.getTime()<=F1.getTime()){
			htm+= '<tr><td align="left"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr> \n';
			datoAg = fecha1[i];
			datoAg = datoAg.substr(datoAg.length-1,1);
			dato = parseafecha(fecha1[i],'',i);
			htm+= '<td class="titulo1">'+dato+'</td>\n';
			miniFecha[ctMini] = dato;
			 if(actual<tempActual){	
					if((FechaActual.getDate()+diasAntelacion)<=F1.getDate()){
						if(datoAg!='$'){
							if(datoAg=='*'){
								htm+=botonsinlocalidad();	
							}else{
								htm+=botonprecio(fecha1[i],precio[i],i);
							}
						}
					}else{
						htm+=botonsinres();			
					}
				

		 }else{
				if(datoAg!='$'){
					if(datoAg=='*'){
						htm+=botonsinlocalidad();	
					}else{
						htm+=botonprecio(fecha1[i],precio[i],i);
					}
				}
				
			}
			htm+= '</tr></table></td></tr>\n';
		 }
	}

	if(fecha2[i]!=' '){
		 if(FechaActual.getTime()<=F2.getTime()){
			htm+= '<tr><td align="left"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr> \n';
			datoAg = fecha2[i];
			datoAg = datoAg.substr(datoAg.length-1,1);
			dato = parseafecha(fecha2[i],'',i);

			if(!miniFecha[ctMini]){
				miniFecha[ctMini] = dato;
			}else{
				miniFecha[ctMini]+='<br>'+dato;				
			}
			htm+= '<td class="titulo1">'+dato+'</td>\n';
			 if(actual<tempActual){
				if((FechaActual.getDate()+diasAntelacion)<=F2.getDate()){
						if(datoAg!='$'){
							if(datoAg=='*'){
								htm+=botonsinlocalidad();	
							}else{
								htm+=botonprecio(fecha2[i],precio[i],i);
							}
						}	
				}else{
					htm+=botonsinres();			
				}
				
			}else{
				if(datoAg!='$'){
					if(datoAg=='*'){
						htm+=botonsinlocalidad();	
					}else{
						htm+=botonprecio(fecha2[i],precio[i],i);
					}
				}	 
				
			}
			htm+= '</tr></table></td></tr>\n';
		 }
	}

	if(fecha3[i]!=' '){
		 if(FechaActual.getTime()<=F3.getTime()){
			htm+= '<tr><td align="left"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr> \n';
			datoAg = fecha3[i];
			datoAg = datoAg.substr(datoAg.length-1,1);
			
			dato = parseafecha(fecha3[i],'',i);
			if(!miniFecha[ctMini]){
				miniFecha[ctMini] = dato;
			}else{
				miniFecha[ctMini]+='<br>'+dato;				
			}
			htm+= '<td class="titulo1">'+dato+'</td>\n';
		 if(actual<tempActual){
				if((FechaActual.getDate()+diasAntelacion)<=F3.getDate()){
					if(datoAg!='$'){
						if(datoAg=='*'){
							htm+=botonsinlocalidad();	
						}else{
							htm+=botonprecio(fecha3[i],precio[i],i);
						}
					}
				}else{
					htm+=botonsinres();			
				}
								
			 }else{
					if(datoAg!='$'){
						if(datoAg=='*'){
							htm+=botonsinlocalidad();	
						}else{
							htm+=botonprecio(fecha3[i],precio[i],i);
						}
					}	
								
				}
			htm+= '</tr></table></td></tr>\n';
		 }
	}
	
	if(fecha4[i]!=' '){
		// if(FechaActual.getTime()<=F4.getTime()){
			htm+= '<tr><td align="left"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr> \n';
			datoAg = fecha4[i];
			datoAg = datoAg.substr(datoAg.length-1,1);
			dato = parseafecha(fecha4[i],'',i);
			if(!miniFecha[ctMini]){
				miniFecha[ctMini] = dato;
			}else{
				miniFecha[ctMini]+='<br>'+dato;				
			}
			htm+= '                            <td class="titulo1">'+dato+'</td>\n';
		if(actual<tempActual){
	     	if((FechaActual.getDate()+diasAntelacion)<=F4.getDate()){
				if(FechaActual.getTime()<=F3.getTime()){
					if(datoAg!='$'){
						if(datoAg=='*'){
							htm+=botonsinlocalidad();	
						}else{
							htm+=botonprecio(fecha4[i],precio[i],i);
						}
					}
				}
		    }else{
				htm+=botonsinres();			
			}
							
		 }else{
				if(datoAg!='$'){
					if(datoAg=='*'){
						htm+=botonsinlocalidad();	
					}else{
						htm+=botonprecio(fecha4[i],precio[i],i);
					}
				}
							
			}
			htm+= '</tr></table></td></tr>\n';
	//	 }
	}
	
    htm+= '                          <tr> \n';
    htm+= '                            <td class="cia">'+cia[i]+'</td>\n';
    htm+= '                          </tr>\n';
    htm+= '                          <tr> \n';
    htm+= '                            <td class="parrafo2" id="tda'+i+'" style="'+txtvisibleB+'">'+texto[i].substr(0,60)+' ...</td>\n';
    htm+= '                          </tr>\n';
    htm+= '                          <tr> \n';

    htm+= '                            <td class="parrafo2" id="td'+i+'" style="'+txtvisible+'">'+texto[i]+'</td>\n';
    htm+= '                          </tr>\n';	
    htm+= '                          <tr>\n';
    htm+= '                            <td class="cia"><a href="JavaScript:swcelda('+i+')"><img src="img/'+qimagencierre+'.gif" width="105" height="13" border="0" id="boton'+i+'"></a></td>\n';
    htm+= '                          </tr>\n';
    htm+= '                        </table></td>\n';
    htm+= '                    </tr>\n';
    htm+= '                  </table></td>\n';
    htm+= '              </tr>\n';
    htm+= '            </table></td>\n';
    htm+= '        </tr>\n';
    htm+= '      </table></td></tr>\n';
  }
 }	
}
if(itemsolo!='false'){
qpublico = 1;
}
	htm+= '<tr><td><!--a href="JavaScript:plegartodo()"><img src="img/vertodos.gif" alt="Ver toda la cartelera plegada" width="15" height="15" border="0"></a--></td></tr></table>';
	 if(qpublico!=0){
			htm+='<table width="150" border="0" cellspacing="0" cellpadding="0"><tr><td background="../comun/util/fondoboton1.gif"><a href="JavaScript:seleccionaSeccion(0)" class="boton">ver TODAS actuaciones</a></td></tr></table>';
	 }
	document.write(htm);
}

function goMesActual(){
if(actual!=tempActual){
	document.write('<table width="150" border="0" cellspacing="0" cellpadding="0"><tr><td background="../comun/util/fondoboton1.gif"><a href="index.htm?quetemp='+tempActual+'&qpublico='+qpublico+'" class="boton">Ver: '+temporada[tempActual]+'</a></td></tr></table>');

//	document.write('<a href="index.htm?quetemp='+tempActual+'" class="titulo3"> Ver cartelera ACTUAL ('+temporada[tempActual]+')</a>')
}else{
	document.write('')	
}
}

function wravisos(){
var htm = '';
if(avisos.length>=1){
htm+='<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td>';
htm+='<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="1"><img src="img/cuad-izd.gif" width="13" height="12"></td>';
htm+='<td background="img/cuad-fon.gif"><img src="img/spacer.gif" width="1" height="1"></td><td width="1"><a href="../html/portada/index.htm" class="cierre">';
htm+='<img src="img/cuad-der.gif" width="13" height="12" border="0"></a></td></tr></table></td></tr><tr>';
htm+='<td bgcolor="CCCCCC"><table width="100%" border="0" cellspacing="1" cellpadding="0"><tr>';
htm+='<td bgcolor="#FFFFFF">';
htm+='<table width="100%" border="0" cellspacing="6" cellpadding="0">';
for(hh=1;hh<=avisos.length-1;hh++){
htm+='<tr><td class="parrafo2">'+avisos[hh]+'</td></tr>';
}
htm+='</table></td></tr></table></td></tr></table>';
}
document.write(htm);
}

function wrdossier(){
var htm='<table width="100%" border="0" cellspacing="0" cellpadding="0">';
for(i=1;i<=doss.length-1;i++){
htm+='<tr><td><a href="'+nomdosier[i]+'" class="link1" target="_blank">'+doss[i]+'</a></td></tr>';
}

htm+='</table>';
document.write(htm);
}

function vermessiguiente(){
var htm = '';
var ac = parseInt(actual);
if(ac<temporada.length-1){

htm ='<table width="150" border="0" cellspacing="0" cellpadding="0"><tr><td background="../comun/util/fondoboton2.gif"><a href="index.htm?quetemp='+(ac+1)+'&qpublico='+qpublico+'" class="boton2">Ver: '+temporada[(ac+1)]+'</a></td></tr></table>';

}
document.write(htm);
}

function wrMiniCartelera(){

var ht='',sw=0,micolor='';
 if(qpublico!=0){
	ht+='<table width="150" border="0" cellspacing="0" cellpadding="0"><tr><td background="../comun/util/fondoboton1.gif"><a href="JavaScript:seleccionaSeccion(0)" class="boton">ver TODAS actuaciones</a></td></tr></table>';
 }
ht+='<table width="100%" border="0" cellspacing="0" cellpadding="2">';
ht+='<tr><td class="parrafo3">Actuaciones '+temporada[actual]+'</td></tr>';
ht+='<tr><td><table width="100%"  border="0" cellspacing="0" cellpadding="0">';
for(x=1;x<=miniFecha.length-1;x++){
	if(sw==0){
		sw=1;
		micolor = '#F3F3F3';
	}else{
		sw=0;
		micolor = '#FFFFFF';
	}
	ht+='<tr><td bgcolor="'+micolor+'">';
	ht+='<table width="100%"  border="0" cellspacing="0" cellpadding="1">';
	ht+='<tr><td><b><a href="'+miniLink[x]+'" class="link1">'+miniTexto[x]+'</a></b></td></tr>';
	mF = miniFecha[x];
	if(mF=='undefined')mF=' ';
//	ht+='<tr><td class="parrafo3">'+mF+'</td></tr>';
	ht+='</table></td></tr>';
}
ht+='</table></td></tr></table>';
if(actual<tempActual){
	ht = '<a href="index.htm?quetemp='+tempActual+'" class="link1"> Ver cartelera ACTUAL<br>('+temporada[tempActual]+')</a>';
}
miniCartelera.innerHTML = ht;

}

function wrResPublico(tipopublico){
	var res = '';
	switch (tipopublico){
		case '0':
			res = '';
			break;
		case '1':
			res = 'Teatro';
			break;
		case '2':
			res = 'Teatro infantil';
			break;
		case '3':
			res = 'CONCIERTOS';
			break;
	}	
	document.write(res);
}

