// JavaScript Document

// Esta altura es para las páginas de contenido con imagen de fondo
alturaContenidosFondo="330";


//Ajuste de tamaño de Iframe
function adjustIFrameSize(){
var oBody= testiframe.document.body;    
    
    navegador=navigator.userAgent;    
    esIE=navegador.indexOf("MSIE");
    
    if(esIE > -1) 
    {
     oFrame= document.all("testiframe").style;
	 oFrame.height='1px';
	 oFrame.height = oBody.scrollHeight + (oBody.offsetHeight - oBody.clientHeight)+60;
	if (oBody.scrollHeight < 300)
	{
		oFrame.height = 300;
		
	}
 }
 else
 {
     oFrame= document.getElementById("testiframe").style;
     oFrame.height='1px';
     oFrame.height = oBody.offsetHeight+60+'px';
     
     document.getElementById("todo").style.top = '2%';
     document.getElementById("todo").style.marginTop = '0';
     
     if (oBody.scrollHeight < 300)
	{
		oFrame.height = '350px';
	}
 }
 parent.scrollTo(1,1);


}


// Ajusta el tamaño de Iframe sólo para vacio.html y aquellas páginas que tengan imagen de fondo
function adjustIFrameSizeFixed(size){
    var oBody= testiframe.document.body;    
    
    navegador=navigator.userAgent;    
    esIE=navegador.indexOf("MSIE");
    
    if(esIE > -1) 
    {
        oFrame= document.all("testiframe").style;
        oFrame.height='1px';
        // Si no se especifica tamaño es vacio.html, posiciono en el centro al 50%
        if (size==undefined) {
            document.getElementById("todo").style.top = '50%';
            document.getElementById("todo").style.marginTop = '-290';
            document.getElementById("todo").style.marginLeft = '-360';                
        } else {
            oFrame.height = alturaContenidosFondo;
        }
    }
    else
    {
		
        oFrame= document.getElementById("testiframe").style;
        oFrame.height = '1px';    		
				
        if (size!=undefined) {
            oFrame.height = alturaContenidosFondo+'px';
	    if (document.getElementById("todo") != undefined){
		    document.getElementById("todo").style.top = '2%';
		    document.getElementById("todo").style.marginTop = '0';
	   }
        } else {
		document.getElementById("todo").style.top = '50%';
		document.getElementById("todo").style.marginTop = '-300px';
		document.getElementById("todo").style.marginLeft = '-360px';                 
	}        
    }     
    parent.scrollTo(1,1);           
}


function getFlashPluginVersion() 
{ 
      var version = { 
            major: -1, 
            minor: -1, 
            installed: false,
            scriptable: false,
            machoArchitectureProblem: false
          };
  
      var osxFlashVersion = 12;          

      // Se le hace la pregunta sin el .enabledPlugin para que no genere error si no está instalado
        var plugin = navigator.mimeTypes["application/x-shockwave-flash"];
            
      if (!plugin) 
      {
        return version;
      }      

      // Ahora si se usa el .enabledPlugin puesto que está instalado y no da error
        var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin; 

      version.installed = true;
    
      var description = plugin.description; 
      
      
      // use RegExp to obtain the relevant version strings 
      // obtain an array of size 2 with version information
      
      var versionArray = description.match(/[\d.]+/g); 
      
      
      if (!versionArray)
      {
        return version;
      }
    
      if (versionArray.length >= 1 && !isNaN(versionArray[0]))
      {
        version.major = parseFloat(versionArray[0]);
      }
    
      if (versionArray.length >= 2 && !isNaN(versionArray[1]))
      {
        version.minor = parseFloat(versionArray[1]);
      }
        
      //if (version.major < 6 || navigator.product != 'Gecko')
	  if (version.major < 6 || (navigator.product != null && navigator.product != 'Gecko'))
      {
        return version;
      }
    
      if (version.major > 6 || version.minor >= 47)
      {
        version.scriptable = true;
      }
      
      if((version.major < osxFlashVersion) && (navigator.userAgent.indexOf("Mach-O") != -1))
      {
        version.scriptable = false;
        version.machoArchitectureProblem = true;
      
      }
    
      return version;
}





function getFlashPluginVersion_() 
{ 
  var version = { 
        major: -1, 
        minor: -1, 
        installed: false,
        scriptable: false,
        machoArchitectureProblem: false
      };
var osxFlashVersion = 12;

  var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin; 
  if (!plugin) 
  {    
    return version;
  }

  version.installed = true;

  var description = plugin.description; 
  
  // use RegExp to obtain the relevant version strings 
  // obtain an array of size 2 with version information
  
  var versionArray = description.match(/[\d.]+/g); 
  
  if (!versionArray)
  {
    return version;
  }

  if (versionArray.length >= 1 && !isNaN(versionArray[0]))
  {
    version.major = parseFloat(versionArray[0]);
  }

  if (versionArray.length >= 2 && !isNaN(versionArray[1]))
  {
    version.minor = parseFloat(versionArray[1]);
  }
    
  if (version.major < 6 || navigator.product != 'Gecko')
  {
    return version;
  }

  if (version.major > 6 || version.minor >= 47)
  {
    version.scriptable = true;
  }
  
  if((version.major < osxFlashVersion) && (navigator.userAgent.indexOf("Mach-O") != -1))
  {
  	version.scriptable = false;
  	version.machoArchitectureProblem = true;
  
  }

  return version;
}




//Crear SWF 
function create(vruta,vsec,vidi)
{
	
	if ((window.ActiveXObject) && 
		  (navigator.userAgent.indexOf("MSIE")!= -1) && (navigator.userAgent.indexOf("Windows") != -1))
		{
      if (vsec != ""){
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
		document.write(' width="720" height="100%" id="flashMov1" align="top">');
		document.write(' <param name="movie" value="' + vruta + '/swf/cabecera.swf?datosHome=http://www.murciaturistica.es/' + vidi + '&idSelect=' + vsec + '">');
		document.write(' <param name=quality value=high>');
		document.write(' <param name=menu value=false>');
		document.write(' <param name="scale" value="noscale">');
		document.write(' <param name="swliveconnect" value="true">');
		document.write(' <param name="bgcolor" value="#ffffff" >');
		document.write(' <param name="salign" value="lt">');
		document.write('<' + '/object>');
}else{
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
		document.write(' width="720" height="100%" id="flashMov1" align="top">');
		document.write(' <param name="movie" value="' + vruta + '/swf/cabecera.swf?datosHome=http://www.murciaturistica.es/' + vidi + '">');
		document.write(' <param name=quality value=high>');
		document.write(' <param name=menu value=false>');
		document.write(' <param name="scale" value="noscale">');
		document.write(' <param name="swliveconnect" value="true">');
		document.write(' <param name="bgcolor" value="#ffffff" >');
		document.write(' <param name="salign" value="lt">');
		document.write('<' + '/object>');
}
		}
	else
		{
		var version_check = getFlashPluginVersion();
		if (version_check.scriptable)
			{
			document.write('<object id="flashMov1" data="' + vruta + '/swf/cabecera.swf?datosHome=http://www.murciaturistica.es/' + vidi + '&idSelect=' + vsec + '" type="application/x-shockwave-flash"');

			document.write(' width="720" height="100%" align="top">');
			document.write('<param name="movie" value="' + vruta + '/swf/cabecera.swf?datosHome=http://www.murciaturistica.es/' + vidi + '&idSelect=' + vsec + '" type="application/x-shockwave-flash">');
			document.write('<param name="quality" value="high">');
			document.write(' <param name="scale" value="noscale">');
			document.write(' <param name="salign" value="lt">');
			document.write(' <param name="bgcolor" value="#ffffff" >');
			document.write('<param name="swliveconnect" value="true">');    	
			document.write('<embed src="' + vruta + '/swf/cabecera.swf?datosHome=http://www.murciaturistica.es/' + vidi + '&idSelect=' + vsec + '" quality="high" scale="noscale" salign="lt" bgcolor="#ffffff" width="720" height="100%" name="cabecera" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">'); 

			document.write('<\/object>'); 
			}
	else
		cargaVersionInferiorFlash();
		}
		document.getElementById('flashid').style.visibility = 'visible';	
}



function reescala(newH,URLO){

	
if(URLO==undefined){}else{loadIframe(URLO);	}
	
	
	document.getElementById("flashid").style.height = newH + "px";
	
	
	

	
	document.getElementById("piePagina").style.height = 50 + "px";
	document.getElementById("piePagina").style.visibility = 'visible'	
	
	if ((window.ActiveXObject) && (navigator.userAgent.indexOf("MSIE")!= -1) && (navigator.userAgent.indexOf("Windows") != -1))	{
	
		document.getElementById("todo").style.top = '0%';
		document.getElementById("todo").style.marginTop = '15';
		
		}else{
			
		document.getElementById("todo").style.top = '0%';
		document.getElementById("todo").style.marginTop = '0';
			
		}
	
//	document.getElementById('pie_pagina').style.visibility = 'hidden';		
	
	
	



	
	
	
}


function adaptaIframeVacc(){
	
	
	
	// SE encargará de ajustar el estilo del IFRAME correspondiente a la cabecera de la versión ACcesible
	
	if ((window.ActiveXObject) && (navigator.userAgent.indexOf("MSIE")!= -1) && (navigator.userAgent.indexOf("Windows") != -1))	{
	

		
		}else{
			

		}
	
	
	
	
	
}





//Carga de archivos en Iframe
function loadIframe(theURL){
  

  /*/*/// Solo para pruebas en local ////////////////
  /*ur=String(theURL);
  ejem=ur.lastIndexOf('?seccion=');
  carga=ur.slice(0,ejem)
  theURL=carga  */
  ////////////////////////////////////////////////
  
  top.document.getElementById("testiframe").src = theURL;
    //document.getElementById('pie_pagina').style.visibility = 'visible';
	
} 




function loadIframeVacc(theURL,imagen,textoalt){
	
	top.document.getElementById("testiframe").src = theURL;
	top.document.getElementById("vacc_cabecera_imagen").src = imagen;
	top.document.getElementById("vacc_cabecera_imagen").alt = textoalt;
	top.document.getElementById("vacc_cabecera_imagen").title = textoalt;
} 

function cambiaimg(imagen,imgcambio,imgorigen,hover){
	if(hover==1){
	
		for(i=0;i<document.images.length;i++){
			
			if(document.images[i].name===imagen){
				
				
				document.images[i].src=imgcambio
			}
		}
	}else{
		for(i=0;i<document.images.length;i++){
			
			if(document.images[i].name===imagen){
				
				
				document.images[i].src=imgorigen
			}
		}
	}
}

// función destinada a cargar id´s en el componente Flash. 

function idCabecera(ident){
 if (top.document.getElementById("flashMov1"))
 {	
  top.document.getElementById("flashMov1").SetVariable('idSelect',ident);	
 }
}



function carga_flash(fichero)
{

  if ((window.ActiveXObject) && (navigator.userAgent.indexOf("MSIE")!= -1) && (navigator.userAgent.indexOf("Windows") != -1))
  {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
		document.write(' width="720" height="100%" id="flashMov1" align="top">');
		document.write(' <param name="movie" value="' + fichero + '">');
		document.write(' <param name=quality value=high>');
		document.write(' <param name=menu value=false>');
		document.write(' <param name="scale" value="noscale">');
		document.write(' <param name="swliveconnect" value="true">');
		document.write(' <param name="bgcolor" value="#ffffff" >');
		document.write(' <param name="salign" value="lt">');
		document.write('<' + '/object>');
  }
  else
  {
		var version_check = getFlashPluginVersion();
		if (version_check.scriptable)
		{
			document.write('<object id="flashMov1" data="' + fichero + '" type="application/x-shockwave-flash"');
			document.write(' width="720" height="100%" align="top">');
			document.write('<param name="movie" value="' + fichero + '" type="application/x-shockwave-flash">');
			document.write('<param name="quality" value="high">');
			document.write(' <param name="scale" value="noscale">');
			document.write(' <param name="salign" value="lt">');
			document.write(' <param name="bgcolor" value="#ffffff" >');
			document.write('<param name="swliveconnect" value="true">');    	
			document.write('<embed src="' + fichero + '" quality="high" scale="noscale" salign="lt" bgcolor="#ffffff" width="720" height="100%" name="cabecera" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">'); 
			document.write('<\/object>'); 
		}
  	        else
 		  cargaVersionInferiorFlash();
  }

}


/* COMPROBADOR DE NAVEGADOR, VERSIÓN DE NAVEGADOR Y VERSIÓN DE FLASH */
/* ################################################################# */

function compruebaNavegador(vruta,vsec,vidi){
    // Se comprueban 3 navegadores, Internet explorer, Mozilla y Netscape
    // Las siguientes constantes contienen el número de versión mínima aceptable.
    // Por debajo de esa versión, carga la página html, si es esa versión o superior,
    // carga la versión flash
    minimoIE=5;
    minimoMozilla=1.0;
    minimoNetscape=8;
	minimoOpera=7.5;
    
    // Se usa la variable userAgent por ser la única que tiene la información completa para todos los navegadores
    navegador=navigator.userAgent;
    
    
    esFirefox=navegador.indexOf("Firefox");
    if (esFirefox > -1){
        version=navegador.substring(esFirefox+8,esFirefox+11);    
        if (parseFloat(version) >= minimoMozilla) {        
            compruebaFlash(vruta,vsec,vidi);
        } else {
            cargaVersionAccesible();            
        }
    } else{
		esOpera=navegador.indexOf("Opera");
		if(esOpera > -1) {		
			version=navegador.substring(esOpera+6,esOpera+11);   			
			if (parseFloat(version) >= minimoOpera) {        
				compruebaFlash(vruta,vsec,vidi);
			} else {
				cargaVersionAccesible();            
			}			
		} else {
        	esIE=navegador.indexOf("MSIE");
			if(esIE > -1) {
				version=navegador.substring(esIE+5,esIE+6);
				if (parseFloat(version) >= minimoIE) {
					compruebaActivacionFlashIE(vruta,vsec,vidi);
				} else {
					cargaVersionAccesible();
				}
			} else {
            	esNetscape=navegador.indexOf("Netscape");
				if(esNetscape > -1) {
					version=navegador.substring(esNetscape+9,esNetscape+10);
					if (parseFloat(version) >= minimoNetscape) {                    
						compruebaFlash(vruta,vsec,vidi);
					} else {
						cargaVersionAccesible();
					}
				} else {
					esSafari=navegador.indexOf("Safari");
					if(esSafari > -1) {
						compruebaFlash(vruta,vsec,vidi);			
					} else{	
						cargaVersionAccesible();			
					}
            	}
        	}
    	}
	}
}

function compruebaActivacionFlashIE(vruta,vsec,vidi){
    // Detección exclusiva para Internet explorer
    // Detecta si está activado o no el plug in de flash antes de
    // ver su versión.
    flashActivado=false;
    for (i=25;i>0;i--) {    
        versionStr = VBGetSwfVer(i);
        if (versionStr == -1 ) { 
            // No está instalado
            flashActivado=false;
        } else if (versionStr != 0) { 
            flashActivado=true;
        }
    }
    if (flashActivado) {
        compruebaFlash(vruta,vsec,vidi);            
    } else {
        cargaVersionInferiorFlash();
    }
    
}
 
function compruebaFlash(vruta,vsec,vidi){
 create(vruta,vsec,vidi);
}

function cargaVersionInferiorFlash(){
    window.open("http://www.murciaturistica.es/PORTAL-2006/html/version_inferior_flash.html","_self");
}


function cargaVersionAccesible(){
    window.open("http://www.murciaturistica.es/PORTAL/ptm.home.menu?idiacc=1S","_self");
}

/* END
/* COMPROBADOR DE NAVEGADOR, VERSIÓN DE NAVEGADOR Y VERSIÓN DE FLASH */
/* END
/* ################################################################# */

function incrusta_flash(fichero,ancho,alto)
{

  if ((window.ActiveXObject) && (navigator.userAgent.indexOf("MSIE")!= -1) && (navigator.userAgent.indexOf("Windows") != -1))
  {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
		document.write(' width="' + ancho + '" height="' + alto + '" id="flashMov1" align="top">');
		document.write(' <param name="movie" value="' + fichero + '">');
		document.write(' <param name=quality value=high>');
		document.write(' <param name=menu value=false>');
		document.write(' <param name="scale" value="noscale">');
		document.write(' <param name="swliveconnect" value="true">');
		document.write(' <param name="bgcolor" value="#ffffff" >');
		document.write(' <param name="salign" value="lt">');
		document.write('<' + '/object>');
  }
  else
  {
		var version_check = getFlashPluginVersion();
		if (version_check.scriptable)
		{
			document.write('<object id="flashMov1" data="' + fichero + '" type="application/x-shockwave-flash"');
			document.write(' width="' + ancho + '" height="' + alto + '" align="top">');
			document.write('<param name="movie" value="' + fichero + '" type="application/x-shockwave-flash">');
			document.write('<param name="quality" value="high">');
			document.write(' <param name="scale" value="noscale">');
			document.write(' <param name="salign" value="lt">');
			document.write(' <param name="bgcolor" value="#ffffff" >');
			document.write('<param name="swliveconnect" value="true">');    	
			document.write('<embed src="' + fichero + '" quality="high" scale="noscale" salign="lt" bgcolor="#ffffff" width="' + ancho + '" height="' + alto + '" name="fichero" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">'); 
			document.write('<\/object>'); 
		}
  	        else
 		  cargaVersionInferiorFlash();
  }

}


  var http_peticion = false;
  var http_capa = "";

  function hazPeticion(url,capa)
  {
    http_peticion = false;
    document.getElementById(capa).innerHTML='CARGANDO ...';

    if (window.XMLHttpRequest)
    { // Mozilla, Safari,...
      http_peticion = new XMLHttpRequest();
      if (http_peticion.overrideMimeType)
      {
        http_peticion.overrideMimeType('text/xml');
      }
    }
    else if (window.ActiveXObject)
    { // IE
      try
      {
        http_peticion = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (e)
      {
        try
        {
          http_peticion = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e) {}
      }
    }else{
      alert("Navegador no compatible.");
    }

    if (!http_peticion)
    {
      alert('No de puede crear una instancia XMLHTTP');
      return false;
    }
    http_capa = capa;
    http_peticion.onreadystatechange = muestraContenido;
    http_peticion.open('GET', url, true);
    http_peticion.send(null);
  }

  function muestraContenido()
  {
    if (http_peticion.readyState == 4)
    {
      if (http_peticion.status == 200)
      {
        document.getElementById(http_capa).innerHTML=http_peticion.responseText;
      }
      else
      {
        alert('Hay un problema en la petición.');
      }
    }
  }

  function r_municipios(valor,nombre,idi,clase,estilo,capa)
  {  
    hazPeticion("./ptm.procesos_generales.municipios?idi="+idi+"&nombre="+nombre+"&destino="+valor+"&clase="+clase+"&estilo="+estilo,capa);
  }

  function r_playas(valor,nombre,idi,clase,estilo,capa)
  {  
    hazPeticion("./ptm.procesos_generales.playas?idi="+idi+"&nombre="+nombre+"&destino="+valor+"&clase="+clase+"&estilo="+estilo,capa);
  }

  function r_tipos_cultura(valor,nombre,idi,clase,estilo,capa)
  {  
    hazPeticion("./ptm.procesos_generales.tipos_cultura?idi="+idi+"&nombre="+nombre+"&destino="+valor+"&clase="+clase+"&estilo="+estilo,capa);
  }

  function r_municipios_salud(valor,nombre,idi,clase,estilo,capa)
  {  
    hazPeticion("./ptm.procesos_generales.localidades_salud?idi="+idi+"&nombre="+nombre+"&tipo_salud="+valor+"&clase="+clase+"&estilo="+estilo,capa);
  }

  function r_tipos_alojamiento(valor,nombre,idi,clase,estilo,capa)
  {  
    hazPeticion("./ptm.procesos_generales.tipos_alojamiento?idi="+idi+"&nombre="+nombre+"&destino="+valor+"&clase="+clase+"&estilo="+estilo,capa);
  }

  function r_categorias(valor,nombre,idi,clase,estilo,capa)
  {  
    hazPeticion("./ptm.procesos_generales.categorias?idi="+idi+"&nombre="+nombre+"&catg="+valor+"&clase="+clase+"&estilo="+estilo,capa);
  }

  function redirecciona(valor)
  {
    alert(valor);
    alert('Esta opción requiere ser redireccionado a la sección que ha seleccionado.');
    window.location=+valor;
  }

