$(function(){$("#date-start").datepicker({dateFormat:"dd/mm/yy",dayNames:[tradDomingo,tradLunes,tradMartes,tradMiercoles,tradJueves,tradViernes,tradSabado],dayNamesMin:[tradDomingoMin,tradLunesMin,tradMartesMin,tradMiercolesMin,tradJuevesMin,tradViernesMin,tradSabadoMin],dayNamesShort:[tradDomingoCort,tradLunesCort,tradMartesCort,tradMiercolesCort,tradJuevesCort,tradViernesCort,tradSabadoCort],firstDay:1,minDate:new Date(),monthNames:[tradEne,tradFeb,tradMar,tradAbr,tradMay,tradJun,tradJul,tradAgo,tradSep,tradOct,tradNov,tradDic],monthNamesShort:[tradEneM,tradFebM,tradMarM,tradAbrM,tradMayM,tradJunM,tradJulM,tradAgoM,tradSepM,tradOctM,tradNovM,tradDicM],navigationAsDateFormat:true})
});function procesoCompra(G,H,E,C,A,D,B){var F=document.formMain;F.codFiscal.value=D;F.hora.value=B;F.fechaSeleccionada.value=C;F.idcine.value=G;F.idpeli.value=H;F.idSesion.value=E;F.idSala.value=A;F.action="selEntradasNoNumCine.do";F.submit()
}function filtrarPeliculas(){var B;B=$("#selmunicipio").val();var D;D=$("#selgenero").val();var F;var A;var E=0;if($("#chkEstrenos").is(":checked")){E=1}var C=0;if($("#chkVo").is(":checked")){C=1}var G=0;if($("#chk3d").is(":checked")){G=1}if(B=="todo"){if(D=="all"){if(E==1){if(C==1){if(G==1){$(".item_sub").slideToggle("fast");
$(".abierto").toggleClass("abierto");$(".item").hide();$(".itemT").hide();$(".item-sub").hide();$(".estrenovo3d").show();$(".estrenovo3dT").show()}else{$(".item_sub").slideToggle("fast");$(".abierto").toggleClass("abierto");$(".item").hide();
$(".itemT").hide();$(".item-sub").hide();$(".estrenovo").show();$(".estrenovoT").show()}}else{if(G==1){$(".item_sub").slideToggle("fast");$(".abierto").toggleClass("abierto");$(".item").hide();$(".itemT").hide();$(".item-sub").hide();$(".estreno3d").show();
$(".estreno3dT").show()}else{$(".item_sub").slideToggle("fast");$(".abierto").toggleClass("abierto");$(".item").hide();$(".itemT").hide();$(".item-sub").hide();$(".estreno").show();$(".estrenoT").show()}}}else{if(C==1){if(G==1){$(".item_sub").slideToggle("fast");
$(".abierto").toggleClass("abierto");$(".item").hide();$(".itemT").hide();$(".item-sub").hide();$(".vo3d").show();$(".vo3dT").show()}else{$(".item_sub").slideToggle("fast");$(".abierto").toggleClass("abierto");$(".item").hide();$(".itemT").hide();
$(".item-sub").hide();$(".vo").show();$(".voT").show()}}else{if(G==1){$(".item_sub").slideToggle("fast");$(".abierto").toggleClass("abierto");$(".item").hide();$(".itemT").hide();$(".item-sub").hide();$(".3d").show();$(".3dT").show()}else{$(".item").show();
$(".itemT").show()}}}}else{$(".item_sub").slideToggle("fast");$(".abierto").toggleClass("abierto");$(".item").hide();$(".itemT").hide();$(".item-sub").hide();if(E==1){if(C==1){if(G){$(".gen"+D+"estrenovo3d").show();$(".genT"+D+"estrenovo3dT").show()
}else{$(".gen"+D+"estrenovo").show();$(".genT"+D+"estrenovoT").show()}}else{if(G==1){$(".gen"+D+"estreno3d").show();$(".genT"+D+"estreno3dT").show()}else{$(".gen"+D+"estreno").show();$(".genT"+D+"estrenoT").show()}}}else{if(C==1){if(G==1){$(".gen"+D+"vo3d").show();
$(".genT"+D+"vo3dT").show()}else{$(".gen"+D+"vo").show();$(".genT"+D+"voT").show()}}else{if(G==1){$(".gen"+D+"3d").show();$(".genT"+D+"3dT").show()}else{$(".gen"+D).show();$(".genT"+D).show()}}}}F=$("#selgenero")[0];F.options[F.selectedIndex].text;
F=F.options[F.selectedIndex].text;$("#cabgenero").text(F);$("#cablocalidadinf").text(jsNombreProvincia)}else{$(".item_sub").slideToggle("fast");$(".abierto").toggleClass("abierto");A=$("#selmunicipio")[0];A.options[A.selectedIndex].text;A=A.options[A.selectedIndex].text;
$("#cablocalidadinf").text(A);F=$("#selgenero")[0];F.options[F.selectedIndex].text;F=F.options[F.selectedIndex].text;$("#cabgenero").text(F);CineAjax.getPeliculasMunicipio(B,jsIdEntidad,jsIdCanal,mostrarPeliculasMunicipio)}}function meterSesion(D,A,C){var B=parseInt(A.substring(0,2));
if(B==16||B==17){if(D[1]==null){D[1]=C}else{D[1]+=C}}else{if(B==18||B==19){if(D[2]==null){D[2]=C}else{D[2]+=C}}else{if(B==20||B==21){if(D[3]==null){D[3]=C}else{D[3]+=C}}else{if(B==22||B==23){if(D[4]==null){D[4]=C}else{D[4]+=C}}else{if(B>=0&&B<=5){if(D[5]==null){D[5]=C
}else{D[5]+=C}}else{if(B>=6&&B<=15){if(D[0]==null){D[0]=C}else{D[0]+=C}}}}}}}return D}function generarCodigoCine(B){var A="";if(B[0]!=null){A+=B[0]}if(B[1]!=null){A+=B[1]}if(B[2]!=null){A+=B[2]}if(B[3]!=null){A+=B[3]}if(B[4]!=null){A+=B[4]}if(B[5]!=null){A+=B[5]
}if(B[0]!=null||B[1]!=null||B[2]!=null||B[3]!=null||B[4]!=null||B[5]!=null){A+="</ul></td></tr></tbody>"}return A}function mostrarPeliculasMunicipio(F){$(".item_sub").slideToggle("fast");$(".abierto").toggleClass("abierto");if(F==null){$(".item").hide();
$(".itemT").hide()}else{$(".item").hide();$(".itemT").hide();$(".item-sub").hide();var D=0;if($("#chkEstrenos").is(":checked")){D=1}var B=0;if($("#chkVo").is(":checked")){B=1}var E=0;if($("#chk3d").is(":checked")){E=1}var C;var A;C=$("#selgenero").val();
A=$("#selmunicipio").val();for(i=0;i<F.length;i++){if(C=="all"){if(D==1){if(B==1){if(E==1){$(".peli"+F[i].id_espec+"estrenovo3d").show();$(".peliT"+F[i].id_espec+"estrenovo3dT").show()}else{$(".peli"+F[i].id_espec+"estrenovo").show();$(".peliT"+F[i].id_espec+"estrenovoT").show()
}}else{if(E==1){$(".peli"+F[i].id_espec+"estreno3d").show();$(".peliT"+F[i].id_espec+"estreno3dT").show()}else{$(".peli"+F[i].id_espec+"estreno").show();$(".peliT"+F[i].id_espec+"estrenoT").show()}}}else{if(B==1){if(E==1){$(".peli"+F[i].id_espec+"vo3d").show();
$(".peliT"+F[i].id_espec+"vo3dT").show()}else{$(".peli"+F[i].id_espec+"vo").show();$(".peliT"+F[i].id_espec+"voT").show()}}else{if(E==1){$(".peli"+F[i].id_espec+"3d").show();$(".peliT"+F[i].id_espec+"3dT").show()}else{$(".peli"+F[i].id_espec).show();
$(".peliT"+F[i].id_espec).show()}}}}else{for(f=0;f<peliGenero.length;f++){if(F[i].id_espec==peliGenero[f].pelicula&&peliGenero[f].genero==C){if(D==1){if(B==1){if(E==1){$(".peli"+F[i].id_espec+"estrenovo3d").show();$(".peliT"+F[i].id_espec+"estrenovo3dT").show()
}else{$(".peli"+F[i].id_espec+"estrenovo").show();$(".peliT"+F[i].id_espec+"estrenovoT").show()}}else{if(E==1){$(".peli"+F[i].id_espec+"estreno3d").show();$(".peliT"+F[i].id_espec+"estreno3dT").show()}else{$(".peli"+F[i].id_espec+"estreno").show();
$(".peliT"+F[i].id_espec+"estrenoT").show()}}}else{if(B==1){if(E==1){$(".peli"+F[i].id_espec+"vo3d").show();$(".peliT"+F[i].id_espec+"vo3dT").show()}else{$(".peli"+F[i].id_espec+"vo").show();$(".peliT"+F[i].id_espec+"voT").show()}}else{if(E==1){$(".peli"+F[i].id_espec).show();
$(".peliT"+F[i].id_espec).show()}else{$(".peli"+F[i].id_espec+"3d").show();$(".peliT"+F[i].id_espec+"3dT").show()}}}}}}}}}function filtrarFecha(C){var D;var B;var F;var A=$("#date-start").val();D=A.substring(6,10);B=A.substring(3,5);F=A.substring(0,2);
$("#date-start").val(F+"/"+B+"/"+D);$(".hoyspan").html(F+"/"+B+"/"+D);var E=$("#selmunicipio").val();$(".prog").parent().hide();$(".prog").hide();$(".progbody").hide();if(E!="todo"){$(".mf"+E+D+B+F).show();$(".mf"+E+D+B+F).parent().show()}else{$(".fch"+D+B+F).show();
$(".fch"+D+B+F).parent().show()}comprobarSiHaySesionesCart();if(C==null){$(".comboFechaPeli option[value=nada]").attr("selected",true)}}function openTrailer(B){var A=window.open("trailer.do?trailer="+B+"&autoInit=1","Trailer","toolbar=0,location=0,directories=0,status=0,dependent=0,menubar=0,scrollbars=0,width=400,height=342,left=200,top=200,resizable=0");
A.focus()}function comprobarSiHaySesionesCart(){var C=$("#date-start").val();var D=C.substring(6,10);var B=C.substring(3,5);var E=C.substring(0,2);for(k=0;k<=jslistaPelis.length;k++){var A=$(".pf"+jslistaPelis[k]+D+B+E);if(A.length==0){$("#sinsesionp"+jslistaPelis[k]).html("<span>"+tradNoHaySesionesParaEl+" <strong>"+E+"/"+B+"/"+D+"</strong></span>")
}else{$("#sinsesionp"+jslistaPelis[k]).html("")}}}function cargandoPeliculas(A,B){if(B==1){if(A!=0){$(".loadpel"+A).show()}}else{if(A!=0){$(".loadpel"+A).hide()}}}function cargarFechasEnCombo(D){if(D.length>0){var L=D.length;var K=new Array();
for(i=0;i<L;i++){var C=false;var J=D[i].fec_cel;if(i==0){K.push(J)}else{for(t=0;t<K.length;t++){if(K[t]==J){C=true}}if(!C){K.push(J)}}}var F=D[0].id_espec;x=$("#comboFechas"+F);var B='<option value="0">'+tradSelFecha+"</option>";for(p=0;p<K.length;
p++){var G=K[p].substring(6,8)+"/"+K[p].substring(4,6)+"/"+K[p].substring(0,4);var H=new Array(tradDomingo,tradLunes,tradMartes,tradMiercoles,tradJueves,tradViernes,tradSabado);var A=new Array(tradEne,tradFeb,tradMar,tradAbr,tradMay,tradJun,tradJul,tradAgo,tradSep,tradOct,tradNov,tradDic);
hoy=new Date();var I=K[p].substring(0,4);I=I*1;hoy.setFullYear(I);var E=K[p].substring(4,6);E=E*1;E=E-1;hoy.setMonth(E);var M=K[p].substring(6,8);M=M*1;hoy.setDate(M);B+='<option value="'+G+'">'+H[hoy.getDay()]+", "+K[p].substring(6,8)+" "+tradDeFecha+" "+A[E]+" "+tradDeFecha+" "+I+"</option>"
}$("#comboFechas"+F).html(B)}}function cambiarFechaCombo(B){var A;A=$("#comboFechas"+B).val();if(A!="0"){$("#date-start").val(A);filtrarFecha(1)}}function cargarProgPeli(D){cargarFechasEnCombo(D);var H=D[0];var K;cargandoPeliculas(H.id_espec,1);
K=$("#programacion"+H.id_espec);var N=D.length;var L="";var Q;var C;var M=new Boolean();var G=new Boolean();var P;var B;cambioFecha=new Boolean();var A=new Array();M=true;G=false;var I=new Array();for(i=0;i<N;i++){var E=i+1;C=D[i].lit_loc;idmunicipio=D[i].id_loc;
P=D[i].fec_cel;B=P.substring(6,8)+"/"+P.substring(4,6)+"/"+P.substring(0,4);Q='<a href="#" onclick="procesoCompra(\''+D[i].id_recinto+"','"+D[i].id_espec+"','"+D[i].id_sesion+"','"+D[i].fec_cel+"','"+D[i].id_area+"','"+D[i].codFiscal+"','"+D[i].hor_cel+"');return false;\">"+D[i].hor_cel+"</a>";
if(M){var F=false;for(t=0;t<I.length;t++){if(I[t]==idmunicipio){F=true}}if(F){var O=L.indexOf("mun"+C);var J=L.indexOf("prog",O);L=L.substring(0,J)+"prog fch"+P+" mf"+idmunicipio+""+P+" pf"+D[i].id_espec+""+P+L.substring(J+4,L.length)}else{I.push(idmunicipio);
if(i>0){L+="</table>"}L+='<table><thead id="mun'+C+'" class="prog mu'+idmunicipio+" fch"+P+" mf"+idmunicipio+P+" pf"+D[i].id_espec+P+'"><tr><td width="242">'+C+'</td><td width="303" class="hoy"><div id="hoydiv"><span class="hoyspan" id="hoyspan">'+B+'</span><div class="calendario_portableCLC enhoyCLC"></div></div></td></tr></thead>'
}L+='<tbody id="fecha'+jsCadenaFechaHoy+'" class="progbody mb'+idmunicipio+" fch"+P+" mf"+idmunicipio+P+" pf"+D[i].id_espec+P+'"><tr><td width="242"><a href="cines.do?idcine='+D[i].id_recinto+'">'+D[i].lit_recinto+" ("+tradSala+" "+D[i].numSala+')</a></td><td width="303" class="hoy"><ul>';
if(D[i].ntipo==0){A=meterSesion(A,D[i].hor_cel,'<li class="num">'+Q+"</a></li>")}else{A=meterSesion(A,D[i].hor_cel,"<li>"+Q+"</a></li>")}if(E<N){if(C!=D[E].lit_loc){L+=generarCodigoCine(A);A=new Array();M=true}else{M=false;if(P!=D[E].fec_cel){cambioFecha=true
}else{cambioFecha=false}}}else{L+=generarCodigoCine(A)}}else{if(cambioFecha){L+=generarCodigoCine(A);A=new Array();if(G){G=false}else{var F=false;for(t=0;t<I.length;t++){if(I[t]==idmunicipio){F=true}}if(F){var O=L.indexOf("mun"+C);var J=L.indexOf("prog",O);
L=L.substring(0,J)+"prog fch"+P+" mf"+idmunicipio+""+P+" pf"+D[i].id_espec+""+P+L.substring(J+4,L.length)}else{I.push(idmunicipio);L+='</table><table><thead id="mun'+C+'" class="prog mu'+idmunicipio+" fch"+P+" mf"+idmunicipio+P+" pf"+D[i].id_espec+P+'"><tr><td width="242">'+C+'</td><td width="303" class="hoy"><div id="hoydiv"><span class="hoyspan" id="hoyspan">'+B+'</span><div class="calendario_portableCLC enhoyCLC"></div></div></td></tr></thead>'
}}L+='<tbody id="fecha'+jsCadenaFechaHoy+'" class="progbody mb'+idmunicipio+" fch"+P+" mf"+idmunicipio+P+" pf"+D[i].id_espec+P+'"><tr><td width="242"><a href="cines.do?idcine='+D[i].id_recinto+'">'+D[i].lit_recinto+" ("+tradSala+" "+D[i].numSala+')</a></td><td width="303" class="hoy"><ul>';
if(D[i].ntipo==0){A=meterSesion(A,D[i].hor_cel,'<li class="num">'+Q+"</a></li>")}else{A=meterSesion(A,D[i].hor_cel,"<li>"+Q+"</a></li>")}if(E<N){if(C!=D[E].lit_loc&&E<N){L+=generarCodigoCine(A);A=new Array();M=true;cambioFecha=false}else{M=false;
if(P!=D[E].fec_cel&&E<N){cambioFecha=true}else{cambioFecha=false}}}else{L+=generarCodigoCine(A)}}else{if(D[i].id_area!=D[i-1].id_area){cambioFecha=true;i=i-1;G=true}else{if(D[i].ntipo==0){A=meterSesion(A,D[i].hor_cel,'<li class="num">'+Q+"</a></li>")
}else{A=meterSesion(A,D[i].hor_cel,"<li>"+Q+"</a></li>")}if(E<N){if(C!=D[E].lit_loc||D[i].lit_recinto!=D[E].lit_recinto){L+=generarCodigoCine(A);A=new Array();M=true}else{M=false;if(P!=D[E].fec_cel){cambioFecha=true}else{if(D[i].lit_recinto!=D[E].lit_recinto){cambioFecha=true;
i=i-1;G=true}else{cambioFecha=false}}}}else{if(E==N){L+=generarCodigoCine(A)}}}}}}L+="</table>";cargandoPeliculas(H.id_espec,0);K.append(L);filtrarFecha();$("#fechasDisp"+H.id_espec).show()}var cinesCargados=new Array();var existe=new Boolean();
$(document).ready(function(){$(".despliega").click(despliegaPeliculas);$(".link").click(despliegaPeliculas);$(".min_min_comprar").click(despliegaPeliculas);$("#date-start").val(jsStrFecha);$("#vista_lista").hide();parpadearMensajeVista(1);$(".contfecha").hide()
});var contador=0;function parpadearMensajeVista(A){if(contador<8){if(A==1){$("#msjCambiaVistaBtn").fadeOut("slow");contador++;setTimeout("parpadearMensajeVista(0)",1000)}else{$("#msjCambiaVistaBtn").fadeIn("slow");contador++;setTimeout("parpadearMensajeVista(1)",1000)
}}}function mostrarLista(){_gaq.push(["_trackEvent","cartelera","click en boton cartelera en lista","mostrar cartelera en lista"]);$("#bton_lista").addClass("seleccion_modo");$("#bton_tabla").removeClass("seleccion_modo");$("#vista_lista").show();
$("#vista_tabla").hide();$(".contfecha").show()}function mostrarTabla(){_gaq.push(["_trackEvent","cartelera","click en boton cartelera en tabla","mostrar cartelera en tabla"]);$("#bton_tabla").addClass("seleccion_modo");$("#bton_lista").removeClass("seleccion_modo");
$("#vista_tabla").show();$("#vista_lista").hide();$(".contfecha").hide()}function despliegaPeliculas(){var C="";var B=$(this).attr("class");if(B=="link"||B=="min_min_comprar"){C=$(this).parent().parent().attr("id")}else{C=$(this).parent().attr("id")
}$("#sinsesion"+C).html("");var D=new Boolean();D=false;C=C.substring(1,6);existe=false;for(i=0;i<cinesCargados.length;i++){if(cinesCargados[i]==C){existe=true}}var A=$(".abierto").attr("id");if(!existe){cinesCargados.push(C);var F="nada";for(f=0;
f<jslistPeliCopias.length;f++){if(C==jslistPeliCopias[f].pelicula){F=jslistPeliCopias[f].copias;f=jslistPeliCopias.length}}CineAjax.getProgramacionPelicula(C,jsIdEntidad,jsIdCanal,jsIdProv,F,cargarProgPeli);D=true}else{D=true;filtrarFecha()}var E="";
if(B=="link"||B=="min_min_comprar"){E=$(this).parent().parent().attr("id")}else{E=$(this).parent().attr("id")}if(A&&A!=E){$("#"+A+"_sub").slideToggle("fast");$(".abierto").toggleClass("abierto")}E="";if(B=="link"||B=="min_min_comprar"){E=$(this).parent().parent().attr("id")
}else{E=$(this).parent().attr("id")}$("#"+E+"_sub").slideToggle("fast");if(B=="link"||B=="min_min_comprar"){$(this).parent().parent().toggleClass("abierto")}else{$(this).parent().toggleClass("abierto")}if(D==false){filtrarFecha()}return false
}function filtrarCheckEstreno(){if($("#chkEstrenos").is(":checked")){alert(tradElCheck)}}function verTrailer(A,B){Shadowbox.open({content:"trailerAnuncio.do?idvideo="+A+"&width=600px&height=450px",player:"iframe",title:B,height:454,width:604})
};
