
/********************************************************* FUNCIÓN Scroll */
function MueveScroll(pScroll,pEstado,pMovimiento,hContenedor,wContenedor,PixelsMov,TiempoMov){
var Posicion
var Tiempo
var AltoScroll
var AnchoScroll
var bMover

	bMover = false;

	AnchoScroll = document.getElementById(pScroll).offsetWidth + 70
	AltoScroll = document.getElementById(pScroll).offsetHeight + 10

	if(pMovimiento=='h'||pMovimiento=='H'){
		if(document.getElementById(pScroll).offsetWidth <= wContenedor){
			return false
		}
		Posicion = document.getElementById(pScroll).style.left
	}else{
		if(document.getElementById(pScroll).offsetHeight <= hContenedor){
			return false
		}
		Posicion = document.getElementById(pScroll).style.top
	}

	Posicion = Posicion.replace(/px/,"");
	Posicion = Posicion.replace(/pt/,"");
	Posicion = new Number(Posicion);
	
	switch(document.getElementById(pEstado).value){
		case 'up':
			Posicion += PixelsMov;
			if(Posicion >= 1){
				document.getElementById(pEstado).value = '';
				bMover = false;
			}else{
				document.getElementById(pScroll).style.top = Posicion;
				bMover = true;
			}
			break;
		case 'down':
			Posicion -= PixelsMov;
			if(Posicion <= (-1*(AltoScroll - hContenedor))){
				document.getElementById(pEstado).value = '';
				bMover = false;
			}else{
				document.getElementById(pScroll).style.top = Posicion;
				bMover = true;
			}
			break;
		case 'left':
			Posicion += PixelsMov;
			if(Posicion >= 1){
				document.getElementById(pEstado).value = '';
				bMover = false;
			}else{
				document.getElementById(pScroll).style.left = Posicion;
				bMover = true;
			}
			break;
		case 'right':
			Posicion -= PixelsMov;
			if(Posicion <= (-1*(AnchoScroll - wContenedor))){
				document.getElementById(pEstado).value = '';
				bMover = false;
			}else{
				document.getElementById(pScroll).style.left = Posicion;
				bMover = true;
			}
			break;
		default:
			bMover = false;
			break;
	}
	
	if(bMover){
		Tiempo = window.setTimeout('MueveScroll("'+pScroll+'","'+pEstado+'","'+pMovimiento+'",'+hContenedor+','+wContenedor+','+PixelsMov+','+TiempoMov+')',TiempoMov)
	}else{
		return false
	}

}


/********************************************************* FUNCIÓN AbrirPP */
function AbrirPP(img, ancho, alto){
  derecha=(screen.width-ancho)/2;
  arriba=(screen.height-alto)/2;
	string="toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+ancho+",height="+alto+",left="+derecha+",top="+arriba+"";
  fin=window.open(img,"",string);
}


function CompruebaCaracter(pCampo,pTexto,pDiv,pForm,Evento){
	if(!!window.event){
		if(Evento.keyCode == 13){
		var bOK;
			bOK = CompruebaCamposTexto(pCampo,pTexto,pDiv)
			if(!!bOK){
				switch(pForm){
					case 'BAvanzada':
						CompruebaBAvanzada()
						break
					case 'BRapida':
						CompruebaBRapida(pForm,pCampo,pTexto,pDiv,Evento)
						break
					case 'BMenu':
						Busca(pCampo,Evento)
						break
					case 'Estrenos':
						BuscarEstrenos(pCampo,Evento)
						break
					default:
						Evento.returnValue = false;
				}
			}else{
				Evento.returnValue = false;
			}
		}else{
			if(Evento.keyCode == 37){
				Evento.returnValue = false;
			}else{
				if(Evento.keyCode == 39){
					Evento.keyCode = 180;
				}
			}
		}
	}else{
		if(Evento.which == 13){
			switch(pForm){
				case 'BAvanzada':
					CompruebaBAvanzada()
					break
				case 'BRapida':
					CompruebaBRapida(pForm,pCampo,pTexto,pDiv,Evento)
					break
				case 'BMenu':
					Busca(pCampo,Evento)
					break
				case 'Estrenos':
					BuscarEstrenos(pCampo,Evento)
					break
				default:
					Evento.preventDefault()
					Evento.stopPropagation()
					break
			}
		}else{
			if((Evento.which == 37) || (Evento.which == 39)){
				Evento.preventDefault();
				Evento.stopPropagation();
			}
		}
	}
}


function ControlCamposFormulario(evento,campo,ValorDef,pDiv){
////el parámetro campo, es el OBJETO del campo a tratar
	if((evento =='focus') && (campo.value==ValorDef)){
		campo.value='';
	}else{
		if(campo.value==''){
			campo.value=ValorDef;
		}else{
			if(pDiv != ''){
				CompruebaCamposTexto(campo,ValorDef,pDiv)
			}
		}
	}
}


function CompruebaCamposTexto(pCampo,pValor,pDiv){
var Aux1;
var Aux2;
var Devolver;

	Devolver = false
	if((pCampo.name == 'txtAnioI') || (pCampo.name == 'txtAnioF')){
		var Fecha = new Date();
		if(((isNaN(pCampo.value)) || (pCampo.value < 1900) || (pCampo.value > Fecha.getFullYear())) && (pCampo.value != '')){
			//DeshabilitaFondo();
			pCampo.value = ''
			pCampo.disabled = true;
			document.getElementById(pDiv).style.display = '';
			document.getElementById(pDiv).focus();
		}else{
			Devolver = true
		}
	}else{
		if((parseInt(pCampo.value.length) < 2)){
			//DeshabilitaFondo();
			pCampo.value = ''
			pCampo.disabled = true;
			document.getElementById(pDiv).style.display = '';
			document.getElementById(pDiv).focus();
		}else{
			if((pCampo.value != pValor) && (pCampo.value != '')){
				if(parseInt(pCampo.value.length) > 0){
					Aux1 = Reemplazar(pCampo.value,"'","´");
					pCampo.value = Aux1;
				}

				if(parseInt(pCampo.value.length) > 0){
					Aux1 = Reemplazar(pCampo.value,"%","");
					pCampo.value = Aux1;
				}

				Aux2 = Aux1
				
				if(parseInt(Aux2.length) > 0){
					if(Aux2.indexOf(" ") == 0){
						bReemplazar = true;
						do{
							Aux1 = Aux2.replace(" ","");
							Aux2 = Aux1;

							if(!(parseInt(Aux2.length) > 0) || (Aux2.indexOf(" ") > 0)){
								bReemplazar = false;
							}
						}while(bReemplazar)
					}
				}

				if(parseInt(Aux2.length) > 0){
					if(Aux2.lastIndexOf(" ") == (Aux2.length - 1)){
						bReemplazar = true;
						do{
							Aux1 = Aux2.replace(" ","");
							Aux2 = Aux1;

							if(!(parseInt(Aux2.length) > 0) || (Aux2.lastIndexOf(" ") < (parseInt(Aux2.length) - 1))){
								bReemplazar = false;
							}
						}while(bReemplazar)
					}
				}

				pCampo.value = Aux2

				if((parseInt(pCampo.value.length) < 2) && (pCampo.value != pValor) && (pCampo.value != '')){
					//DeshabilitaFondo();
					pCampo.value = ''
					pCampo.disabled = true;
					document.getElementById(pDiv).style.display = '';
					document.getElementById(pDiv).focus();
				}else{
					Devolver = true
				}
			}else{
				Devolver = true;
			}
		}
	}
	return Devolver
}


function CompruebaBRapida(pForm,pCampo,pTxtBRapida,pDiv,Evento) {
	if((pCampo.value == pTxtBRapida) || (pCampo.value == '')) {
		//DeshabilitaFondo();
		document.getElementById(pDiv).style.display = '';
		if(event){
			Evento.returnValue = false;
		}else{
			Evento.preventDefault()
			Evento.stopPropagation()
		}
	}else{
	var bOK;
		bOK = CompruebaCamposTexto(pCampo,pTxtBRapida,'DivBRapidaIni');
		if(!!bOK){
			if(pCampo.name == 'txtBRapida2'){
				document.getElementById('txtBRapida').value = pCampo.value;
			}
			document.getElementById(pForm).submit()
		}
	}
}


function ColocaDiv(pDiv)
{
	var AnchoP;
	var AltoP;
	var Alto;
	
	if (pDiv.style.height==null){
		Alto=150;
	}else{
		Alto=pDiv.style.height;
	}

	AnchoP=replace(pDiv.style.width,'px','');
	AltoP=replace(Alto,'px','');

	Left = ((screen.width - AnchoP)/2);
	Top = ((screen.height - AltoP)/3);
	
	pDiv.style.left= Left;
	pDiv.style.top = Top;
}

function DeshabilitaFondo(){
	document.getElementById('Fondo').style.display = '';
}

function HabilitaFondo(){
	document.getElementById('Fondo').style.display = 'none';
}


function Reemplazar(sTexto,sCad1,sCad2){
var Aux1;
var Aux2;
var bReemplazar;

	Aux1 = sTexto
	Aux2 = '';
	if(sTexto.indexOf(sCad1) >= 0){
		bReemplazar = true;
		do{
			Aux2 = Aux1.replace(sCad1,sCad2)

			Aux1 = Aux2;
			if(Aux1.indexOf(sCad1) < 0){
				bReemplazar = false;
			}
		}while(bReemplazar)
	}

	return Aux1
}


function RestauraCamposTexto(pCampo,pValor){
	if(pCampo == 'txtAnio'){
	var arrValor;
		arrValor = pValor.split('#');
		if(document.getElementById(pCampo+'I').disabled){
			document.getElementById(pCampo+'I').disabled = false;
			document.getElementById(pCampo+'I').value = arrValor[0];
			document.getElementById(pCampo+'I').focus();
		}else{
			document.getElementById(pCampo+'F').disabled = false;
			document.getElementById(pCampo+'F').value = arrValor[1];
			document.getElementById(pCampo+'F').focus();
		}	
	}else{
		document.getElementById(pCampo).disabled = false;
		document.getElementById(pCampo).value = pValor;
		document.getElementById(pCampo).focus();
	}
}


// JavaScript Document
function AbrirVentana(pVentana,Nombre,Ancho,Alto,Left,Top,Scroll,Resize,Tool,Status,Menu,Location){
var Ventana;
var Opciones;
	if((Ancho > screen.width) || (Ancho == 0)){
		Ancho = screen.width - 2;
	}
	if((Alto > screen.height) || (Alto == 0)){
		Alto = screen.height - 2;
	}
	if(Left == 0){
		Left	= ((screen.width - Ancho)/2);
	}
	if(Top == 0){
		Top			= ((screen.height - Alto)/2);
	}
	Opciones	= 'width='+Ancho+',height='+Alto+',top='+Top+',left='+Left+',toolbar='+Tool+',scrollbars='+Scroll+',location='+Location+',statusbar='+Status+',menubar='+Menu+',resizable='+Resize;

	Ventana	= window.open(pVentana,'Filmotech',Opciones);
	Ventana.focus();
}


function MuestraTrailer(vISAN,sTitulo,RutaTrailer,MasInfo){
var Ventana;
	Ventana = window.open('../ES/FT_Trailer.asp?ISAN='+vISAN+'&titulo='+sTitulo+'&Ruta='+RutaTrailer+'&MasInfo='+MasInfo,'Trailer','width=450,height=438,Left=350,Top=300,Scrollbars=0,resizable=0,Toolbar=0,statusbar=0,Menubar=0,Location=0');
}

function CompruebaInt(){
	if(window.event.keyCode < 48 || window.event.keyCode > 57){
		window.event.returnValue = false;
	}
}