function FNenviarVar(peli,variable,args){
//   var sendText = args.value;
//	alert(args +" _ "+peli+" _ "+variable);
   eval("window.document."+peli).SetVariable(variable.toString(), args);
   
}

function FNpopup(p_url,p_id,p_ancho,p_alto,p_carac){
	car="width="+p_ancho+",height="+p_alto+",left="+((screen.width/2)-(parseInt(p_ancho)/2))+",top="+((screen.height/2)-(parseInt(p_alto)/2))+","+p_carac
	window.open(p_url,p_id,car)
}

function FNtd_OnRollOver(_this,p_col){
	document.getElementById(_this).bgColor=p_col
}

function FNtd_onRollOut(_this,p_col){
	document.getElementById(_this).bgColor=p_col
}

function FNconmutar_flechas(){
	if(vPos==a_fotos.length-1 && v_url_sig==""){
		document.images.imgavv.src="img/tri_rj_avv_off.gif"
	}else{
		document.images.imgavv.src="img/tri_rj_avv.gif"
	}
	if(vPos==0 && v_url_ant==""){
		document.images.imgdrr.src="img/tri_rj_drr_off.gif"
	}else{
		document.images.imgdrr.src="img/tri_rj_drr.gif"
	}
}

function FNfiltrar_imagen(p_vPos){
	vPos=parseInt(p_vPos)
	FNcargarImagen(unescape(a_fotos[vPos].objeto),unescape(a_fotos[vPos].ancho),unescape(a_fotos[vPos].alto),unescape(a_fotos[vPos].descripcion),undefined,unescape(a_fotos[vPos].obj_panoramica),a_fotos[vPos].nCodImagen,a_fotos[vPos].nAmpliacion,a_fotos[vPos].cUrlCompra)
	FNconmutar_flechas()
}


function FNvis_foto(p_accion){
	vPos+=(p_accion)
	if(p_accion){
		if(vPos>=0 && vPos<a_fotos.length){
			FNfiltrar_imagen(vPos)
		}else{
			if(vPos>(a_fotos.length-1)){
				if(v_url_sig!=""){
					window.location=v_url_sig
		
				}
				vPos=(a_fotos.length-1)
			}else{
				if(v_url_ant!=""){
					window.location=v_url_ant+"&nInd=1"
				}
				vPos=0
			}
		}
	}
}

function FNcargarImagen(p_obj,p_ancho,p_alto,p_descrip,p_fila,p_pan,p_nCodImagen,p_nAmpliacion,p_cUrlCompra){
	if(p_pan==""){
		if(p_nAmpliacion==1){
			v_ancho=998
		}else{
			v_ancho=614
		}
		v_html='<a href="coment.php?nCodImg='+p_nCodImagen+'" target="_blank"><img src="'+p_obj+'" width="'+p_ancho+'" height="'+p_alto+'" border="0" alt=""></a>'
		v_salida_html=v_html
	}else{
		v_ancho=998
		v_swf=''
		v_swf+='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,14,0" width="481" height="385">'
		v_swf+='            <param name="movie" value="swf/gfx_gal.swf">'
		v_swf+='            <param name="quality" value="high">'
		v_swf+='			<param name="FlashVars" value="p_img='+escape(p_pan)+'&p_nCodImg='+p_nCodImagen+'">'
		v_swf+='            <embed src="swf/gfx_gal.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="481" height="385" flashvars="p_img='+escape(p_pan)+'&p_nCodImg='+p_nCodImagen+'"></embed>'
		v_swf+='</object>'
		v_salida_html=v_swf
	}
	
	obj_cont.innerHTML = v_salida_html;
	//Control de url
	/*
	if(p_cUrlCompra==""){
		cUrlCompra='<img src="img/galeria/comprar_off.gif" width="124" height="12" hspace="4" alt="No disponible">';
	}else{
		cUrlCompra='<a href="redir.php?cUrl='+escape(p_cUrlCompra)+'" target="_blank"><img src="img/galeria/comprar_on.gif" width="124" height="12" hspace="4" border="0" alt="Decora con esta fotografía">';
	}
	//--
	v_ver_comentarios='<br><span class="base"><img src="img/spacer.gif" width="100%" height="7"><a href=javascript:FNpopup("coment.php?nCodImg='+p_nCodImagen+'","v'+p_nCodImagen+'",'+v_ancho+',700,"toolbars=false,status=yes,scrollbars=yes") class="link11RJ"><img src="img/galeria/detalles_on.gif" hspace="4" border="0"></a>'+cUrlCompra+'</span>'
	*/
	if(p_cUrlCompra=="" || p_cUrlCompra=="-1"){
		cUrlCompra='<span class="parrArial11GR">comprar reproducción</span>';
	}else{
		cUrlCompra='<a href="redir.php?cUrl='+escape(p_cUrlCompra)+'&nCodImg='+p_nCodImagen+'" target="_blank" class="link11RJ">comprar reproducción</a>';
	}
	//--
	v_ver_comentarios='<br><span class="base"><img src="img/spacer.gif" width="100%" height="7">| <a href="coment.php?nCodImg='+p_nCodImagen+'" class="link11RJ" target="_blank">comentarios / ampliar</a> | '+cUrlCompra+' |</span>'
	obj_descipcion.innerHTML=unescape(p_descrip)+v_ver_comentarios
	
	if(p_fila!=undefined){vPos=parseInt(p_fila);FNvis_foto(0)}
	
	FNurl("acceso.php?nCodImg="+p_nCodImagen)
	FNurl("coment_gal.php?cAcc=1&nCodImg="+p_nCodImagen,"id_coment")
	document.forms["form_links"].action=v_url_actual+"&nCodImg="+p_nCodImagen
	
//	
}

function FNvalidar(formulario){
	form_ok=true
	msg=""
	n=0;while(formulario[n]){
		nombres_campo=formulario[n].name
		c_campo=eval("formulario."+nombres_campo)
		switch (nombres_campo){
			case "p_nombre":
					if(c_campo.value=="" || c_campo.value==" " || !isNaN(c_campo.value)){;form_ok=false;msg+="· 'Nombre'\n"}
					break;
			case "p_mensaje":
					if(c_campo.value=="" || c_campo.value==" " || !isNaN(c_campo.value)){;form_ok=false;msg+="· 'Mensaje'\n"}
					break;					
			case "p_comentario":
					if(c_campo.value=="" || c_campo.value==" " || !isNaN(c_campo.value)){;form_ok=false;msg+="· 'Comentario'\n"}
					break;					
			case "p_mail":
					if(c_campo.value!="" && c_campo.value.indexOf("@")==-1){;form_ok=false;msg+="· 'Correo ' (deje en blanco si no desea usar este campo)\n"}
					break;
			case "p_pais":
					if(c_campo.value!="" && !isNaN(c_campo.value)){;form_ok=false;msg+="· 'Pais' (deje en blanco si no desea enviar este dato)\n"}
					break;
			case "p_edad":
					if(c_campo.value!="" && isNaN(c_campo.value)){;form_ok=false;msg+="· 'Edad' (deje en blanco si no desea enviar este dato)\n"}
					break;
			case "p_como":
					if(c_campo.value!="" && !isNaN(c_campo.value)){;form_ok=false;msg+="· 'Como me encontraste' (deje en blanco si no desea enviar este dato)\n"}
					break;
			default:
		}
		n++
	}
	if(!form_ok){
		alert("Para utilizar este servicio debes rellenar correctamente los siguientes campos:\n\n"+msg)
		return false
	}else{
		return true
//		formulario.submit()
	}
//return (form_ok)
}

function FNvalidar_rec(formulario){
	form_ok=true
	msg=""
	n=0;while(formulario[n]){
		nombres_campo=formulario[n].name
		c_campo=eval("formulario."+nombres_campo)
		switch (nombres_campo){
			case "t_nombre_e":
					if(c_campo.value==""){;form_ok=false;msg+="· 'Tu nombre'\n"}
					break;
			case "t_mail_e":
					if(c_campo.value=="" || c_campo.value.indexOf("@")==-1){;form_ok=false;msg+="· 'Tu e-mail'\n"}
					break;
			case "t_nombre_r":
					if(c_campo.value==""){;form_ok=false;msg+="· 'Nombre del destinatario'\n"}
					break;
			case "t_mail_r":
					if(c_campo.value=="" || c_campo.value.indexOf("@")==-1){;form_ok=false;msg+="· 'E-mail del destinatario'\n"}
					break;
			default:
		}
		n++
	}
	if(!form_ok){
		alert("Para utilizar este servicio debes rellenar correctamente los siguientes campos:\n\n"+msg)
		return false
	}else{
		return true
	}
//return (form_ok)
}

function FNvalidar_contacto(formulario){
	form_ok=true
	msg=""
	n=0;while(formulario[n]){
		nombres_campo=formulario[n].name
		c_campo=eval("formulario."+nombres_campo)
		switch (nombres_campo){
			case "t_nombre_e":
					if(c_campo.value==""){;form_ok=false;msg+="· 'Nombre'\n"}
					break;
			case "t_mail_e":
					if(c_campo.value=="" || c_campo.value.indexOf("@")==-1){;form_ok=false;msg+="· 'E-mail'\n"}
					break;
			case "t_mensaje_e":
					if(c_campo.value==""){;form_ok=false;msg+="· 'Mensaje'\n"}
					break;
			default:
		}
		n++
	}
	if(!form_ok){
		alert("Para utilizar este servicio debes rellenar correctamente los siguientes campos:\n\n"+msg)
		return false
	}else{
		return true
	}
//return (form_ok)
}

function FNvalidar_links(formulario){
	form_ok=true
	msg=""
	n=0;while(formulario[n]){
		nombres_campo=formulario[n].name
		c_campo=eval("formulario."+nombres_campo)
		switch (nombres_campo){
			case "p_titulo":
					if(c_campo.value==""){;form_ok=false;msg+="· 'Título de la página'\n"}
					break;
			case "p_url":
					if(c_campo.value=="" || (c_campo.value.indexOf("http://")!=-1 && c_campo.value.length==7) ){;form_ok=false;msg+="· 'Dirección URL'\n"}
					break;
			case "p_descripcion":
					if(c_campo.value==""){;form_ok=false;msg+="· 'Descripción'\n"}
					break;
			default:
		}
		n++
	}
	if(!form_ok){
		alert("Para utilizar este servicio debes rellenar correctamente los siguientes campos:\n\n"+msg)
		return false
	}else{
		return true
	}
//return (form_ok)
}

// Control Clase de ejecución de archivos ShockWave Flash
// (c)2006 The Mad Pixel Factory --- http://www.madpixel.es

obj_swf=function(){
	this.salida_div=false
	this.trace=false
	this.codificarFlashVars=false
}
obj_swf.prototype.FNtrace=function(){
	this.trace=true
	return true
}
obj_swf.prototype.FNcodificarFlashVars=function(){
	this.codificarFlashVars=true
	return true
}
obj_swf.prototype.FNid_salida=function(p_id_salida){
	if(typeof(p_id_salida)!="undefined"){
		if(document.getElementById(p_id_salida)){
			this.salida_div=true
			this.obj_div=document.getElementById(p_id_salida)
		}
	}
}
obj_swf.prototype.FNborrar=function(){
	delete this
}
obj_swf.prototype.FNgfx_swf=function(){
	//Comprueba parametros básicos
	if(typeof(this.classid)=='undefined'){this.classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'}
	if(typeof(this.codebase)=='undefined'){this.codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0'}
	if(typeof(this.quality)=='undefined'){this.quality='high'}
	if(typeof(this.type)=='undefined'){this.type='application/x-shockwave-flash'}
	if(typeof(this.pluginspage)=='undefined'){this.pluginspage='http://www.macromedia.com/go/getflashplayer'}
	if(typeof(this.id)=='undefined'){var nId=Math.round(Math.random()*100);this.id='swf'+nId}
	//--
	
	//Crea arrays de contenido
	this.a_object_propios=new Array()
	this.a_comunes=new Array()
	this.a_object_variables=new Array()
	this.a_embed_propios=new Array()
	this.a_embed_variables=new Array()
	//--
	
	//Revisa contenido adquirido
	for(parametros in this){
		var cNomParametro=parametros.toLowerCase()
		var cValorParametro=eval("this."+parametros)
		if(typeof(cValorParametro)=="string"){
			switch (cNomParametro){
				case "classid":
				case "codebase":
				case "onafterupdate":
				case "onbeforeupdate":
				case "onblur":
				case "oncellchange":
				case "onclick":
				case "ondblClick":
				case "ondrag":
				case "ondragend":
				case "ondragenter":
				case "ondragleave":
				case "ondragover":
				case "ondrop":
				case "onfinish":
				case "onfocus":
				case "onhelp":
				case "onmousedown":
				case "onmouseup":
				case "onmouseover":
				case "onmousemove":
				case "onmouseout":
				case "onkeypress":
				case "onkeydown":
				case "onkeyup":
				case "onload":
				case "onlosecapture":
				case "onpropertychange":
				case "onreadystatechange":
				case "onrowsdelete":
				case "onrowenter":
				case "onrowexit":
				case "onrowsinserted":
				case "onstart":
				case "onscroll":
				case "onbeforeeditfocus":
				case "onactivate":
				case "onbeforedeactivate":
				case "ondeactivate":
				case "type":
					this.a_object_propios.push( cNomParametro+'="'+cValorParametro+'"' )
					break;
				case "width":
				case "height":
				case "align":
					this.a_comunes.push( cNomParametro+'="'+cValorParametro+'"' )
					break;
				case "type":
				case "pluginspage":
				case "allowscriptaccess":
				case "width":
				case "height":
				case "align":
				case "vspace": 
				case "hspace":
				case "class":
				case "accesskey":
				case "tabindex":
					this.a_embed_propios.push( cNomParametro+'="'+cValorParametro+'"' )
					break;
				case "id":
					this.a_object_propios.push( cNomParametro+'="'+cValorParametro+'"' )
					this.a_embed_propios.push('name'+'="'+cValorParametro+'"' )
					break;
				case "movie":
					this.a_object_variables.push( '<param name="'+cNomParametro+'" value="'+cValorParametro+'" />' )
					this.a_embed_propios.push('src'+'="'+cValorParametro+'"' )
					break;
				case "flashvars":
					//Revision el contenido de FlashVars para evitar problemas de comillas y caracteres especiales
					if(cValorParametro.indexOf('"')!=-1 || cValorParametro.indexOf("'")!=-1 || this.codificarFlashVars){
						cValorParametro=escape(cValorParametro)
					}
					this.a_object_variables.push( '<param name="'+cNomParametro+'" value="'+cValorParametro+'" />' )
					this.a_embed_variables.push( cNomParametro+'="'+cValorParametro+'"' )
					//--
					break;
				default :
					this.a_object_variables.push( '<param name="'+cNomParametro+'" value="'+cValorParametro+'" />' )
					this.a_embed_variables.push( cNomParametro+'="'+cValorParametro+'"' )
					break;
	
			}
		}
	}
	//--

	this.a_object_propios=this.a_object_propios.join(" ")
	this.a_comunes=this.a_comunes.join(" ")
	this.a_embed_propios=this.a_embed_propios.join(" ")
	this.a_object_variables=this.a_object_variables.join("\n")
	this.a_embed_variables=this.a_embed_variables.join(" ")

	//Genera salida
	cad=''
	cad+=('<object '+this.a_object_propios+' '+this.a_comunes+' >'+'\n')
	cad+=(''+this.a_object_variables +'\n')
	cad+=('<embed '+this.a_embed_propios+' '+this.a_comunes+' '+this.a_embed_variables+'></embed>'+'\n')
	cad+=('</object>'+'\n')
	
	if(this.salida_div){
		this.obj_div.innerHTML=cad //Salida a etiqueta ID
	}else{
		document.write(cad) //Escritura directa sobre HTML
	}
	//--
	
	if(this.trace){alert(cad)}
	
}

function FNurl(url,target) {
    // native XMLHttpRequest object
	if(target){
//    document.getElementById(target).innerHTML = '-- cargando comentarios --';
	}
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
		if(target){
			req.onreadystatechange = function() {jahDone(target);};
		}
        req.open("GET", url, true);
        req.send(null);
    // IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
		if(target){
			req.onreadystatechange = function() {jahDone(target);};
		}
            req.open("GET", url, true);
            req.send();
        }
    }
}    

function jahDone(target) {
		// only if req is "loaded"
	if (req.readyState == 4) {
		// only if "OK"
		if (req.status == 200) {
			results = req.responseText;
			document.getElementById(target).innerHTML = results;
		} else {
			document.getElementById(target).innerHTML="jah error: " + req.statusText;
		}
	}
}

