/////////////////VARIABLES TEXTO ///////////////////////


///////////////////FIN VARIABLES TEXTO//////////////////


////FUNCION PARA DETECTAR EXPLORER

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};


////FIN FUNCION PARA DETECTAR EXPLORER

function CompruebaInt(){
	if(window.event.keyCode < 48 || window.event.keyCode > 57){
		window.event.returnValue = false;
	}
}


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)
			}
		}
	}
}

/*
	/////////////////		Backup de la función

			function CompruebaCamposTexto(pCampo,pValor,pDiv){
				if((pCampo.name == 'txtAnioI') || (pCampo.name == 'txtAnioF')){
					var Fecha = new Date();
					if((isNaN(pCampo.value)) || (pCampo.value < 1900) || (pCampo.value > Fecha.getFullYear())){
						pCampo.value = ''
						pCampo.disabled = true;
						document.getElementById(pDiv).style.display = '';
						document.getElementById(pDiv).focus();
					}
				}else{
					if(pCampo.value.length < 3){
						pCampo.value = ''
						pCampo.disabled = true;
						document.getElementById(pDiv).style.display = '';
						document.getElementById(pDiv).focus();
					}
				}
			}
	/////////////////
*/

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) < 3)){
			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.substring(1,Aux2.length)
							Aux2 = Aux1;

							if(!(parseInt(Aux2.length) > 0) || (Aux2.indexOf(" ") > 0)){
								bReemplazar = false;
							}
						}while(bReemplazar)
					}
			
					if(Aux2.lastIndexOf(" ") == (Aux2.length - 1)){
						bReemplazar = true;
						do{
							Aux1 = Aux2.substring(0,(Aux2.length-1))
							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) < 3) && (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 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();
	}
}

//FUNCION EXTERNA SCROLL
function MM_findObj(n, d) { //v4.01
  var p,i,x;  
  if(!d) d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) 
    {
     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
    }
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

/*function FT_VScroll(el,dr,ty,oy,spd,limit) { //v1.7 by PVII

 var g,gg,fr,sp,pa='',slw=true,m=false,h,ly;ty=parseInt(ty);
 if((g=MM_findObj(el))!=null){gg=(document.layers)?g:g.style;}else{return;}
 if(dr=="Stop"){if(g.toMove){clearTimeout(g.p7Magic);}g.toMove=false;}
 if((parseInt(navigator.appVersion)>4 || navigator.userAgent.indexOf("MSIE")>-1)&& !window.opera){pa="px";}
 if(navigator.userAgent.indexOf("NT")>-1 || navigator.userAgent.indexOf("Windows 2000")>-1){slw=false;}
 if(spd=="Slow"){sp=(slw)?2:1;fr=(slw)?40:30;}else if(spd=="Medium"){sp=(slw)?4:1;fr=(slw)?40:10;
 }else{sp=(slw)?8:4;fr=(slw)?40:10;}if(spd=="Warp"){sp=7;}var yy=parseInt(gg.top);if(isNaN(yy)){
 if(g.currentStyle){yy=parseInt(g.currentStyle.top);}else if(document.defaultView&&document.defaultView.getComputedStyle){
 yy=parseInt(document.defaultView.getComputedStyle(g,"").getPropertyValue("top"));}else{yy=0;}}
 if ((yy<limit)&&(dr=='Down')){
		return;
	}
 if(document.all || document.getElementById){h=parseInt(g.offsetHeight);
 if(!h){h=parseInt(g.style.pixelHeight);}
 }else if(document.layers){h=parseInt(g.clip.height);}ly=ty+parseInt(oy)-h;
 if(dr=="Down"){if(yy>ly){m=true;yy-=sp;if(yy<ly){yy=ly;}}}
 if(dr=="Up"){if(yy<ty){m=true;yy+=sp;if(yy>ty){yy=ty;}}}
 if(dr=="Reset"){gg.top=ty+pa;if(g.toMove){clearTimeout(g.p7Magic);}g.toMove=false;}
 if(m){gg.top=yy+pa;if(g.toMove){clearTimeout(g.p7Magic);}g.toMove=true;
  eval("g.p7Magic=setTimeout(\"FT_VScroll('"+el+"','"+dr+"',"+ty+","+oy+",'"+spd+"',"+limit+")\","+fr+")");
 }else{g.toMove=false;}
}*/

/* COPIA DE SEGURIDAD DE FT_VScroll*/
function FT_VScroll(el,dr,ty,oy,spd) { //v1.7 by PVII
 var g,gg,fr,sp,pa='',slw=true,m=false,h,ly;ty=parseInt(ty);
 if((g=MM_findObj(el))!=null){gg=(document.layers)?g:g.style;}else{return;}
 if(dr=="Stop"){if(g.toMove){clearTimeout(g.p7Magic);}g.toMove=false;}
 if((parseInt(navigator.appVersion)>4 || navigator.userAgent.indexOf("MSIE")>-1)&& !window.opera){pa="px";}
 if(navigator.userAgent.indexOf("NT")>-1 || navigator.userAgent.indexOf("Windows 2000")>-1){slw=false;}
 if(spd=="Slow"){sp=(slw)?2:1;fr=(slw)?40:30;}else if(spd=="Medium"){sp=(slw)?4:1;fr=(slw)?40:10;
 }else{sp=(slw)?8:4;fr=(slw)?40:10;}if(spd=="Warp"){sp=7;}var yy=parseInt(gg.top);if(isNaN(yy)){
 if(g.currentStyle){yy=parseInt(g.currentStyle.top);}else if(document.defaultView&&document.defaultView.getComputedStyle){
 yy=parseInt(document.defaultView.getComputedStyle(g,"").getPropertyValue("top"));}else{yy=0;}}
 if(document.all || document.getElementById){h=parseInt(g.offsetHeight);
 if(!h){h=parseInt(g.style.pixelHeight);}
 }else if(document.layers){h=parseInt(g.clip.height);}ly=ty+parseInt(oy)-h;
 if(dr=="Down"){if(yy>ly){m=true;yy-=sp;if(yy<ly){yy=ly;}}}
 if(dr=="Up"){if(yy<ty){m=true;yy+=sp;if(yy>ty){yy=ty;}}}
 if(dr=="Reset"){gg.top=ty+pa;if(g.toMove){clearTimeout(g.p7Magic);}g.toMove=false;}
 if(m){gg.top=yy+pa;if(g.toMove){clearTimeout(g.p7Magic);}g.toMove=true;
  eval("g.p7Magic=setTimeout(\"FT_VScroll('"+el+"','"+dr+"',"+ty+","+oy+",'"+spd+"')\","+fr+")");
 }else{g.toMove=false;}
}




function FT_HScroll(el,dr,tx,ox,spd) { //v1.7 by PVII
var g,gg,fr,sp,pa='',slw=true,m=false,w,ww,lx,rx;tx=parseInt(tx);
if((g=MM_findObj(el))!=null){gg=(document.layers)?g:g.style;}else{return;}
if(dr=="Stop"){if(g.toMove){clearTimeout(g.p7Magic);}g.toMove=false;}
if((parseInt(navigator.appVersion)>4 || navigator.userAgent.indexOf("MSIE")>-1)&& !window.opera){pa="px";}
if(navigator.userAgent.indexOf("NT")>-1 || navigator.userAgent.indexOf("Windows 2000")>-1){slw=false;}
//speed settings?
if(spd=="Slow"){sp=(slw)?2:1;fr=(slw)?40:30;}else if(spd=="Medium"){sp=(slw)?4:1;fr=(slw)?40:10;
}else{sp=(slw)?8:4;fr=(slw)?40:10;}if(spd=="Warp"){sp=7;}var xx = parseInt(gg.left);if(isNaN(xx)){
if(g.currentStyle){xx=parseInt(g.currentStyle.left);}else if(document.defaultView&&document.defaultView.getComputedStyle){
xx=parseInt(document.defaultView.getComputedStyle(g,"").getPropertyValue("left"));}else{xx=0;}}
if(document.all || document.getElementById){w=parseInt(g.offsetWidth);if(!w){w=parseInt(g.style.pixelWidth);}
if(g.hasChildNodes){for(wx=0;wx<g.childNodes.length;wx++){ww=parseInt(g.childNodes[wx].offsetWidth);
if(ww>w){w=ww;}}}}else if(document.layers){w=parseInt(g.clip.width);}lx=tx-w+parseInt(ox);rx=tx;
if(dr=="Right"){if(xx>lx){m=true;xx-=sp;if(xx<lx){xx=lx;}}}
if(dr=="Left"){if(xx<rx){m=true;xx+=sp;if(xx>rx){xx=rx;}}}
if(dr=="Reset"){gg.left=tx+pa;if(g.toMove){clearTimeout(g.p7Magic);}g.toMove=false;}
if(m){gg.left=xx+pa;if(g.toMove){clearTimeout(g.p7Magic);}g.toMove=true;
eval("g.p7Magic=setTimeout(\"FT_HScroll('"+el+"','"+dr+"',"+tx+","+ox+",'"+spd+"')\","+fr+")");
}else{g.toMove=false;}
}


function EnviaACesta(IdProducto,ISAN,IdUsuario,AmbitoOk,blEnviaOK,CRapida){
	if (IdUsuario != 0){
		//USUARIO REGISTRADO
		if (IdProducto==""){
			document.getElementById('DivNoClicPolitica').style.display='';
		}else{
 			if(AmbitoOk =="True"){
				location.href="FT_InsertaCesta.asp?IdProducto="+IdProducto+"&ISAN="+ISAN+"&IdUsuario="+IdUsuario+"&blEnviaOk="+blEnviaOK+"&CRapida="+CRapida
			}else{
				document.getElementById('DivNoAmbito').style.display='';
			}
		}
	}else{
		// USUARIO SIN REGISTRAR
		document.getElementById('DivNoRegistrado').style.display='';
	}

}

function EnviaACestaV2(IdPrecioObra,ISAN,IdUsuario,AmbitoOk,blEnviaOK,CRapida){
	if(IdUsuario != 0){
		//USUARIO REGISTRADO
		if (IdPrecioObra==""){
			document.getElementById('DivNoClicPolitica').style.display='';
		}else{
 			if(AmbitoOk =="True"){
				location.href="FT_InsertaCestaV2.asp?IdPrecio="+IdPrecioObra+"&ISAN="+ISAN+"&IdUsuario="+IdUsuario+"&blEnviaOk="+blEnviaOK+"&CRapida="+CRapida
			}else{
				document.getElementById('DivNoAmbito').style.display='';
			}
		}
	}else{
		// USUARIO SIN REGISTRAR
		document.getElementById('DivNoRegistrado').style.display='';
	}

}

function LlamaPagoTarjeta(IdPrecioObra, ISAN, IdUsuario, AmbitoOk, blEnviaOK, CRapida, Pasarela, Corto) {
	AbrirVentana('FT_PagoTarjeta.asp?IdPrecio='+IdPrecioObra+'&ISAN='+ISAN+'&IdUsuario='+IdUsuario+'&blEnviaOk='+blEnviaOK+'&blAmbitoOk='+AmbitoOk+'&CRapida='+CRapida+'&Pasarela='+Pasarela+'&Corto='+Corto,'Trailer',595,570,0,0,0,0,0,0,0,0);
}


function EnviaASMS(IdPrecio,vISAN,IdTipoProd,AmbitoOk,Corto){
	if (AmbitoOk =="True"){
		AbrirVentana('FT_ObtencionCodigoSMS.asp?ISAN='+vISAN+'&IdTipoProd='+IdTipoProd+'&Corto='+Corto+'&IdPrecio='+IdPrecio,'Trailer',595,570,0,0,0,0,0,0,0,0);
	}else{
		document.getElementById('DivNoAmbito').style.display='';
	}		
}

function EnviaA905(vISAN,IdTipoProd,AmbitoOk,Corto){
	if (AmbitoOk =="True"){
		AbrirVentana('FT_ObtencionCodigo905.asp?ISAN='+vISAN+'&IdTipoProd='+IdTipoProd+'&Corto='+Corto,'Trailer',595,570,0,0,0,0,0,0,0,0);
	}else{
		document.getElementById('DivNoAmbito').style.display='';
	}
}

function CodigoPromocion(vISAN,AmbitoOk){
	if (AmbitoOk =="True"){
		AbrirVentana('FT_CodigoPromocion.asp?ISAN='+vISAN,'Trailer',595,570,0,0,0,0,0,0,0,0)
	}else{
		document.getElementById('DivNoAmbito').style.display='';
	}
}

function CodigoPromocionF(vISAN,AmbitoOk){
	if (AmbitoOk =="True"){
		AbrirVentana('FT_CodigoPromocionF.asp?ISAN='+vISAN,'Trailer',595,570,0,0,0,0,0,0,0,0)
	}else{
		document.getElementById('DivNoAmbito').style.display='';
	}
}

	
/*************************************************/
/***************ActivaFormulario******************/
/*************************************************/
	function ActivaFormulario(pform,TxDatosPromo,TxDatosFactura)
{
	if(pform == 'P'){
		//GESTIONA PARTE DE PROMOCION
		if (document.getElementById('DatosPromocionACTIVO').value==1){
			document.getElementById('TitPromociones').innerHTML= '<div id="MFTituloGAb1"><img src="../images/spacer.gif" alt WIDTH="1" HEIGHT="1"></div><div id="MFTituloGAb2">'+TxDatosPromo+'</div><div id="MFTituloGAb3"><img src="../images/spacer.gif" alt WIDTH="1" HEIGHT="1"></div>';
			document.getElementById('DatosPromocionACTIVO').value = 0;
			///PONER EN GRIS TODA ESA PARTE
			document.getElementById('lbTxMiEspacio1').style.className="TxG01";
			document.getElementById('txtNombre1').disabled=1;
			document.getElementById('lbNombre1').style.className = "TxG01";
			document.getElementById('txtApellidos1').disabled=1;
			document.getElementById('lbApellidos1').style.className = "TxG01";
			document.getElementById('SelPaisOrigen').disabled=1;			
			document.getElementById('lbSelPaisOrigen').style.className="TxG01";
			document.getElementById('selSexo').disabled=1;
			document.getElementById('lbselSexo').style.className="TxG01";
			document.getElementById('txtFhNacimientoDia').disabled=1;
			document.getElementById('txtFhNacimientoMes').disabled=1;
			document.getElementById('txtFhNacimientoAnyo').disabled=1;
			document.getElementById('lbFhNacimiento').style.className="TxG01";
			document.getElementById('txtCdPostal1').disabled=1;
			document.getElementById('lbCdPostal1').style.className="TxG01";
			document.getElementById('txtGenero_Favorito').disabled=1;
			document.getElementById('lbGeneroFavorito').style.className="TxG01";
			document.getElementById('txtActor_Favorito').disabled=1;
			document.getElementById('lbActorFavorito').style.className="TxG01";
			document.getElementById('txtActriz_Favorita').disabled=1;
			document.getElementById('lbActrizFavorita').style.className="TxG01";
			document.getElementById('txtDirector_Favorito').disabled=1;
			document.getElementById('lbDirectorFavorito').style.className="TxG01";
		}else{
			document.getElementById('TitPromociones').innerHTML= '<div id="MFTituloGA1"><img src="../images/spacer.gif" alt WIDTH="1" HEIGHT="1"></div><div id="MFTituloGA2">'+TxDatosPromo+'</div><div id="MFTituloGA3"><img src="../images/spacer.gif" alt WIDTH="1" HEIGHT="1"></div>';
			document.getElementById('DatosPromocionACTIVO').value = 1;
			///QUITAR EL GRIS A TODA ESA PARTE
			document.getElementById('lbTxMiEspacio1').style.className="";
			document.getElementById('txtNombre1').disabled=0;
			document.getElementById('lbNombre1').style.className = "";
			document.getElementById('txtApellidos1').disabled=0;
			document.getElementById('lbApellidos1').style.className = "";
			document.getElementById('SelPaisOrigen').disabled=0;			
			document.getElementById('lbSelPaisOrigen').style.className="";	
			document.getElementById('selSexo').disabled=0;
			document.getElementById('lbselSexo').style.className="";	
			document.getElementById('txtFhNacimientoDia').disabled=0;
			document.getElementById('txtFhNacimientoMes').disabled=0;
			document.getElementById('txtFhNacimientoAnyo').disabled=0;	
			document.getElementById('lbFhNacimiento').style.className="";
			document.getElementById('txtCdPostal1').disabled=0;
			document.getElementById('lbCdPostal1').style.className="";
			document.getElementById('txtGenero_Favorito').disabled=0;
			document.getElementById('lbGeneroFavorito').style.className="";
			document.getElementById('txtActor_Favorito').disabled=0;
			document.getElementById('lbActorFavorito').style.className="";
			document.getElementById('txtActriz_Favorita').disabled=0;
			document.getElementById('lbActrizFavorita').style.className="";
			document.getElementById('txtDirector_Favorito').disabled=0;
			document.getElementById('lbDirectorFavorito').style.className="";				
		}
	}else{
		//GESTIONA PARTE DE FACTURACION		
		if (document.getElementById('DatosFacturacionACTIVO').value==1){
			document.getElementById('TitFacturacion').innerHTML= '<div id="MFTituloGAb1"><img src="../images/spacer.gif" alt WIDTH="1" HEIGHT="1"></div><div id="MFTituloGAb2">'+TxDatosFactura+'</div><div id="MFTituloGAb3"><img src="../images/spacer.gif" alt WIDTH="1" HEIGHT="1"></div>';
			document.getElementById('DatosFacturacionACTIVO').value = 0;
			///PONER EN GRIS TODA ESA PARTE
			document.getElementById('lbTxMiEspacio2').style.className="TxG01";
			document.getElementById('txtEmpresa').disabled=1;
			document.getElementById('lbEmpresa').style.className = "TxG01";
			document.getElementById('txtNombre2').disabled=1;
			document.getElementById('lbNombre2').style.className = "TxG01";
			document.getElementById('txtApellidos2').disabled=1;
			document.getElementById('lbApellidos2').style.className = "TxG01";
			document.getElementById('SelPais2').disabled=1;
			document.getElementById('lbSelPais2').style.className = "TxG01";
			document.getElementById('txtDomicilio2').disabled=1;
			document.getElementById('lbDomicilio2').style.className = "TxG01";
			document.getElementById('txtCdPostal2').disabled=1;
			document.getElementById('lbCdPostal2').style.className = "TxG01";
			document.getElementById('txtLocalidad2').disabled=1;
			document.getElementById('lbLocalidad2').style.className = "TxG01";										
			document.getElementById('txtProvincia2').disabled=1;
			document.getElementById('lbProvincia2').style.className = "TxG01";					
		}else{
			document.getElementById('TitFacturacion').innerHTML= '<div id="MFTituloGA1"><img src="../images/spacer.gif" alt WIDTH="1" HEIGHT="1"></div><div id="MFTituloGA2">'+TxDatosFactura+'</div><div id="MFTituloGA3"><img src="../images/spacer.gif" alt WIDTH="1" HEIGHT="1"></div>';
			document.getElementById('DatosFacturacionACTIVO').value = 1;
			///QUITAR EN GRIS TODA ESA PARTE
			document.getElementById('lbTxMiEspacio2').style.className="";
			document.getElementById('txtEmpresa').disabled=0;
			document.getElementById('lbEmpresa').style.className = "";
			document.getElementById('txtNombre2').disabled=0;
			document.getElementById('lbNombre2').style.className = "";
			document.getElementById('txtApellidos2').disabled=0;
			document.getElementById('lbApellidos2').style.className = "";				
			document.getElementById('SelPais2').disabled=0;
			document.getElementById('lbSelPais2').style.className = "";
			document.getElementById('txtDomicilio2').disabled=0;
			document.getElementById('lbDomicilio2').style.className = "";
			document.getElementById('txtCdPostal2').disabled=0;
			document.getElementById('lbCdPostal2').style.className = "";						
			document.getElementById('txtLocalidad2').disabled=0;
			document.getElementById('lbLocalidad2').style.className = "";	
			document.getElementById('txtProvincia2').disabled=0;
			document.getElementById('lbProvincia2').style.className = "";								
		}
	}
}
	
	
function LlamaPagoConCodigo(cod){
	location.href = 'FT_PagoConCodigo.asp?cod='+cod;
}

function MuestraTrailer(vISAN,Tipo){
	switch(Tipo){
		case 'F':
			location.href = 'FT_FichaPelicula.asp?Id='+vISAN+'&video=1';
			break;
		case 'P':
			location.href = 'FT_ProximosEstrenos.asp?Estreno='+vISAN+'&video=1#'+vISAN;
			break;
		case 'E':
			location.href = 'FT_EstrenosHistorico.asp?Estreno='+vISAN+'&video=1#'+vISAN;
			break;
	}
}

function MuestraTrailer_ORIGINAL(vISAN,sTitulo,RutaTrailer,MasInfo){
var Ventana;
	Ventana = window.open('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 LlamaLicencia (id_pedido, codigo_banco,url,idioma,IP)
{
	BrowserDetect.init();
	
	if (BrowserDetect.browser=='Explorer'){
		//window.open('../Tienda/fil_insertaFechaDescarga.aspx?idpedido='+id_pedido+'&codigo_banco='+codigo_banco+'&idioma='+idioma+'&IP='+IP+'&url='+url);
		window.open('FT_GestionaRegLicencia.asp?idpedido='+id_pedido+'&codigo_banco='+codigo_banco+'&idioma='+idioma+'&IP='+IP+'&url='+url);
	}else{
		alert("La descarga de liciencias está sólo disponible para Internet Explorer.")
	}
}

function LlamaLicenciaContenido (id_pedido, codigo_banco,url,idioma,IP)
{
	BrowserDetect.init();
	
	if (BrowserDetect.browser=='Explorer'){
		window.open('FT_GestionaRegLicencia.asp?blContenido=1&idpedido='+id_pedido+'&codigo_banco='+codigo_banco+'&idioma='+idioma+'&IP='+IP+'&url='+url);
	}else{
		alert("La descarga de liciencias está sólo disponible para Internet Explorer.")
	}
}

function MuestraDIVPorId(Id,TamPag)
{
	var i;
	for(i=1;i<=TamPag;i++){
		document.getElementById('Obra'+i).style.display='none';
	}
	document.getElementById('Obra'+Id).style.display='';
}


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 replace(texto,s1,s2){
	return texto.split(s1).join(s2);
}


function AbreFoto(sFoto,sPie){
var Ventana;
	Ventana = window.open('FT_Foto.asp?Img='+sFoto+'&Pie='+sPie,'Foto','width=450,height=438,Left=350,Top=300,Scrollbars=1,resizable=0,Toolbar=0,statusbar=0,Menubar=0,Location=0');
}

function ActivaCamposStream(campo){
	if (campo.value.length > 0){
		document.all.btn400d.style.display='none';
		document.all.btn700d.style.display='none';
		document.all.btnon.style.display='';
	}
}

function AddContenidoGratuito(ISAN,IdUsuario){
	if (IdUsuario != 0){
		//USUARIO REGISTRADO
		location.href='FT_InsertaContenidoGratuito.asp?ISAN='+ISAN+'&idUsuario='+IdUsuario;
	}
	else
	{
		// USUARIO SIN REGISTRAR
		document.getElementById('DivNoRegistrado').style.display='';
	}
}

function CompruebaPeliculasProvincia(CodProvincia,CodigosProvinciaConPelicula){
	if (CodigosProvinciaConPelicula.indexOf(CodProvincia) == -1){
		alert('No se encontraron estrenos en esta provincia');
	}else{
		location.href='FT_Cartelera.asp?Provincia='+CodProvincia;
	}
}

// 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,Nombre,Opciones);
	Ventana.focus();
}

	function TamVentana() {
	    var x, y;
	    if (self.innerHeight) { // MOS
	        y = self.innerHeight;
	        x = self.innerWidth - 21;
	    } else if (document.documentElement && document.documentElement.clientWidth) { // IE6 Strict
	        x = document.documentElement.clientWidth;
	        y = document.documentElement.clientHeight;
	    } else if (document.body.clientHeight) { // IE quirks
	        y = document.body.clientHeight;
	        x = document.body.clientWidth;
	    }
 	    return {x: x, y: y};
	}



/*
pScroll			Nombre del div que contiene el texto.
pEstado			Nombre del campo hidden que sentido del movimiento.
pMovimiento		Tipo de movimiento.
hContenedor		Altura en pixels del div que contiene al texto.
hContenedor		Ancho en pixels del div que contiene al texto.
PixelsMov		Cuantos pixeles se desplaza el texto.
TiempoMov		Tiempo en milisegundos hasta que vuelve a moverse el texto.
*/

function InicializaScroll(pScroll,pTipoMov,pMovimiento){
	if(pTipoMov=='h'||pTipoMov=='H'){
		document.getElementById(pScroll).style.left = pMovimiento;
	}else{
		document.getElementById(pScroll).style.top = pMovimiento;
	}
}

function ActivaScroll(pScroll,pMovimiento,hContenedor,wContenedor,PixelsMov,FlechaA,FlechaB){
	if(pMovimiento=='h'||pMovimiento=='H'){
		EstadoFlecha(document.getElementById(FlechaA),'../images/FIzquierda',1,document.getElementById(FlechaB),'../images/FDerecha','default',pScroll,pMovimiento,hContenedor,wContenedor,PixelsMov);
		EstadoFlecha(document.getElementById(FlechaB),'../images/FDerecha',2,document.getElementById(FlechaA),'../images/FIzquierda','default',pScroll,pMovimiento,hContenedor,wContenedor,PixelsMov);
	}else{
		EstadoFlecha(document.getElementById(FlechaA),'../images/FArriba',1,document.getElementById(FlechaB),'../images/FAbajo','default',pScroll,pMovimiento,hContenedor,wContenedor,PixelsMov);
		EstadoFlecha(document.getElementById(FlechaB),'../images/FAbajo',2,document.getElementById(FlechaA),'../images/FArriba','default',pScroll,pMovimiento,hContenedor,wContenedor,PixelsMov);
	}
}


/*------------------------------------------------------------------------------------------*/
/*	pFlechaA:		Indica cual es la imagen a la que se le asignará una nueva src.			*/
/*	pScrA:			Indica cual es la src por defecto de la imagen.							*/
/*	nFlecha:		Indica cual es el tipo de la FlechaA (1{up | left}; 2{down | right})	*/
/*	pFlechaB:		Indica cual es la imagen opuesta.										*/
/*	pScrA:			Indica cual es la src por defecto de la imagen opuesta.					*/
/*	pEstadoF:		Indica cual es el estado de la flecha pFlechaA (over, out, etc).		*/
/*	pScroll:		Indica cual es el Scroll a tener en cuenta al elegir la src.			*/
/*	pMovimiento:	Indica cual es el tipo de movimiento del Scroll.						*/
/*	hContenedor:	Indica cual es la altura del Contenedor del Scroll.						*/
/*	wContenedor:	Indica cual es el ancho del Contenedor del Scroll.						*/
/*------------------------------------------------------------------------------------------*/
function EstadoFlecha(pFlechaA,pSrcA,nFlecha,pFlechaB,pSrcB,pEstadoF,pScroll,pMovimiento,hContenedor,wContenedor,PixelsMov){
var Posicion;
var AnchoScroll;
var AltoScroll;
	AnchoScroll = document.getElementById(pScroll).offsetWidth + 70;
	AltoScroll = document.getElementById(pScroll).offsetHeight + 10;
	
	if(pMovimiento=='h'||pMovimiento=='H'){
		if(document.getElementById(pScroll).offsetWidth <= wContenedor){
		// El ancho del Scroll es menor que el del Contenedor, por lo que las flechas aparecerán deshabilitadas.
			pFlechaA.src = pSrcA + '_d.jpg'
			pFlechaA.style.cursor = 'default';
			pFlechaB.src = pSrcB + '_d.jpg'
			pFlechaB.style.cursor = 'default';
			return(false);
		}else{
		// Compruebo la posición del Scroll y la Flecha.
			Posicion = document.getElementById(pScroll).style.left;
		}
	}else{
		if(document.getElementById(pScroll).offsetHeight <= hContenedor){
		// El alto del Scroll es menor que el del Contenedor, por lo que las flechas aparecerán deshabilitadas.
			pFlechaA.src = pSrcA + '_d.jpg'
			pFlechaA.style.cursor = 'default';
			pFlechaB.src = pSrcB + '_d.jpg'
			pFlechaB.style.cursor = 'default';
			return(false);
		}else{
		// Compruebo la posición del Scroll y la Flecha.
			Posicion = document.getElementById(pScroll).style.top;
		}
	}

	Posicion = Posicion.replace(/px/,"");
	Posicion = Posicion.replace(/pt/,"");
	Posicion = new Number(Posicion);

	var Aux = pFlechaA.src;
	switch(pEstadoF){
	case 'Over':
	// El cursor está encima de la flecha. Pasa a estado ON si no está en estado D
		if(Aux.substring(Aux.lastIndexOf('/')+1) != (pSrcA.substring(pSrcA.lastIndexOf('/')+1) + '_d.jpg')){
			pFlechaA.src = pSrcA + '_on.jpg';
			pFlechaA.style.cursor = 'pointer';
		}else{
			pFlechaA.src = pSrcA + '_d.jpg'
			pFlechaA.style.cursor = 'default';
		}
		break;
	case 'Out':
	// El cursor ha salido de la flecha. Pasa a estado OFF si no está en estado D
		if(Aux.substring(Aux.lastIndexOf('/')+1) != pSrcA.substring(pSrcA.lastIndexOf('/')+1) + '_d.jpg'){
			pFlechaA.src = pSrcA + '.jpg';
			pFlechaA.style.cursor = 'pointer';
		}else{
			pFlechaA.src = pSrcA + '_d.jpg'
			pFlechaA.style.cursor = 'default';
		}
		break;
	default:
	// Estado por Defecto de la Flecha. Depende del tipo de flecha
		if(nFlecha==1){
			if(Posicion >= 0){
				pFlechaA.src = pSrcA + '_d.jpg'
				pFlechaA.style.cursor = 'default';
			}else{
				pFlechaA.src = pSrcA + '.jpg';
				pFlechaA.style.cursor = 'pointer';
			}
		}else{
			if(pMovimiento=='h'||pMovimiento=='H'){
				if((Posicion - PixelsMov) <= (-1*(AnchoScroll - wContenedor))){
					pFlechaA.src = pSrcA + '_d.jpg'
					pFlechaA.style.cursor = 'default';
				}else{
					pFlechaA.src = pSrcA + '.jpg';
					pFlechaA.style.cursor = 'pointer';
				}
			}else{
				if((Posicion - PixelsMov) <= (-1*(AltoScroll - hContenedor))){
					pFlechaA.src = pSrcA + '_d.jpg'
					pFlechaA.style.cursor = 'default';
				}else{
					pFlechaA.src = pSrcA + '.jpg';
					pFlechaA.style.cursor = 'pointer';
				}
			}
		}
		break;
	}
}

function MueveScroll(pScroll,pEstado,pMovimiento,hContenedor,wContenedor,PixelsMov,TiempoMov,FlechaA,FlechaB){
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(pMovimiento=='h'||pMovimiento=='H'){
		EstadoFlecha(document.getElementById(FlechaA),'../images/FIzquierda',1,document.getElementById(FlechaB),'../images/FDerecha','default',pScroll,pMovimiento,hContenedor,wContenedor,PixelsMov);
		EstadoFlecha(document.getElementById(FlechaB),'../images/FDerecha',2,document.getElementById(FlechaA),'../images/FIzquierda','default',pScroll,pMovimiento,hContenedor,wContenedor,PixelsMov);
	}else{
		EstadoFlecha(document.getElementById(FlechaA),'../images/FArriba',1,document.getElementById(FlechaB),'../images/FAbajo','default',pScroll,pMovimiento,hContenedor,wContenedor,PixelsMov);
		EstadoFlecha(document.getElementById(FlechaB),'../images/FAbajo',2,document.getElementById(FlechaA),'../images/FArriba','default',pScroll,pMovimiento,hContenedor,wContenedor,PixelsMov);
	}

	if(bMover){
		Tiempo = window.setTimeout('MueveScroll("'+pScroll+'","'+pEstado+'","'+pMovimiento+'",'+hContenedor+','+wContenedor+','+PixelsMov+','+TiempoMov+',"'+FlechaA+'","'+FlechaB+'")',TiempoMov)
	}else{
		return false
	}

}

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 DeshabilitaFondo(){
	document.getElementById('Fondo').style.display = '';
}

function HabilitaFondo(){
	document.getElementById('Fondo').style.display = 'none';
}


function CargarFondo(){
var Ancho, Alto

	Ancho = TamVentana().x;
	Alto = TamVentana().y;

	document.getElementById('Fondo').style.width = Ancho + 'px';
	document.getElementById('Fondo').style.height =	'100%';
	document.getElementById('ImgFondo').style.width = Ancho + 'px';
	document.getElementById('ImgFondo').style.height =	'100%';
}

function CadenaSegura(pCadena){
	if(/^([a-zA-Z0-9_]{6,30})+$/.test(pCadena)){
		return true;
	}else{
		return false;
	}

// Antigua función (no funciona correctamente)
//	var RegExPattern = /([a-zA-Z0-9])$/;
//	if (cadena.match(RegExPattern)){
//		return true;
//	}else{
//		return false;
//	}
}


//***************************************************************************************//
//  Valida una fecha. El valor de la fecha se le puede pasar directamente (pFecha) con   //
//  formato "dd/mm/aaaa", o el día, el mes y el ańo por separado (pDia, pMes y pAnio).   //
//***************************************************************************************//
function ValidarFecha(pDia,pMes,pAnio,pFecha){
var Aux;
var Dia, Mes, Anio;

	if(pFecha != ''){
		Aux = pFecha.split('/');
		Dia		= Aux(0);
		Mes		= Aux(1);
		Anio	= Aux(2);
	}else{
		Dia		= pDia;
		Mes		= pMes;
		Anio	= pAnio;
	}

	if(Anio > 1700){
		if(Mes == 1 || Mes == 3 || Mes == 5 || Mes == 7 || Mes == 8 || Mes == 10 || Mes == 12){
			if(Dia < 1 || Dia > 31){
				return(false); //Fecha Erronea
			}
		}else{
			if(Mes == 4 || Mes == 6 || Mes == 9 || Mes == 11){
				if(Dia < 1 || Dia > 30){
					return(false); //Fecha Erronea
				}
			}else{
				if(Mes == 2){
					if(((Anio%4 == 0) && (Anio%100 != 0)) || (Anio%400 == 0)){
						if(Dia < 1 || Dia > 29){
							return(false); //Fecha Erronea
						}
					}else{
						if(Dia < 1 || Dia > 28){
							return(false); //Fecha Erronea
						}
					}
				}else{
					return(false); //Fecha Erronea
				}
			}
		}
	}else{
		return(false); //Fecha Erronea
	}

	return(true); //Fecha Válida
}

// Verifica si pEmail es una direccion de email válida
function ValidaEmail(pEmail){
	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(pEmail)){
		return true;
	}else{
		return false;
	}
}


function BRapida(pForm,pTexto,pTipo){
	document.getElementById('txtBRapida').value = pTexto;
	document.getElementById('ddlBRapida').value = pTipo;
//	document.getElementById('ddlBRapida')(pTipo).selected = true;
	document.getElementById(pForm).submit();	
}

function Buscar(pTexto,pTipo){
	document.getElementById('txtBRapida').value = pTexto;
	document.getElementById('ddlBRapida').value = pTipo;
	document.getElementById('BMenu').submit();	
}

function GestPrecio(Precio){
    document.getElementById('FPINFOf2').innerText = Precio;
}

function trim (myString)
{
	return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
}


function ValidaCodigo(ISAN, Codigo, Calidad) {
    //alert(Codigo.indexOf('TP'));
    location.href = 'FX_StreamF.asp?ISAN=ISAN&V=' + Calidad + '&Val=' + Codigo;
}

function LlamaTarifaPlana(calidad) {
    AbrirVentana('FX_StreamTP.asp?ISAN=<%=vISAN%>&V=' + calidad + 'K', 'Visionado', 595, 570, 0, 0, 0, 0, 0, 0, 0, 0);
}
