// JavaScript Document
function showErrormessage() // mensaje de usuario no correcto
{
	document.getElementById("textMessage").innerHTML ="<span class='ver10' >Usuario o contraseña incorrecta</span>";
	setTimeout("document.getElementById(\"textMessage\").innerHTML =\"\";",3000);
}

function showMaininterface()
{
	document.getElementById("window_login").style.display="none";
	document.getElementById("window_main").style.display="block";
}

/*Menu Perfil*/
function onFlechaLogin(submenu)
{
	switch (submenu) { 

		    case 1: 
				document.getElementById("flechaSubmenu").style.top='21px';
				document.getElementById("flechaSubmenu").style.left='206px';
	 	    break; 

		    case 2: 
				document.getElementById("flechaSubmenu").style.top='21px';
				document.getElementById("flechaSubmenu").style.left='370px';
    	    break; 

		    case 3: 
  				document.getElementById("flechaSubmenu").style.top='21px';
				document.getElementById("flechaSubmenu").style.left='547px';
		    break;

		    default: 

				document.getElementById("flechaSubmenu").style.top='21px';
				document.getElementById("flechaSubmenu").style.left='206px';
		}

	document.getElementById("flechaSubmenu").style.display="block";
}


function offFlechaLogin()
{
	document.getElementById("flechaSubmenu").style.display="none";
}

/*Windows Perfil - CONSULTA DE PUNTOS */ 

function showPointsUser(nombreUser,sexoUser,pointsAcumulados,pointsUtilizados,pointsDisponibles)
{
	if(sexoUser=="M")
	{document.getElementById("textNombreUsuario").innerHTML ="<span >BIENVENIDO &nbsp;"+nombreUser+"</span>";}
	else
	{document.getElementById("textNombreUsuario").innerHTML ="<span >BIENVENIDA &nbsp;"+nombreUser+"</span>";}

	document.getElementById("textHastaelMomentoRojo").innerHTML ="<b>"+pointsAcumulados+"</b>&nbsp;PUNTOS";
	document.getElementById("textUtilizados").innerHTML ="Utilizados &nbsp; :&nbsp;"+pointsUtilizados;
	document.getElementById("textDisponibles").innerHTML ="Disponibles &nbsp; :&nbsp;"+pointsDisponibles;
	document.getElementById("rClienteNombre").value=nombreUser;
	
}

/*   MUESTRA LOS DATOS DEL PERFIL DE USUARIO	*/
function showPerfilUser(codigoUser,nombreUser,sexoUser,fechaInscripcion,fechaNacimiento,dni,estadocivil,direccion,telefono,mail,ocupacion,centrotrabajo,centroestudio,celular,departamento,provincia,estrenos,programacion,promociones,noticias,generos,cines,distrito)
{
	document.getElementById("dataCodigo").innerHTML=codigoUser;
//	document.getElementById("dataCodigo_ra").innerHTML=codigoUser;	
	/*agregando para que asigne el codigo */
	/*****************************************************************************************/
	document.getElementById("client").value=codigoUser;
	document.getElementById("rClienteId").value=codigoUser;
	
	document.getElementById("txt_codigo_ra").value=codigoUser;
	/*****************************************************************************************/	
	
	document.getElementById("dataNombreUsuario").innerHTML =nombreUser;
	document.getElementById("dataFechaInscripcion").innerHTML =fechaInscripcion;
	document.getElementById("dataFechaNacimiento").innerHTML =fechaNacimiento;
	document.getElementById("dataDNI").value =dni;

	if(sexoUser=="M")
	{document.forms[0].radiosexo[0].checked="checked";}
	else
	{document.forms[0].radiosexo[1].checked="checked";}

	if(dni.length==8)
	{document.forms[0].radiodni[0].checked="checked";}
	else
	{document.forms[0].radiodni[1].checked="checked";}

	if(estrenos==1)
	{document.forms[0].estrenos.checked="checked";}

	if(programacion==1)
	{document.forms[0].programacion.checked="checked";}

	if(promociones==1)
	{document.forms[0].promociones.checked="checked";}

	if(noticias==1)
	{document.forms[0].noticias.checked="checked";}

	var descEstadoCivil
	switch(estadocivil)
	{

		case "S":
		descEstadoCivil="Soltero(a)";
		break;

		case "C":
		descEstadoCivil="Casado(a)";
		break;

		case "V":
		descEstadoCivil="Viudo(a)";
		break;
	
		case "D":
		descEstadoCivil="Divorciado(a)";
		break;		

		default:
		descEstadoCivil="Soltero(a)";
	}
	document.getElementById("txt_estadocivil").value =descEstadoCivil;
	document.getElementById("txt_calle").value =direccion;	
	document.getElementById("txt_telefono").value =telefono;
	document.getElementById("txt_celular").value =celular;
	document.getElementById("txt_email").value =mail;	
	document.getElementById("txt_email_ra").value =mail;		/*EMail de consulta puntos*/
	document.getElementById("txt_email_ra_o").value =mail;		/*EMail de consulta puntos*/	
	document.getElementById("txt_ocupacion").value =ocupacion;	
	document.getElementById("txt_centrotrabajo").value =centrotrabajo;	
	document.getElementById("txt_centroestudios").value =centroestudio;
	document.getElementById("inputGenero").innerHTML =generos;
	document.getElementById("inputCinePreferido").innerHTML =cines;
}

function showPerfilUser_concurso(codigoUser,nombreUser,nombreNombre,nombrePaterno,nombreMaterno,sexoUser,fechaInscripcion,fechaNacimiento,dni,estadocivil,direccion,telefono,mail,ocupacion,centrotrabajo,centroestudio,celular,departamento,provincia,estrenos,programacion,promociones,noticias,generos,cines,distrito)
{
	document.getElementById("dataCodigo").innerHTML=codigoUser;
//	document.getElementById("dataCodigo_ra").innerHTML=codigoUser;	
	/*agregando para que asigne el codigo */
	/*****************************************************************************************/
	document.getElementById("client").value=codigoUser;
	document.getElementById("rClienteId").value=codigoUser;
	
	document.getElementById("txt_codigo_ra").value=codigoUser;
	/*****************************************************************************************/	
	
//	document.getElementById("dataNombreUsuario").innerHTML =nombreUser;
//	document.getElementById("dataFechaInscripcion").innerHTML =fechaInscripcion;
//	document.getElementById("dataFechaNacimiento").innerHTML =fechaNacimiento;
	document.getElementById("dataDNI").value =dni;

	if(sexoUser=="M")
	{document.forms[0].radiosexo[0].checked="checked";}
	else
	{document.forms[0].radiosexo[1].checked="checked";}

	if(dni.length==8)
	{document.forms[0].radiodni[0].checked="checked";}
	else
	{document.forms[0].radiodni[1].checked="checked";}

	if(estrenos==1)
	{document.forms[0].estrenos.checked="checked";}

	if(programacion==1)
	{document.forms[0].programacion.checked="checked";}

	if(promociones==1)
	{document.forms[0].promociones.checked="checked";}

	if(noticias==1)
	{document.forms[0].noticias.checked="checked";}

	var descEstadoCivil
	switch(estadocivil)
	{

		case "S":
		descEstadoCivil="Soltero(a)";
		break;

		case "C":
		descEstadoCivil="Casado(a)";
		break;

		case "V":
		descEstadoCivil="Viudo(a)";
		break;
	
		case "D":
		descEstadoCivil="Divorciado(a)";
		break;		

		default:
		descEstadoCivil="Soltero(a)";
	}
	document.getElementById("txt_nombre").value =nombreNombre;
	document.getElementById("txt_paterno").value =nombrePaterno;
	document.getElementById("txt_materno").value =nombreMaterno;	
//	document.getElementById("dataNombreUsuarioPaterno").value =nombrePaterno;
//	document.getElementById("dataNombreUsuarioMaterno").value =nombreMaterno;	

	document.getElementById("txt_estadocivil").value =descEstadoCivil;
	document.getElementById("txt_calle").value =direccion;	
	document.getElementById("txt_telefono").value =telefono;
	document.getElementById("txt_celular").value =celular;
	document.getElementById("txt_email").value =mail;
	document.getElementById("txt_fechanacimiento").value =fechaNacimiento;	
	document.getElementById("txt_email_ra").value =mail;		/*EMail de consulta puntos*/
	document.getElementById("txt_email_ra_o").value =mail;		/*EMail de consulta puntos*/	
	document.getElementById("txt_ocupacion").value =ocupacion;	
	document.getElementById("txt_centrotrabajo").value =centrotrabajo;	
	document.getElementById("txt_centroestudios").value =centroestudio;
	document.getElementById("inputGenero").innerHTML =generos;
	document.getElementById("inputCinePreferido").innerHTML =cines;
}


function showErrorCajero(sMensaje,sCodigo)
{
	//document.getElementById("inputComboPelicula").innerHTML='';
	//document.getElementById("inputComboFuncion").innerHTML='';	
	
	  document.getElementById("inputComboPelicula").innerHTML='<select name="filmReservaslightBlueComboBox"  id="filmReservaslightBlueComboBox" class="select_reservas" disabled="disabled"><option value="-1">Seleccionar Pelicula</option></select>';


	alert(sMensaje);
	return;
}

function showErrorReserva(sDetails,sSolution) // muestra los errores de los XML
{   //alert('hola1');
	//alert(sDetails);
	//alert(sSolution);
	
	document.getElementById("inputComboCine").innerHTML='';
	document.getElementById("inputComboPelicula").innerHTML='';
	document.getElementById("inputComboFuncion").innerHTML='';
	document.getElementById("PassErrorReservas").style.display="block";
	document.getElementById("textDetailesErrorReserva").innerHTML =sDetails; //mensaje del ORACLE
	sSolutionc='Error: '+sSolution;
	document.getElementById("textSolutionErrorReserva").innerHTML=sSolutionc; // codigo de mensaje
	if(sSolution==90006 || sSolution==90005 || sSolution==90004)
	{	document.getElementById("buttonTerminar_Error").style.display="block";
	}
}

function cajeroabierto()
{	document.getElementById("rEbackWhiteCaja").style.display="none"; }

function cajerocerrado(sDetails,sCodigo)
{	estado = document.getElementById("estadocaja").value;
	showErrorReserva(sDetails,sCodigo);
	document.getElementById("rEbackWhiteCaja").style.display="none";
}


function initWindowMain()  // AQUI INICIA QUE PANTALLA MOSTRAR EN EL LOGIN.PHP
{
	document.getElementById("window_changePerfil_passTwo").style.display="none";
	document.getElementById("window_changePerfil_passThree").style.display="none";
	document.getElementById("window_changePerfil_passFour").style.display="none";
	document.getElementById("window_changePerfil_passFive").style.display="none";
	document.getElementById("window_changePerfil").style.display="none";
	document.getElementById("window_Middle").style.display="none";
	document.getElementById("window_reservarEntradas").style.display="none";
	document.getElementById("window_Puntos").style.display="none";
//	var showIt = document.getElementById("2").value; //
//	var showIt=document.getElementById("cWindow").value; //
	var showIt=parseInt(document.getElementById("cWindow").value); //
	document.getElementById("window_preloader").style.display="none";

//	alert(showIt);
	switch(showIt)
	{
		case 1:
		windowToShow="window_Puntos";  // MUESTRA PANTALLA PUNTOS
		sposition='206px';
		document.getElementById("currentDiv").value="window_Puntos";
		break;

		case 2:
		windowToShow="window_reservarEntradas"; // MUESTRA RESERVAR ENTRADAS
		sposition='370px';
		document.getElementById("currentDiv").value="window_reservarEntradas";
		break;

		case 3:
		windowToShow="window_changePerfil"; // MUESTRA CAMBIAR PERFIL
		sposition='547px';
		document.getElementById("currentDiv").value="window_changePerfil";
		break;	

		default:
		windowToShow="window_reservarEntradas"; // POR DEFECTO DESPUES DE LOGEARTE TE MUESTRA LA PANTALLA DE PUNTOS
		sposition='206px';
		document.getElementById("currentDiv").value="window_changePerfil";
	}

	document.getElementById(windowToShow).style.display="block";
	document.getElementById("flechaSubmenuPuntos").style.left=sposition;
	document.getElementById("flechaSubmenu").style.left=sposition;

	if(windowToShow=="window_reservarEntradas")  
	{
		if(document.getElementById("rClienteType").value=="O")
		{		
			document.getElementById("backWhiteNoReservas").style.display="none";
			document.getElementById("rEbackWhiteCaja").style.display="block";
			//xajax_validaCajero();
			var estado = document.getElementById("estadocaja").value;
			if(estado==0) //cerrado
			{
				document.getElementById("rEbackWhiteCaja").style.display="none";
			}
			else
			{	
				document.getElementById("rEbackWhiteCaja").style.display="none";		
				document.getElementById("PassOneReservas").style.display="block";
				document.getElementById("iscombobox_Reservas").value="Y";		
				sComplex=document.getElementById("rnoComplex").value;
				sFilm=document.getElementById("rnoFilm").value;
				document.getElementById("ridComplex").value=sComplex;
				document.getElementById("ridFilm").value=sFilm;
				document.getElementById("inputComboCine").innerHTML=scriptPreloader;
				document.getElementById("inputComboPelicula").innerHTML=scriptPreloader;
				document.getElementById("inputComboFuncion").innerHTML=scriptPreloader;	
				//alert(sComplex);
				xajax_getComplexReservas(sComplex); //primer combo de cines 
				//alert(sFilm);
				xajax_getFilmReservas(sFilm,sComplex);
				xajax_getFunctionReservas(sComplex,sFilm);
			}
			
		}
	}
}



function changeView(Idview)
{
	//alert(Idview);
	var showIt	
	var currentView=document.getElementById("currentDiv").value;
	document.getElementById(currentView).style.display="none";
	switch(Idview)
	{
		case 1:
		showIt="window_Puntos";
		document.getElementById("flechaSubmenuPuntos").style.left='206px';	
		break;

		case 2:
		showIt="window_reservarEntradas";
		document.getElementById("flechaSubmenuPuntos").style.left='370px';		
//		alert('370px');
		break;

		case 3:
		showIt="window_changePerfil";
		document.getElementById("flechaSubmenuPuntos").style.left='547px';
		break;	

		default:
		showIt="window_Puntos";
		document.getElementById("currentDiv").value="window_Puntos";
	}

	document.getElementById("currentDiv").value=showIt;
	document.getElementById(showIt).style.display="block";

	if(showIt=="window_reservarEntradas")
	{
		if (document.getElementById("iscombobox_Reservas").value=="N")
		{ 
			if(document.getElementById("rClienteType").value=="O")
			{		

				document.getElementById("backWhiteNoReservas").style.display="none";
				document.getElementById("rEbackWhiteCaja").style.display="block";
				//xajax_validaCajero();
				var estado = document.getElementById("estadocaja").value;
				if(estado==0)//cerrado
				{
					document.getElementById("rEbackWhiteCaja").style.display="none";				
				}
				else
				{	document.getElementById("rEbackWhiteCaja").style.display="none";
					document.getElementById("PassOneReservas").style.display="block";				
					xajax_getComplexReservas("");
					document.getElementById("iscombobox_Reservas").value="Y";
				}
				
			}
		}	
	}

}


function backPassOne()
{
	document.getElementById("window_changePerfil_passTwo").style.display="none";
	document.getElementById("window_changePerfil_passOne").style.display="block";
}

function backPassTwo()
{
	document.getElementById("window_changePerfil_passThree").style.display="none";
	document.getElementById("window_changePerfil_passTwo").style.display="block";
}

function backPassThree()
{
	document.getElementById("window_changePerfil_passFour").style.display="none";
	document.getElementById("window_changePerfil_passThree").style.display="block";
}

function backPassFour()
{
	document.getElementById("window_changePerfil_passFive").style.display="none";
	document.getElementById("window_changePerfil_passFour").style.display="block";
}

function nexttoPassone()
{
	document.getElementById("window_changePerfil_passOne").style.display="none";
	document.getElementById("window_changePerfil_passTwo").style.display="block";
}


function nexttoPasstwo()
{
	document.getElementById("window_changePerfil_passTwo").style.display="none";
	document.getElementById("window_changePerfil_passThree").style.display="block";
}

function nexttoPassthree()
{
	document.getElementById("window_changePerfil_passThree").style.display="none";
	document.getElementById("window_changePerfil_passFour").style.display="block";
}

function nexttoPassfour()
{
	document.getElementById("window_changePerfil_passFour").style.display="none";
	document.getElementById("window_changePerfil_passFive").style.display="block";
}


function validationPassOne()
{
	var radiodni = getSelectedRadio(document.forms[0].radiodni);
	var numerodni
	if (radiodni == 0)
	{	if(!validatorObject_core("dataDNI","I","DNI","Paso 1",3,"Nº","2")){return;}
		if(!validatorObject_core("dataDNI","I","DNI","Paso 1",3,"0","3")){return;}
		if(!validatorObject_core("dataDNI","V","DNI","Paso 1")){return;}
		if(!validatorObject_core("dataDNI","N","DNI","Paso 1")){return;}
		numerodni=document.getElementById("dataDNI").value;	}
	else{numerodni="";}
	if(!validatorObject_core("txt_estadocivil","I","Estado Civil","Paso 1",3,"--Seleccionar--","1")){return;}
	dataUser[0]=numerodni;
	dataUser[1]=getSelectedRadioValue(document.forms[0].radiosexo);
	dataUser[2]=document.getElementById("txt_estadocivil").value;
	nexttoPassone();
}

function validationPassOne_concurso()
{
	var radiodni = getSelectedRadio(document.forms[0].radiodni);
	var numerodni
	if (radiodni == 0)
	{	if(!validatorObject_core("dataDNI","I","DNI","Paso 1",3,"Nº","2")){return;}
		if(!validatorObject_core("dataDNI","I","DNI","Paso 1",3,"0","3")){return;}
		if(!validatorObject_core("dataDNI","V","DNI","Paso 1")){return;}
		if(!validatorObject_core("dataDNI","N","DNI","Paso 1")){return;}
		numerodni=document.getElementById("dataDNI").value;	}
	else{numerodni="";}
	if(!validatorObject_core("txt_estadocivil","I","Estado Civil","Paso 1",3,"--Seleccionar--","1")){return;}
	dataUser[0]=numerodni;
	dataUser[1]=getSelectedRadioValue(document.forms[0].radiosexo);
	dataUser[2]=document.getElementById("txt_estadocivil").value;
	dataUser[20]=document.getElementById("txt_fechanacimiento").value;	
	dataUser[21]=document.getElementById("txt_nombre").value;	
	dataUser[22]=document.getElementById("txt_paterno").value;	
	dataUser[23]=document.getElementById("txt_materno").value;	
	dataUser[24]=document.getElementById("idconcurso").value;
	nexttoPassone();
}

function validationPassTwo()
{
	if(!validatorObject_core("txt_departamento","I","Departamento","Paso 2",3,"---Seleccione Departamento---","1")){return;}
	if(!validatorObject_core("txt_provincia","I","Provincia","Paso 2",3,"---Seleccione Provincia---","1")){return;}
	if(!validatorObject_core("txt_distrito","I","Distrito","Paso 2",3,"---Seleccione Distrito---","1")){return;}
	if(!validatorObject_core("txt_telefono","N","Telefono","Paso 2")){return;}	
	if(!validatorObject_core("txt_celular","N","Celular","Paso 2")){return;}	
//	if(!validatorObject_core("txt_email","V","Email","Paso 2")){return;}
	if(!validateEmail(document.getElementById("txt_email").value))
	{alert("Error en el paso 2 : El campo Email es incorrecto. Por favor ingrese un Email correcto");return;}
	dataUser[3]=document.getElementById("txt_departamento").value;
	dataUser[4]=document.getElementById("txt_provincia").value;
	dataUser[5]=document.getElementById("txt_distrito").value;
	dataUser[6]=document.getElementById("txt_calle").value;
	dataUser[7]=document.getElementById("txt_telefono").value;
	dataUser[8]=document.getElementById("txt_celular").value;
	dataUser[9]=document.getElementById("txt_email").value;
	nexttoPasstwo();
}

function validationPassThree()
{
	dataUser[10]=document.getElementById("txt_ocupacion").value;
	dataUser[11]=document.getElementById("txt_centrotrabajo").value;
	dataUser[12]=document.getElementById("txt_centroestudios").value;
	nexttoPassthree();
}

function validationPassFour()
{
	if(document.forms[0].estrenos.checked){dataUser[13]='1';}else{dataUser[13]='0';}	
	if(document.forms[0].programacion.checked){dataUser[14]='1';}else{dataUser[14]='0';}	
	if(document.forms[0].promociones.checked){dataUser[15]='1';}else{dataUser[15]='0';}	
	if(document.forms[0].noticias.checked){dataUser[16]='1';}else{dataUser[16]='0';}	
	var strGenero="";
	var totalcheck=document.forms[0].GF.length;

	for (var i=0; i<totalcheck; i++) {
         if (document.forms[0].GF[i].checked) {
            strGenero=strGenero+"1";
         } else { 
            strGenero=strGenero+"0";
         }
    }

	dataUser[17]=strGenero;
	nexttoPassfour();
}

function validationPassFive()
{
	var strCine="";
	var totalcheck=document.forms[0].CP.length;
	for (var i=0; i<totalcheck; i++) {
         if (document.forms[0].CP[i].checked) {
           strCine=strCine+"1";
         } else { 
           strCine=strCine+"0";
	     }
    }

	dataUser[18]=strCine;
	dataUser[19]=document.getElementById("client").value;
	nexttoPassfive();
}

function nexttoPassfive()
{
	document.getElementById("window_changePerfil_passFive").style.display="none";
	document.getElementById("window_savePerfil").style.display="block";
	sendDataFormPerfilUser();
}

function validationPassFive_concurso() /*  guardar perfcil - concurso comedia romana */ 
{
	var strCine="";
	var totalcheck=document.forms[0].CP.length;
	for (var i=0; i<totalcheck; i++) {
         if (document.forms[0].CP[i].checked) {
           strCine=strCine+"1";
         } else { 
           strCine=strCine+"0";
	     }
    }

	dataUser[18]=strCine;
	dataUser[19]=document.getElementById("client").value;
	nexttoPassfive_concurso();
}

function nexttoPassfive_concurso()  /*  guardar perfcil - concurso comedia romana */ 
{
	document.getElementById("window_changePerfil_passFive").style.display="none";
	document.getElementById("window_savePerfil").style.display="block";
	sendDataFormPerfilUser_concurso();
}


function initWindowPerfil()
{
	document.getElementById("window_changePerfil_passTwo").style.display="none";
	document.getElementById("window_changePerfil_passThree").style.display="none";
	document.getElementById("window_changePerfil_passFour").style.display="none";
	document.getElementById("window_changePerfil_passFive").style.display="none";
	document.getElementById("window_savePerfil").style.display="none";
	document.getElementById("window_changePerfil_passOne").style.display="block";
}

function sendDataFormPerfilUser()
{
	var DFUtoString=""; 
	for(i=0;i<20;i++)
	{DFUtoString=DFUtoString+"|"+dataUser[i];}
	xajax_saveDataFormPerfilUser(DFUtoString.substr(1));
}

function sendDataFormPerfilUser_concurso() /*  guardar perfcil - concurso comedia romana */ 
{
	var DFUtoString=""; 
	for(i=0;i<25;i++)
	{DFUtoString=DFUtoString+"|"+dataUser[i];}
	xajax_saveDataFormPerfilUser_concurso(DFUtoString.substr(1));
}



function vPassOneRes() // avanzar paso 1 para reservas 
{
	if(!validatorObject_core("complexReservaslightBlueComboBox","I","Elegir Cine","Formulario",3,"Buscar Cine","1")){return;}
	if(!validatorObject_core("filmReservaslightBlueComboBox","I","Elegir Película","Formulario",3,"Buscar Película","1")){return;}
	if(!validatorObject_core("functionReservaslightBlueComboBox","I","Elegir Función","Formulario",3,"Buscar Función","1")){return;}

	idComplex=document.getElementById("ridComplex").value;
	idFilm=document.getElementById("ridFilm").value;
	idFunction=document.getElementById("ridFunction").value;
	idSala=document.getElementById("ridSala").value;
	document.getElementById("textTicketFunction").innerHTML=scriptPreloader;
	document.getElementById("textTicketFunction").innerHTML=PreloaderBoletos;
	
	//xajax_getSiteFunctionReservas(idcomplex,idfilm,idfunction,idsala);
	/******/
	xajax_getTicketFunctionReservas(idComplex,idFilm,idFunction,idSala);
	nPassOneRes();
	/*****/
}

function nPassOneRes() // Limpia el paso 1 y muestra paso 2
{
	document.getElementById("PassOneReservas").style.display="none";
	document.getElementById("PassTwoReservas").style.display="block";
}


function bPassOneRes() // retorceder al paso 1 para reservas 
{
	document.getElementById("PassTwoReservas").style.display="none";
	document.getElementById("PassOneReservas").style.display="block";
	
	var scriptPreloader='<img src="images/ajax-loader_perfil.gif" width="16" height="16" />&nbsp;<span class="ver10bold">Procesando</span>';
	document.getElementById("textDisponible").innerHTML=scriptPreloader;
	var idcomplex=document.getElementById("ridComplex").value;
	var idfilm=document.getElementById("ridFilm").value;
	var idfunction=document.getElementById("ridFunction").value;
	var idsala = document.getElementById("ridSala").value;
	
	document.getElementById("textTotalTicketReserva").innerHTML='';
	document.getElementById("rtotPagTicket").value=0;
	document.getElementById("rtotNumTicket").value=0;
	document.getElementById("rTipTicket").value=0;
	//xajax_getSiteFunctionReservas(idcomplex,idfilm,idfunction);
	/*************************************************************************/	
	document.getElementById("NextPassOneReserv").innerHTML='';
	/************************************************************************/
	xajax_getSiteFunctionReservas(idcomplex,idfilm,idfunction,idsala);
}



function vPassTwoRes() // avanzar al paso 3
{
	sTextNumberTickets=parseInt(document.getElementById("rtotNumTicket").value);
	sTextNumberDispon=parseInt(document.getElementById("rsitesFunction").value);

	if(sTextNumberTickets<1)
	{alert("No ha ingresado cantidad de entradas a reservar");return;}

	if(sTextNumberTickets>6)
	{alert("Le recordamos que solo puede reservar un máximo de 6 entradas por Operación");return;}
	
	if(sTextNumberDispon<sTextNumberTickets)
	{alert("No puede reservar mas a lo disponible");return;}

	sTextCine=document.getElementById("complexReservaslightBlueComboBox").options[document.getElementById("complexReservaslightBlueComboBox").selectedIndex].text;
	
	sTextPelicula=document.getElementById("filmReservaslightBlueComboBox").options[document.getElementById("filmReservaslightBlueComboBox").selectedIndex].text;

	sTextFunction=document.getElementById("functionReservaslightBlueComboBox").options[document.getElementById("functionReservaslightBlueComboBox").selectedIndex].text;

	sTextFunction2=sTextFunction.toUpperCase();
	
	sTextNumberTickets=document.getElementById("rtotNumTicket").value;
	if(sTextNumberTickets==0)
	{alert("Debe Ingresar almenos un ticket"); return;}
	
	sTextTotalPago=document.getElementById("rtotPagTicket").value;
	if(sTextTotalPago==0)
	{alert("Debe Ingresar almenos un ticket"); return;}
	
	
	
	document.getElementById("textNombreCine").innerHTML=sTextCine.toUpperCase();
	document.getElementById("textNombrePelicula").innerHTML=sTextPelicula.toUpperCase();
	document.getElementById("textHoraFuncion").innerHTML=sTextFunction2;
	document.getElementById("textCantidadEntradas").innerHTML=sTextNumberTickets+" entradas";
	document.getElementById("textTotalPago").innerHTML=document.getElementById("rMoneda").value+sTextTotalPago;
	nPassTwoRes();

}

function nPassTwoRes() // limpia el paso 2 y muestra el paso 3
{
	document.getElementById("PassTwoReservas").style.display="none";
	document.getElementById("PassThreeReservas").style.display="block";
}


function showClientesPremium(mensaje) // redirecciona a login
{
	alert(mensaje);
	location.href= "login.php";	
}

function showClientesPremium_concurso(mensaje) // concurso comedia romana
{
	alert(mensaje);
	location.href= "index.php";	
}


function bPassTwoRes() // retrocede al paso 2
{
	document.getElementById("PassThreeReservas").style.display="none";
	document.getElementById("PassTwoReservas").style.display="block";
}

function updateScroll()
{
	var scroller  = null;
	var scrollbar = null;
	scroller  = new jsScroller(document.getElementById("Scroller-1_reservas"), 400, 68);
	scrollbar = new jsScrollbar (document.getElementById("Scrollbar-Container_reservas"), scroller, false);
}

function cSubtotal(indice)
{

	sNamePrecio="txtPrecio"+indice;
	sNameComision="txtComision"+indice;
	sNameCantidad="txtCantidad"+indice;
	sNameDivSubtotal="inputSubtotal"+indice;
	sNameSubtotal="txtSubtotal"+indice;
	sNumberEntradas=document.getElementById(sNameCantidad).value;
	

	if(!(sNumberEntradas.length>0))
	{	document.getElementById(sNameCantidad).value="";
		sNumberEntradas="0";
	}

	if(!validatorObject_core(sNameCantidad,"N","Cantidad","Formulario"))
	{	document.getElementById(sNameCantidad).value="";
		sNumberEntradas="0";
	}
	
	if(sNumberEntradas.length>6)
	{	alert("Cantidad no puede exceder la 6 entradas");
		document.getElementById(sNameCantidad).value="";
		sNumberEntradas="0";
	}
	
	
	fValuePrecio=parseFloat(document.getElementById(sNamePrecio).value);
	fValueComision=parseFloat(document.getElementById(sNameComision).value);
	iValueCantidad=parseInt(sNumberEntradas);
	

	
	fValueSubFloat = parseFloat(fValuePrecio+fValueComision);

	//alert("hola");
	//alert(fValuePrecio);
	//alert(fValueComision);
	
	fValueSubtotal=(fValuePrecio+fValueComision)*iValueCantidad;
	
	fValueSubtotal = Math.round(fValueSubtotal*100)/100;
	
	document.getElementById(sNameDivSubtotal).innerHTML =document.getElementById("rMoneda").value+fValueSubtotal;
	
	document.getElementById(sNameSubtotal).value =fValueSubtotal;
	
	cTotalTickets();
}

//MODIFICADO 24/03/2006 651
//MODIFICADO 11/03/2008 647

function cTotalTickets() 
{
	iTickets=parseInt(document.getElementById("totalTicket").value);
	//alert(iTickets);
	fTotalPago=0;
	iTotalEntradas=0;
	sTicketsCantidad="";
	sTBoletos="";
	sTPrecios="";
	sTComisiones="";
	sTCantidades="";
	sTSubtotales="";
	
	
	if(iTickets==0)
	{ 	iTickets=0; 	}
 	else
	{	iTickets=iTickets-1;
	}
	
	//alert(iTickets);
	
	for(i=0;i<=iTickets;i++)
	{
		sNameIdTicket="txtIdEntrada"+i;
		sNameSubtotal="txtSubtotal"+i;
		sNameCantidad="txtCantidad"+i;
		sMBoletos="mBoletos"+i;
		sMPrecios="mPrecios"+i;
		sMComisiones="mComisiones"+i;
		
		//alert(sNameCantidad);
		//alert(sNameSubtotal);
		
		sNumberEntradas=document.getElementById(sNameCantidad).value;
		sSubTotal=document.getElementById(sNameSubtotal).value;
		if(!(sNumberEntradas.length>0))
		{iNumberEntradas=0;}
		else{iNumberEntradas=parseInt(document.getElementById(sNameCantidad).value);
	}

		if(!(sSubTotal.length>0)){fSubTotalTicket=0;}else{fSubTotalTicket=parseFloat(sSubTotal);}

		fTotalPago=fTotalPago+fSubTotalTicket;
		iTotalEntradas=iTotalEntradas+iNumberEntradas;
		
		if(iNumberEntradas>0)
		{sTicketsCantidad=sTicketsCantidad+"|cant"+document.getElementById(sNameIdTicket).value+"="+iNumberEntradas;}
		
		sTBoletos=sTBoletos+"|"+document.getElementById(sMBoletos).value;
		sTPrecios=sTPrecios+"|"+document.getElementById(sMPrecios).value;
		sTComisiones=sTComisiones+"|"+document.getElementById(sMComisiones).value;
		sTCantidades=sTCantidades+"|"+iNumberEntradas;
		sTSubtotales=sTSubtotales+"|"+fSubTotalTicket;
	}

	document.getElementById("rTipTicket").value=sTicketsCantidad;
	document.getElementById("rtotNumTicket").value=iTotalEntradas;
	document.getElementById("rtotPagTicket").value=fTotalPago;
	document.getElementById("mBoletos").value=sTBoletos;
	document.getElementById("mPrecios").value=sTPrecios;
	document.getElementById("mComisiones").value=sTComisiones;
	document.getElementById("mCantidades").value=sTCantidades;
	document.getElementById("mSubtotales").value=sTSubtotales;
	
	fTotalPago = Math.round(fTotalPago*100)/100;
	//alert(fTotalPago);
	
	document.getElementById("textTotalTicketReserva").innerHTML =document.getElementById("rMoneda").value+fTotalPago;
}



function vPassSave() //llama al paso guardar
{

nSave();
}

function nSave() // paso guardar los manda a la funcion xajax_savedataReserva
{
	
if(document.frm_login.chkterminos.checked==true){
	
	sTextClienteId=document.getElementById("rClienteId").value;
	sTextCliente=document.getElementById("rClienteNombre").value;
	sTextCine=document.getElementById("ridComplex").value;
	sTextPelicula=document.getElementById("ridFilm").value;
	sTextFunction=document.getElementById("ridFunction").value;
	sTextSala=document.getElementById("ridSala").value;
	sTextNumberTickets=document.getElementById("rtotNumTicket").value;
	sTextTotalPago=document.getElementById("rtotPagTicket").value;
	sTextTicketCantidad=document.getElementById("rTipTicket").value;
	sTextMoneda=document.getElementById("rMoneda").value;
	sTextBoletos=document.getElementById("mBoletos").value;
	sTextPrecios=document.getElementById("mPrecios").value;
	sTextComisiones=document.getElementById("mComisiones").value;
	sTextCantidades=document.getElementById("mCantidades").value;
	sTextSubtotales=document.getElementById("mSubtotales").value;
	sTextUltimo=document.getElementById("functionReservaslightBlueComboBox").options[document.getElementById("functionReservaslightBlueComboBox").selectedIndex].text;
	document.getElementById("PassThreeReservas").style.display="none";
	document.getElementById("PassSaveReservas").style.display="block";
	document.getElementById("textClienteReserva").innerHTML=sTextCliente;
	
	xajax_saveDataReserva(sTextClienteId,sTextCine,sTextPelicula,sTextFunction,sTextSala,sTextNumberTickets,sTextTotalPago,sTextTicketCantidad,sTextMoneda,sTextBoletos.substr(1),sTextPrecios.substr(1),sTextComisiones.substr(1),sTextCantidades.substr(1),sTextSubtotales.substr(1),sTextUltimo);

//	alert("NO TE OLVIDES DE TENER A LA MANO TU NUMERO DE INDICADOR, Y RECUERDA QUE TIENES SOLO 20 MINUTOS ANTES DEL INICIO LA FUNCIÓN PARA PODER CANJEAR TUS BOLETOS, DE LO CONTRARIO TU RESERVA QUEDARA SIN EFECTO.\nCANJEA TUS ENTRADAS EN EL CENTRO DE ATENCIÓN AL CLIENTE (CAC) !!!");/*MENSAJE ANTES DE RESERVA*/


	}else{
		alert("Tienes que aceptar las NORMAS DEL USUARIO para poder reservar");
	}
}

function showIdentificardorReserva(idReserva)
{
	document.getElementById("textCodigoReserva").innerHTML=idReserva;
}


function showLogin() // oculta preloader y muestra login
{
	document.getElementById("window_preloader").style.display="none";
	document.getElementById("window_login").style.display="block";
}

function showPreloader() // muestra gif
{
	document.getElementById("window_preloader").style.display="block";
}



function getFilm() // va a buscar las peliculas para el cine seleccionado
{
	var idComplex=document.getElementById("complexReservaslightBlueComboBox").options[document.getElementById("complexReservaslightBlueComboBox").selectedIndex].value;
	
	//alert(idComplex);
	
	if(idComplex=='-1') // si escoge opcion -1
	{ //alert("Escoger Cine");
	  document.getElementById("inputComboPelicula").innerHTML='<select name="complexReservaslightBlueComboBox" id="complexReservaslightBlueComboBox" class="select_reservas" disabled="disabled"><option value="-1">Seleccionar Película</option></select>';
	  document.getElementById("inputComboFuncion").innerHTML='<select name="functionReservaslightBlueComboBox" id="functionReservaslightBlueComboBox" class="select_reservas" disabled="disabled"><option value="-1">Seleccionar Funcion</option></select>';
	  idComplex='';
	  document.getElementById("textDisponible").innerHTML='';
	  document.getElementById("NextPassOneReserv").innerHTML='';
	  
	  document.getElementById("rsitesFunction").value=0;
	  document.getElementById("ridComplex").value=0;
	  document.getElementById("ridFilm").value=0;
	  document.getElementById("ridFunction").value=0;
	  document.getElementById("ridSala").value=0;
	  
	  return;
	}
	else  // si escoge un cine
	{
		
	document.getElementById("ridComplex").value=idComplex;
	document.getElementById("inputComboPelicula").innerHTML=scriptPreloader;
	document.getElementById("functionReservaslightBlueComboBox").disabled=true;
	document.getElementById("textDisponible").innerHTML='';
	document.getElementById("NextPassOneReserv").innerHTML='';
	document.getElementById("ridFilm").value=0;
	document.getElementById("ridFunction").value=0;
	document.getElementById("ridSala").value=0;
	document.getElementById("rsitesFunction").value=0;
	xajax_getFilmReservas("",idComplex);	
	
	}
	
}

function getFunction() // va a buscar las  funciones de la pelicula selleciona 
{
	
	var idFilm=document.getElementById("filmReservaslightBlueComboBox").options[document.getElementById("filmReservaslightBlueComboBox").selectedIndex].value;
	if(idFilm=='-1'){ 
		//alert("Escoger película");
		document.getElementById("inputComboFuncion").innerHTML='<select name="functionReservaslightBlueComboBox" id="functionReservaslightBlueCombox" class="select_reservas" disabled="disabled"><option value="-1">Buscar Func&iacute;on</option></select>';
		document.getElementById("textDisponible").innerHTML='';
		document.getElementById("NextPassOneReserv").innerHTML='';
		document.getElementById("rsitesFunction").value=0;
		document.getElementById("ridFilm").value=0;
		document.getElementById("ridFunction").value=0;
		document.getElementById("ridSala").value=0;
		return;
	}
	else{
	document.getElementById("filmReservaslightBlueComboBox").disable=false;
	document.getElementById("inputComboFuncion").innerHTML='<select name="functionReservaslightBlueComboBox"id="functionReservaslightBlueComboBox" class="select_reservas" disabled="disabled"><option value="-1">Buscar Pel&iacute;cula</option></select>';
	document.getElementById("ridFilm").value=idFilm;
	var idComplex=document.getElementById("ridComplex").value;
	document.getElementById("textDisponible").innerHTML='';
	document.getElementById("NextPassOneReserv").innerHTML='';	
	document.getElementById("rsitesFunction").value=0;
	document.getElementById("inputComboFuncion").innerHTML=scriptPreloader;		
	xajax_getFunctionReservas(idComplex,idFilm);
	}
}

function getSites() // a buscar lo disponible de acuerdo al cine, pelicula, funcion(hora) y sala
{
		// funcion en minutos
		var idfunction=document.getElementById("functionReservaslightBlueComboBox").options[document.getElementById("functionReservaslightBlueComboBox").selectedIndex].value;
	
		if(idfunction=='-1')
		{
			alert("Seleccione una Funcion");
			document.getElementById("textDisponible").innerHTML='';
			document.getElementById("NextPassOneReserv").innerHTML='';
			return;
		}
		else if(idfunction=='1')
		{
			alert("Seleccione otra Película");
			return;
		}
		else
		{
			var idcomplex=document.getElementById("ridComplex").value;
			var idfilm=document.getElementById("ridFilm").value;	
			//sala
			var textsala=document.getElementById("functionReservaslightBlueComboBox").options[document.getElementById("functionReservaslightBlueComboBox").selectedIndex].text;
			var idsala=textsala.substr(16,2);
			document.getElementById("ridSala").value=textsala.substr(16,2);
			document.getElementById("ridFunction").value=idfunction;
			document.getElementById("textDisponible").innerHTML=scriptPreloader;
			document.getElementById("NextPassOneReserv").innerHTML='';
			xajax_getSiteFunctionReservas(idcomplex,idfilm,idfunction,idsala);
			
		}
	
	
	
}

///////////////////////////////////////////////////////////ULTIMOS CAMBISO////////////////////////////////////////////


function validarmail(email){
	var filtro  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (!filtro.test(email)){
        alert("Su dirección de email es incorrecta");
        return;
    }
	loanding_email();
} 
function loanding_email()
{
	document.getElementById("ver").style.display="block";
	document.getElementById("ver").innerHTML="<img src='images/loading_celeste.gif' width='10' height='10' />Actualizando...";
	setTimeout("document.getElementById(\"ver\").style.display =\"none\";",3000);
	xajax_EditarRubro(xajax.getFormValues('frm_login'));
	xajax_verContacto(xajax.getFormValues('frm_login'));
}
function loanding_email_new()
{
	document.getElementById("ver_new_email").style.display="block";
	document.getElementById("ver_new_email").innerHTML="Actualizando...";
//	setTimeout("document.getElementById(\"ver_new_email\").style.display =\"none\";",3000);
	xajax_verContacto(xajax.getFormValues('frm_login'));
}
