/////////// Esta sección es externa al portal ////////

window.status = "     "; //Porque IE se queda cargando la pagina todo el rato

// 
function SymError()
{
  return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
  return (new Object());
}

window.open = SymWinOpen;

//inicializador
function objects_initializer() {
	//descubre ie o nn
	if (navigator.appName == "Microsoft Internet Explorer")
		init_ie_objs();
	else
		if (navigator.appVersion.indexOf("4.") ==-1)
			init_dom_objs();
		else
			init_nn_objs();
	objsCreated = true;
}

//ie inicializador
function init_ie_objs() {
	objElements = document.all.tags("DIV");
	theObjs = new Array();
	for (i=0;i<objElements.length;i++) {
		if (objElements[i].id != "") {
			theObjs[objElements[i].id] = new W3CDOM_object(objElements[i]);
		}
	}
}

//NN4 inicializador
function init_nn_objs() {
	theObjs = new Array();
	for (i=0;i<document.layers.length;i++) {
		if (document.layers[i].name != "") {
			theObjs[document.layers[i].name] = new NN4_object(document.layers[i]);
		}
	}
}

//NN6 inicializador
function init_dom_objs() {
	objElements = document.getElementsByTagName("div");
	theObjs = new Array();
	for (i=0;i<objElements.length;i++) {
		var obj = objElements[i];
		if (obj.id != "") {
			theObjs[obj.id] = new W3CDOM_object(obj);
		}
	}
}

//* the following if statement was inserted to fix the NE v.6.1 & 6.2 bug *//
//* when you tried to open out site in browsers, the browser would shrink and couldn't be resized *//
//* this error would occur as long as the following objects were called outside the function *//
//* my fix hides the objects from NE v 6.0,6.1,6.2.*//
if (((navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)==4))||(navigator.appName=="Microsoft Internet Explorer")){
var innerWidth = new Object();
var innerHeight = new Object();

var pgW = new Object();
var pgH = new Object();
}
function nsResize(init) {
	if (init==true) with (navigator) {
		if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
			document.pgW=innerWidth; document.pgH=innerHeight; onResize=reloadPage; }
		}
		else if	(innerWidth!=document.pgW || innerHeight!=document.pgH) {
			location.reload();
		}
}
//nsResize(true);


/////////// Esta sección tiene relación directa con el portal ////////


// No editar debajo de esta línea
// ===========================
bV  = parseInt(navigator.appVersion)
bNS = navigator.appName=="Netscape"
bIE = navigator.appName=="Microsoft Internet Explorer"

function nrc(e) {
   if (bNS && e.which > 1){
      alert(am)
      return false
   } else if (bIE && (event.button >1)) {
     alert(am)
     return false;
   }
}

document.onmousedown = nrc;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (bNS && bV<5) window.onmousedown = nrc;

// Funciones para los estados del mouse OVER y OUT:
  function mOvr(src,clrOver) {
    if (!src.contains(event.fromElement)) {
	  src.style.cursor = 'hand';
	  src.bgColor = clrOver;
	}
  }
  function mOut(src,clrIn) {
	if (!src.contains(event.toElement)) {
	  src.style.cursor = 'default';
	  src.bgColor = clrIn;
	}
  }

function MM_reloadPage(init) {  //recarga la ventana si Nav4 se redimensiona
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->


// Funciones de rollover:
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


/// Funciones empleadas por secciones de Amarre ///


//Ayuda contextual

var enabletip=false;

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}



function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Averiguamos lo cerca que está el puntero del ratón de la esquina de la ventana
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip

//Emergencias:
function vuelta(){
ayudaWindow = window.open("vuelta.php","vuelta","scrollbars=no,width=245,height=180,"+pos);
}

function pulso(){
ayudaWindow = window.open("pulso.php","pulso","scrollbars=no,width=285,height=180,"+pos);
}

function gmdss1(){
ayudaWindow = window.open("gmdss1.php","gmdss1","scrollbars=no,width=497,height=440,"+pos);
}

function gmdss2(){
ayudaWindow = window.open("gmdss2.php","gmdss2","scrollbars=no,width=497,height=440,"+pos);
}

function gmdss3(){
ayudaWindow = window.open("gmdss3.php","gmdss3","scrollbars=no,width=497,height=440,"+pos);
}

function gmdss4(){
ayudaWindow = window.open("gmdss4.php","gmdss4","scrollbars=no,width=497,height=440,"+pos);
}

function pns(){
ayudaWindow = window.open("1.php","1","scrollbars=no,width=270,height=192,"+pos);
}

function consejos(){
ayudaWindow = window.open("consejos2.php","consejos2","scrollbars=no,width=358,height=253,"+pos);
}

function atlantico(){
ayudaWindow = window.open("atlantico.php","atlantico","scrollbars=no,width=468,height=550,"+pos);
}

function mediterraneo(){
ayudaWindow = window.open("mediterraneo.php","mediterraneo","scrollbars=no,width=499,height=333,"+pos);
}


//Escuela. Conversor Morse


function translate(form) {
letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .,?:-!";
morse = new Array(
".-","-...","-.-.","-..",".","..-.",
"--.","....","..",".---","-.-",".-..",
"--","-.","---",".--.","--.-",".-.",
"...","-","..-","...-",".--","-..-",
"-.--","--..",".-","-...","-.-.","-..",
".","..-.","--.","....","..",".---",
"-.-",".-..","--","-.","---",".--.",
"--.-",".-.","...","-","..-","...-",
".--","-..-","-.--","--.."," ",".-.-.-",
"--..--","..--..","---...","-....-","!");

form.output.value = "";
var input = form.input.value;
output = "";
for(count = 0; count < input.length; count++) {
daChar = input.charAt(count);
for (i = 0; i < letters.length; i++) {
if (daChar == letters.charAt(i)) {
output += morse[i];
break;
      }
   }
}
form.output.value = output;
}



//Meteorología:
function ayuda(){
ayudaWindow = window.open("leyenda_iconos.php","Ayuda","scrollbars=yes,width=300,height=400,"+pos);
}

function anemografo(){
ayudaWindow = window.open("instrumentos/anemografo.php","anemografo","scrollbars=no,width=250,height=390,"+pos);
}

function anemometro(){
ayudaWindow = window.open("instrumentos/anemometro.php","anemometro","scrollbars=no,width=205,height=480,"+pos);
}

function barografo(){
ayudaWindow = window.open("instrumentos/barografo.php","barografo","scrollbars=no,width=355,height=375,"+pos);
}

function barometro(){
ayudaWindow = window.open("instrumentos/barometro.php","barometro","scrollbars=no,width=345,height=540,"+pos);
}

function caseta(){
ayudaWindow = window.open("instrumentos/caseta.php","caseta","scrollbars=no,width=340,height=365,"+pos);
}

function evaporimetro(){
ayudaWindow = window.open("instrumentos/evaporimetro.php","evaporimetro","scrollbars=no,width=295,height=670,"+pos);
}

function heliografo(){
ayudaWindow = window.open("instrumentos/heliografo.php","heliografo","scrollbars=no,width=445,height=370,"+pos);
}

function higrografo(){
ayudaWindow = window.open("instrumentos/higrografo.php","higrografo","scrollbars=no,width=445,height=355,"+pos);
}

function higrotermografo(){
ayudaWindow = window.open("instrumentos/higrotermografo.php","higrotermografo","scrollbars=no,width=445,height=410,"+pos);
}

function microbarografo(){
ayudaWindow = window.open("instrumentos/microbarografo.php","microbarografo","scrollbars=no,width=345,height=320,"+pos);
}

function piranometro(){
ayudaWindow = window.open("instrumentos/piranometro.php","piranometro","scrollbars=no,width=365,height=470,"+pos);
}

function pirhelio(){
ayudaWindow = window.open("instrumentos/pirheliometro.php","pirhelio","scrollbars=no,width=485,height=420,"+pos);
}

function pluviografo(){
ayudaWindow = window.open("instrumentos/pluviografo.php","pluviografo","scrollbars=no,width=345,height=540,"+pos);
}

function pluviometro(){
ayudaWindow = window.open("instrumentos/pluviometro.php","pluviometro","scrollbars=no,width=375,height=470,"+pos);
}

function psicrometro(){
ayudaWindow = window.open("instrumentos/psicrometro.php","psicrometro","scrollbars=no,width=265,height=610,"+pos);
}

function satmet(){
ayudaWindow = window.open("instrumentos/satmet.php","satmet","scrollbars=no,width=360,height=510,"+pos);
}

function satmetgeo(){
ayudaWindow = window.open("instrumentos/satmetgeo.php","satmet","scrollbars=no,width=355,height=350,"+pos);
}

function satmetpol(){
ayudaWindow = window.open("instrumentos/satmetpol.php","satmetpol","scrollbars=no,width=525,height=405,"+pos);
}

function tanque(){
ayudaWindow = window.open("instrumentos/tanque.php","tanque","scrollbars=no,width=440,height=370,"+pos);
}

function termografo(){
ayudaWindow = window.open("instrumentos/termografo.php","termografo","scrollbars=no,width=440,height=360,"+pos);
}

function termaxmin(){
ayudaWindow = window.open("instrumentos/termaxmin.php","termaxmin","scrollbars=no,width=445,height=370,"+pos);
}

function termsuelo(){
ayudaWindow = window.open("instrumentos/termsuelo.php","termsuelo","scrollbars=no,width=435,height=350,"+pos);
}


function cirrus(){
ayudaWindow = window.open("nubes/cirrus.php","cirrus","scrollbars=no,width=275,height=270,"+pos);
}

function cirrocumulus(){
ayudaWindow = window.open("nubes/cirrocumulus.php","cirrocumulus","scrollbars=no,width=275,height=270,"+pos);
}

function cirrostratus(){
ayudaWindow = window.open("nubes/cirrostratus.php","cirrostratus","scrollbars=no,width=275,height=270,"+pos);
}

function altostratus(){
ayudaWindow = window.open("nubes/altostratus.php","altostratus","scrollbars=no,width=275,height=270,"+pos);
}

function altocumulus(){
ayudaWindow = window.open("nubes/altocumulus.php","altocumulus","scrollbars=no,width=275,height=270,"+pos);
}

function stratus(){
ayudaWindow = window.open("nubes/stratus.php","stratus","scrollbars=no,width=275,height=270,"+pos);
}

function stratocumulus(){
ayudaWindow = window.open("nubes/stratocumulus.php","stratocumulus","scrollbars=no,width=275,height=270,"+pos);
}

function nimbostratus(){
ayudaWindow = window.open("nubes/nimbostratus.php","nimbostratus","scrollbars=no,width=275,height=270,"+pos);
}

function cumulus(){
ayudaWindow = window.open("nubes/cumulus.php","cumulus","scrollbars=no,width=275,height=270,"+pos);
}

function cumulonimbus(){
ayudaWindow = window.open("nubes/cumulonimbus.php","cumulonimbus","scrollbars=no,width=275,height=270,"+pos);
}


//Puertos
function capblanc(){
ayudaWindow = window.open("faros/farocaboblanco.php","capblanc","scrollbars=no,width=500,height=452,"+pos);
}

function salines(){
ayudaWindow = window.open("faros/farosalines.php","salines","scrollbars=no,width=500,height=452,"+pos);
}

function crestes(){
ayudaWindow = window.open("faros/farocrestes.php","crestes","scrollbars=no,width=500,height=452,"+pos);
}

function capdepera(){
ayudaWindow = window.open("faros/farocapdepera.php","capdepera","scrollbars=no,width=500,height=452,"+pos);
}

function alcanada(){
ayudaWindow = window.open("faros/faroalcanada.php","alcanada","scrollbars=no,width=500,height=452,"+pos);
}

function portopi(){
ayudaWindow = window.open("faros/faroportopi.php","portopi","scrollbars=no,width=500,height=452,"+pos);
}

function calafiguera(){
ayudaWindow = window.open("faros/farocalafiguera.php","calafiguera","scrollbars=no,width=500,height=452,"+pos);
}

function llebeig(){
ayudaWindow = window.open("faros/farollebeig.php","llebeig","scrollbars=no,width=500,height=452,"+pos);
}

function samola(){
ayudaWindow = window.open("faros/farosamola.php","samola","scrollbars=no,width=500,height=452,"+pos);
}

function tramuntana(){
ayudaWindow = window.open("faros/farotramuntana.php","tramuntana","scrollbars=no,width=500,height=452,"+pos);
}

function capgros(){
ayudaWindow = window.open("faros/farocapgros.php","capgros","scrollbars=no,width=500,height=452,"+pos);
}

function sacreu(){
ayudaWindow = window.open("faros/farosacreu.php","sacreu","scrollbars=no,width=500,height=452,"+pos);
}

function avansada(){
ayudaWindow = window.open("faros/faroavançada.php","avançada","scrollbars=no,width=500,height=452,"+pos);
}

function formentor(){
ayudaWindow = window.open("faros/faroformentor.php","formentor","scrollbars=no,width=500,height=452,"+pos);
}


//Escuela Naútica
function morse(){
ayudaWindow = window.open("conversor.php","conversor","scrollbars=no,width=500,height=250,"+pos);
}

function conversor(){
ayudaWindow = window.open("conversorlongitud.php","conversorlongitud","scrollbars=no,width=700,height=352,"+pos);
}

function conversorbis(){
ayudaWindow = window.open("conversorbis.php","conversorbis","scrollbars=no,width=700,height=200,"+pos);
}

function conversorbisa(){
ayudaWindow = window.open("conversorbisa.php","conversorbisa","scrollbars=no,width=600,height=300,"+pos);
}

function pos1(){
ayudaWindow = window.open("pos1.php","pos1","scrollbars=no,width=300,height=200,"+pos);
}

function pos2(){
ayudaWindow = window.open("pos2.php","pos2","scrollbars=no,width=300,height=200,"+pos);
}

function pos3(){
ayudaWindow = window.open("pos3.php","pos3","scrollbars=no,width=300,height=200,"+pos);
}

function pos4(){
ayudaWindow = window.open("pos4.php","pos4","scrollbars=no,width=300,height=200,"+pos);
}


//Recetas
function truco(){
ayudaWindow = window.open("enviatruco.php","truco","scrollbars=no,width=330,height=235,"+pos);
}



//Playas y calas
function coord(){
ayudaWindow = window.open("coord.php","coord","scrollbars=no,width=480,height=300,"+pos);
}

function coord1(){
ayudaWindow = window.open("coord1.php","coord","scrollbars=no,width=480,height=300,"+pos);
}


/*******************************************************************
*
* Rollovers de Flora y Fauna.
*
***********************************************************************/

/*
Plugin Detector()

Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)

Author: Nadav Savio
Author Email: webmonkey@giantant.com

*/

// aquí es donde redactamos el VBScript para ventanas MSIE
var WM_startTagFix = '</';
var msie_windows = 0;
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)){
  msie_windows = 1;
  document.writeln('<script language="VBscript">');
  document.writeln('\'This will scan for plugins for all versions of Internet Explorer that have a VBscript engine version 2 or greater.');
  document.writeln('\'This includes all versions of IE4 and beyond and some versions of IE 3.');
  document.writeln('Dim WM_detect_through_vb');
  document.writeln('WM_detect_through_vb = 0');
  document.writeln('If ScriptEngineMajorVersion >= 2 then');
  document.writeln('  WM_detect_through_vb = 1');
  document.writeln('End If');
  document.writeln('Function WM_activeXDetect(activeXname)');
  document.writeln('  on error resume next');
  document.writeln('  If ScriptEngineMajorVersion >= 2 then');
  document.writeln('     WM_activeXDetect = False');
  document.writeln('     WM_activeXDetect = IsObject(CreateObject(activeXname))');
  document.writeln('     If (err) then');
  document.writeln('        WM_activeXDetect = False');
  document.writeln('     End If');
  document.writeln('   Else');
  document.writeln('     WM_activeXDetect = False');
  document.writeln('   End If');
  document.writeln('End Function');
  document.writeln(WM_startTagFix+'script>');
}

function WM_pluginDetect(plugindescription, pluginxtension, pluginmime, activeXname){
  //este script block probará a todos los agentes del usuario que tienen un array real plug-in 
  //(por ejemplo Netscape) y fija las variables, de otro modo eso dirige la rutina
  // para WM _ activeXDetect y detectar el control del activeX.
  
  

  // Primero se definen algunas variables:
  var i,plugin_undetectable=0,detected=0, daPlugin=new Object();


 // Comprobamos para ver si no es un navegador MSIE, así podemos checkear los plugins en cuestión: 
  if (msie_windows && WM_detect_through_vb){
      plugin_undetectable = 0;
  } else {
      plugin_undetectable = 1;
  }

// Si tiene real plugins o mimetypes array, miramos primero el plugin:
  if(navigator.plugins) {
      numPlugins = navigator.plugins.length;
      if (numPlugins > 1) {
	  if (navigator.mimeTypes && navigator.mimeTypes[pluginmime] && navigator.mimeTypes[pluginmime].enabledPlugin && (navigator.mimeTypes[pluginmime].suffixes.indexOf(pluginxtension) != -1)) { // nos aseguramos y chequeamos la versión (si está especificada)
	      if ((navigator.appName == 'Netscape') && (navigator.appVersion.indexOf('4.0') != -1)) { // Netscape no puede manejar las referencias a los plugins del navegadors por número....
		  for(i in navigator.plugins) {
		      if ((navigator.plugins[i].description.indexOf(plugindescription) != -1) || (i.indexOf(plugindescription) != -1)) { // ... por eso algunas versiones de Quicktime no tienen descripción
			  detected=1;
			  break;
		      }
		  }
	      } else {
		  for (i = 0; i < numPlugins; i++) {
		      daPlugin = navigator.plugins[i];
		      if ((daPlugin.description.indexOf(plugindescription) != -1) || (daPlugin.name.indexOf(plugindescription) != -1)) {
			  detected=1;
			  break;
		      }
		  }
	      }

	      // Rarezas Mac:
      if (navigator.mimeTypes[pluginmime] == null) {
		  detected = 0;
	      }
	  }
	  return detected;
      } else if((msie_windows == 1) && !plugin_undetectable){
	  return WM_activeXDetect(activeXname);
      } else { 		
	  return 0;
      }
  } else {
      return 0;
  }
}


// esta función hace más fácil detectar los plugins comunes:
function WM_easyDetect(whichPlugin) {

    // hace fácil la detección de plugins sin saber los mimetypes y nombres activeX:
    var isItThere = 0;
    if( (whichPlugin == 'flash') || (whichPlugin == 'Flash') ) {
	isItThere = WM_pluginDetect('Flash', 'swf', 'application/x-shockwave-flash', 'ShockwaveFlash.ShockwaveFlash');
    } 

    return isItThere;
}


/*******************************************************************
*
* Fade de los rollovers de cada top.
*
***********************************************************************/
/*** Creación de variables globales ***/

var FadingObject = new Array();
var FadeRunning=false;
var FadeInterval=30;

/*******************************************************************************/
/*** Estas son las más simples HEX/DEC rutinas de conversion 				 ***/
/*******************************************************************************/

var hexDigit=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
function dec2hex(dec)
{
	return(hexDigit[dec>>4]+hexDigit[dec&15]);
}
function hex2dec(hex)
{
	return(parseInt(hex,16))
}
/******************************************************************************************/

/***********************************************************
* Función   : createFaderObject
*
* Parámetros : theDiv   - el nombre del DIV en el que cambia el texto.
*              numSteps - el número de pasos para usar en el fade.
*		       startColor - el color de fondo de la página.
*              
* Descripción : crea un objeto que puede mantener el estado actual
*               del fade para un DIV en concreto.
***********************************************************/
function createFaderObject(theDiv, numSteps, startColor)
{
	if(!startColor)
		startColor = "000000";
		
	this.name		= theDiv;
	this.text		= null;
	this.color		= "FFFFFF";
	this.next_text	= null;
	this.next_color	= null;
	this.state		= "OFF";
	this.index		= 0;
	this.steps		= numSteps;
	this.r		= hex2dec(startColor.slice(0,2));
	this.g		= hex2dec(startColor.slice(2,4));
	this.b		= hex2dec(startColor.slice(4,6));
}

/***********************************************************
* Función   :  FadingText
*
* Parámetros : theDiv   - el nombre del DIV en el que cambia el texto.
*              numSteps - el número de pasos para usar en el fade.
*              
* Descripción : función Library a llamar desde el HTML principal.
*		        Crea un objeto que maneja el estado actual de fade
*               la animación fade para una DIV particular.
***********************************************************/
function FadingText(theDiv, numSteps, startColor)
{
	FadingObject[theDiv] = new createFaderObject(theDiv, numSteps, startColor);
}
/*****************************************************************
* Función     : start_fading
*
* Descripción : Si el loop FadeAnimation no está corriendo actualmente
*		        entoces se inicia.
*****************************************************************/
function start_fading()
{
	if(!FadeRunning)
		FadeAnimation();
}
/*****************************************************************
* Función     : set_text
*
* Descripción : en el nuevo modelo W3C DOM necesitamos 
*				solamente fijar el texto una vez,
*				depués de lo cual podemos cambiar el color.
*
*****************************************************************/
function set_text(f)
{
	if(navigator.appName.indexOf("Netscape") != -1
		&& document.getElementById)
	{
		var theElement = document.getElementById(f.name);
		var newRange   = document.createRange();
		newRange.setStartBefore(theElement);
		var strFrag    = newRange.createContextualFragment(f.text);	

		while (theElement.hasChildNodes())
			theElement.removeChild(theElement.lastChild);
		theElement.appendChild(strFrag);
		theElement.style.color="#"+f.startColor;
	}
}
/*****************************************************************
*
* Función    : getColor
*
* Parámetros : f - el objeto fade por el cual se calcula el color.
*
* Descripción: calcula el color del link, dependiento del punto 
*		       en el que nos encontramos del fade en que estamos.
*
*****************************************************************/
function getColor(f)
{
	var r=hex2dec(f.color.slice(0,2));
	var g=hex2dec(f.color.slice(2,4));
	var b=hex2dec(f.color.slice(4,6));

	r2= Math.floor(f.r+(f.index*(r-f.r))/(f.steps) + .5);
	g2= Math.floor(f.g+(f.index*(g-f.g))/(f.steps) + .5);
	b2= Math.floor(f.b+(f.index*(b-f.b))/(f.steps) + .5);

	return("#" + dec2hex(r2) + dec2hex(g2) + dec2hex(b2));
}
/*****************************************************************
*
* Función    : setColor
*
* Parámetros : fadeObj   - El objeto TextFader a fijar
*
* Descripción: Obtiene el color del texto y lo escribe en la DIV.
*		      
*****************************************************************/
function setColor(fadeObj)
{
	var theColor=getColor(fadeObj);
	var str="<FONT COLOR="+ theColor + ">" + fadeObj.text + "</FONT>";
	var theDiv=fadeObj.name;
	
//si IE 4+
	if(document.all)
	{
		document.all[theDiv].innerHTML=str;
	}	
//sino si NS 4
	else if(document.layers)
	{
		document.nscontainer.document.layers[theDiv].document.write(str);
		document.nscontainer.document.layers[theDiv].document.close();
	}
//sino si NS 6
	else if (document.getElementById)
	{
		theElement = document.getElementById(theDiv);
		theElement.style.color=theColor;
	}
	
}
/*****************************************************************
*
* Función    : fade_up
*
* Parámetros : theDiv  - La div en la que mostramos el texto
*		       newText - El texto a mostrar cuando se hace el fade
*		       newColor- Color que tendrá el texto
*
* Descripción: Dependiendo del estado actual del fade
*		       esta función determinará el nuevo estado y
*		       si fuera necesario, iniciar los efectos fade.
*
*****************************************************************/
function fade_up(theDiv, newText, newColor)
{
	var f=FadingObject[theDiv];

	if(newColor == null)
		newColor="FFFFFF";

	if(f.state == "OFF")
	{
		f.text  = newText;
		f.color = newColor;
		f.state = "FADE_UP";
		set_text(f);
		start_fading();
	}
	else if( f.state == "FADE_UP_DOWN"
		|| f.state == "FADE_DOWN"
		|| f.state == "FADE_DOWN_UP")
	{
		if(newText == f.text)
			f.state = "FADE_UP";
		else
		{
			f.next_text  = newText;
			f.next_color = newColor;
			f.state      = "FADE_DOWN_UP";
		}
	}
}
/*****************************************************************
*
* Función    : fade_down
*
* Parámetros : theDiv  - La div en la que mostramos el texto
*
* Descripción: Dependiendo del estado actual del fade
*		       esta función determinará el nuevo estado y
*		       si fuera necesario, empezar los efectos fade.
*
*****************************************************************/
function fade_down(theDiv)
{
	var f=FadingObject[theDiv];

	if(f.state=="ON")
	{
		f.state="FADE_DOWN";
		start_fading();
	}
	else if(f.state=="FADE_DOWN_UP")
	{
		f.state="FADE_DOWN";
		f.next_text = null;
	}
	else if(f.state == "FADE_UP")
	{
		f.state="FADE_UP_DOWN";
	}
}
/*******************************************************************
*
* Función    : Animate
*
* Descripción : Esta función se basa en la función Animate
*		        de animate.js (rollovers animados).
*		        Cada objeto fade tiene un estado. Esta función
*		        modifica cada objeto y cambia su estado.
*
*****************************************************************/
function FadeAnimation()
{
	FadeRunning = false;
	for (var d in FadingObject)
	{
		var f=FadingObject[d];

		if(f.state == "FADE_UP")
		{
			if(f.index < f.steps)
				f.index++;
			else
				f.index = f.steps;
			setColor(f);

			if(f.index == f.steps)
				f.state="ON";
			else
				FadeRunning = true;
		}
		else if(f.state == "FADE_UP_DOWN")
		{
			if(f.index < f.steps)
				f.index++;
			else
				f.index = f.steps;
			setColor(f);

			if(f.index == f.steps)
				f.state="FADE_DOWN";
			FadeRunning = true;
		}
		else if(f.state == "FADE_DOWN")
		{
			if(f.index > 0)
				f.index--;
			else
				f.index = 0;
			setColor(f);

			if(f.index == 0)
				f.state="OFF";
			else
				FadeRunning = true;
		}
		else if(f.state == "FADE_DOWN_UP")
		{
			if(f.index > 0)
				f.index--;
			else
				f.index = 0;
			setColor(f);

			if(f.index == 0)
			{
				f.text      = f.next_text;
				f.color     = f.next_color;
				f.next_text = null;
				f.state     ="FADE_UP";
				set_text(f);
			}
			FadeRunning = true;
		}
	}
	// Chequemaos para ver si necesitamos animar más frames:
	if(FadeRunning)
		setTimeout("FadeAnimation()", FadeInterval);

}


/*
 * FadingText(divName, numSteps, BGColor)
 * divName : deben corresponderse los nombres DIV definidos al final del BODY.
 * numSteps: el número de pasos en la transición del FADE.
 * BGColor : el color de fondo del DIV o documento.
 */
	FadingText('fadeindex', 10,"1D3974");
	FadingText('fadebuscador', 10,"FE9F0F");		
	FadingText('fadeasoc', 10,"C4C5A9");
	FadingText('fadeportes', 10,"427C93");
	FadingText('fademergencias', 10,"666666");
	FadingText('fadescuela', 10,"B9C0CD");
	FadingText('fadeforo', 10,"FFFFFF");
	FadingText('fadehistorias', 10,"4B617D");
	FadingText('fademeteo', 10,"16325C");
	FadingText('fadenavegar', 10,"D0B9BE");
	FadingText('fadeplayas', 10,"D1A11D");
	FadingText('fadepuertos', 10,"BAC3CF");
	FadingText('faderecetas', 10,"C9D2CC");
	FadingText('faderestaurantes', 10,"7A4427");
	FadingText('fadeservmar', 10,"785190");
	FadingText('fadetorneos', 10,"CBCEBA");
	FadingText('fadeturismo', 10,"4896E1");


//  El "Frame Interval"; cuanto más pequeño = más rápido:
	FadeInterval=15;
