// Utilidades
pPan=0;
pTilt=0;

function AdecuarQTaVentana(pPanorama, pPan, pTilt, pFov)
{
  <!--
  width=screen.width;
  height=screen.height - 20;
  fov="75";
  // alert(width + " " +height);
  // alert(window.width + " - " +window.height);

  versionQT = getQuicktimeVersion();
  if (versionQT == null) alert("Your computer seems that has not installed QuickTime. Please follow the instructions if you like. Su ordenador aparentemente no dispone de QuickTime. Si lo desea siga las instrucciones para su instalación.");

  if (screen.width>1280)
  {
    swidth = 1280;
  }
  else
  {
    swidth = screen.width;
  }

  if (swidth==1280)
  {
    fov="75";
  }
  else if (swidth==1024)
  {
    fov="85";
  }
  else if (swidth==800)
  {
    fov="85";
  }
  if (pFov != null)  // Si se pide uno en concreto, ese es el que vale
  {
    fov=pFov;
  }
  //alert(fov);
 
  // Invocar QT
  document.write('<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" WIDTH="'+width+'"HEIGHT="'+height+'" ');
  document.write('CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab"> ');
  document.write('<PARAM name="SRC" VALUE="'+pPanorama+'"> ');
  document.write('<PARAM name="AUTOPLAY" VALUE="false"> ');
  document.write('<PARAM name="CACHE" VALUE="false"> ');
  document.write('<PARAM name="CONTROLLER" VALUE="false"> ');
  document.write('<PARAM name="SCALE" VALUE="tofit"> ');
  document.write('<PARAM name="FOV" VALUE="'+fov+'"> ');
  document.write('<PARAM name="PAN" VALUE="'+pPan+'"> ');
  document.write('<PARAM name="TILT" VALUE="'+pTilt+'"> ');
  document.write('<PARAM name="bgcolor" VALUE="#000000"> ');
  document.write('<embed src="'+pPanorama+'"type="video/quicktime" ');
  document.write('width="'+width+'" height="'+height+'" fov="'+fov+'" tilt="'+pTilt+'" pan="'+pPan+'" cache="false" ');
  document.write('controller="false" bgcolor="#000000" scale="tofit" PLUGINSPAGE="http://www.apple.com/quicktime/download/"></embed>'); 
  document.write('</OBJECT>');

  // Pié de página
  document.write('  <table width="100%" border="0"> ');
  document.write('    <tr> ');
  document.write('      <td> ');
  document.write('        <div align="left"><font style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; color:#FFFF00">Click and drag to move, and Shift and Ctrl Keys to zoom it. Haga ');
  document.write('          click y arrastre para mover la imagen y use las teclas Control y May para hacer zoom.</font></div> ');
  document.write('      </td> ');
  document.write('      <td> ');
  document.write('        <div align="right"><a href="javascript:VentanaCerrar()"><font style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; color:#FF9900"><BOLD>CLOSE/CERRAR</BOLD></font></a></div> ');
  document.write('      </td> ');
  document.write('  </table> ');


  //-->
}

function VentanaCerrar(pURL)
{
  window.close();
}

function abrirVentana(pURL, pAncho, pAlto, pPosX, pPosY)
{
	var PosX="100";
	var PosY="100";
	var Ancho="660";
	var Alto="400";
	var extras="resizable=yes, status=no, scrollbars=yes, status=no, titlebar=no, toolbar=no, menubar=no, location=no";

	if (pAncho != null) {
		Ancho=pAncho;
	}
	if (pAlto != null) {
		Alto=pAlto;
	}
	if (pPosX != null) {
		PosX=pPosX;
	}
	if (pPosY != null) {
		PosY=pPosY;
	}
	
	parametros="width="+Ancho+" ,height="+Alto+" ,left="+PosX+ " ,top="+PosY;
	parametros = parametros + ", "+ extras;
	if (debug) alert("Parametros abrirVentana "+parametros);
	window.open(pURL, null, parametros);
}

function Ventana(pURL)
{
	window.open(pURL,"",'scrollbars=yes,resizable=yes');
}

function VentanaFullScreen(pURL)
{
	window.open(pURL,"",'fullscreen=yes');
}


var quicktimeVersion = 0;
function getQuicktimeVersion() {
	var agent = navigator.userAgent.toLowerCase(); 
	
	// NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Quicktime plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
      for (i=0; i < navigator.plugins.length; i++ ) {
         var plugin =navigator.plugins[i];
         if (plugin.name.indexOf("QuickTime") > -1) {
            quicktimeVersion = parseFloat(plugin.name.substring(18));
         }
      }
	}
   
	// IE4+ Win32:  attempt to create an ActiveX object using VBScript
	else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
	  document.write('<scr' + 'ipt language="VBScript"\> \n');
		document.write('on error resume next \n');
		document.write('dim obQuicktime \n');
		document.write('set obQuicktime = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1") \n');
		document.write('if IsObject(obQuicktime) then \n');
		document.write('   if obQuicktime.IsQuickTimeAvailable(0) then \n');
		document.write('      quicktimeVersion = CInt(Hex(obQuicktime.QuickTimeVersion) / 1000000) \n');
		document.write('   end if \n');
		document.write('end if \n');
		document.write('</scr' + 'ipt\> \n');
  }

	// Can't detect in all other cases
	else {
		quicktimeVersion = quicktimeVersion_DONTKNOW;
	}

	return quicktimeVersion;
}

quicktimeVersion_DONTKNOW = -1;
