var ResizeIframe = {   
  wrapperId : "tinc_content",
                
  /**
   * Resizes an iframe sId including oDoc to oDoc's content size.
   * Can be called top-down, i.e. from the including iframe (or it's parents) or bottom-up, i.e. from the included document.
   * In the latter case the iframe element is retrieved programmatically.
   * 
   * @param oDoc  Included page's document object
   * @param sId   ID of including iframe
   */               
  resize : function ( oDoc, sId ) 
  {
    try
    {
      if ( typeof oDoc == "undefined" ) return;
  
      if ( typeof sId != "undefined" ) 
      {
        var iframe = oDoc.getElementById( sId );
        var iframeDoc = iframe.contentWindow.document;
      } else {
        var iframeDoc = oDoc;
        var iframeWindow = iframeDoc.parentWindow || iframeDoc.defaultView;
        var iframe = iframeWindow.frameElement;
      }
      var wrapper = iframeDoc.getElementById( this.wrapperId );

      // make sure we only resize once
      if ( iframeDoc.isIntegrated == true ) { return; }
      
      // switch on transparency for iframe
      iframeDoc.body.style.backgroundColor = "transparent";
      iframe.allowTransparency = "true";
            
      iframeDoc.body.style.padding = "0px";
      iframeDoc.body.style.border = "none";
      
      var tabs = iframeDoc.getElementsByTagName( "table" )
      if ( tabs[0] && tabs[0].className == "dborder" )
     	{		
      	wrapper.setAttribute( "wfx:overridewidth", "true" );
      } else if ( iframeDoc.forms[0] && iframeDoc.forms[0].elements["formname"] ) 
      {
      	wrapper.setAttribute( "wfx:overridewidth", "true" );
      } 
      
      if ( window.addEventListener )
      {   
      	var gcs = iframeDoc.defaultView.getComputedStyle( iframeDoc.body, null);
        var v_margin = parseInt( gcs.getPropertyValue( "margin-top" ) ) + parseInt( gcs.getPropertyValue( "margin-bottom" ) );
        var h_margin = parseInt( gcs.getPropertyValue( "margin-left" ) ) + parseInt( gcs.getPropertyValue( "margin-right" ) );
        var wrapper_width = wrapper.offsetWidth;
        
        var flex = wrapper.getAttribute( "wfx:overridewidth" );
        if ( flex == "true" )
        {
        	wrapper.style.width = "100%";
        } else {
        	iframe.style.width = wrapper_width + h_margin + "px";
        }
        
        // Setting the top padding of the wrapper avoids wrong calculation of the height due to collapsing margins behavior
        wrapper.style.paddingTop = "1px";
        
        height = wrapper.offsetHeight + v_margin ;
      } 
      else if ( window.attachEvent ) 
      {        
        iframeDoc.body.style.margin = "0px";
        var wrapper_width = wrapper.offsetWidth;
        
        var flex = wrapper.getAttribute( "wfx:overridewidth" );
        if ( flex == "true" )
        {
        	wrapper.style.width = "100%";
        } else {
        	iframe.style.width = wrapper_width + "px";
        }
        
        height = wrapper.offsetHeight;
      }

      if ( iframe.scrolling != "yes" ) { height += 20; }
      
      iframe.style.height = height + "px";
      iframeDoc.isIntegrated = true; 
    } catch ( ex )
    {
      return; 
    }
    
    WfxExtrasProcessor.process( oDoc, sId );
  }
}

var WfxExtrasProcessor = {
  process : function ( oDoc, sId)
  {    
    if ( typeof oDoc == "undefined" ) return;
  
    if ( typeof sId != "undefined" ) 
    {
      var iframe = oDoc.getElementById( sId );
      var iframeDoc = iframe.contentWindow.document;
    } else {
      var iframeDoc = oDoc;
      var iframeWindow = iframeDoc.parentWindow || iframeDoc.defaultView;
      var iframe = iframeWindow.frameElement;
    }
    
    // let non-tinc links load in the parent document. this might need some adjustment
    var links = iframeDoc.getElementsByTagName( "a" );
    for ( var i = 0; i < links.length; i++ )
    {
      if ( links[i].href.indexOf( "/tinc" ) == -1 ) links[i].target = "_parent";
    }
    
    // Special case: WebElements forms might do redirection to another page after submission. That's indicated by a non-empty
    // 'redirectionEnabled' attribute of a submit button. 
    var inputs = iframeDoc.getElementsByTagName( "input" );
    for ( var i = 0; i < inputs.length; i++ )
    {
      var input = inputs[i];
      if ( input.getAttribute("redirection") != null && input.getAttribute("redirection") != '' ) 
        input.form.target = "_parent";
    }
  }
}

/*funcion de poner datos de la serie*/
function ponerAlturaSeparador() {
	//obtenemos el div correspondiente al separador
	var dSeparador = document.getElementById("separador");
	var dIzda = document.getElementById("datos_izda");
	var dDcha = document.getElementById("datos_dcha");
	//alert("Altura Izquierda: " + dIzda.height);
	//alert("Altura Derecha: " + dDcha.height);
	//alert("Altura Separador: " + dSeparador.height);
	//obtenemos el div mas alto
	if (dDcha.height > dIzda.height) {
		//alert("Derecha: " + dDcha.height);
		dSeparador.height = dDcha.height;
	} else {
		//alert("Izquierda: " + dIzda.height);
		dSeparador.height = dIzda.height;
	}
}

//Esta función pone como innerHTML el texto que le pasamos en la
//variable 'dato' en la capa identidicada mediante el ID que le
//pasamos en idCapa
function ponerDatosCapa(idCapa, dato, tag) {
	var dCapa = document.getElementById(idCapa);
	var pr = dCapa.getElementsByTagName(tag);
	pr[0].innerHTML = dato;
}
function cargar1pie() {
	//alert("entramos a cargar1pie");
	var texto = "<img width='176' height='204' src='../imagenes/carrera1.jpg.jpg' align='left' hspace='12' /> <img width='432' height='177' src='../imagenes/zubizuriw.gif' /><br /> \
La  primera carrera a pie partir&aacute; de la Ribera Botica Vieja  y discurrir&aacute; por la zona peatonal del Paseo, Avda Universidades y Campo  Volant&iacute;n junto a la valla de la r&iacute;a, atravesar&aacute; la r&iacute;a por la rampa del puente  Zubizuri (Calatrava) haciendo un doble zigzag y regresar&aacute; por el Paseo de  Uribitarte siguiendo la l&iacute;nea blanca del suelo. <br /> \
  A la altura del Hotel Sheraton se continuar&aacute; de frente hacia  el Palacio de Euskalduna y se girar&aacute; a la izquierda para coger la Avenida de  Abandoibarra. Pasar&aacute; frente al Palacio de Euskalduna y descender&aacute; por la zona  peatonal del Puente, efectuando el giro de 180 grados <img width='176' height='264' src='../imagenes/carrera1b.jpg' align='left' hspace='12' />en el Camino de Morgan  para pasar por la l&iacute;nea de meta y enfilar el Paseo de la Ribera de Botica Vieja  por el bidegorri hasta los boxes. Todo ello se observa de forma gr&aacute;fica en la  imagen superior.<br />\
  El circuito estar&aacute;  se&ntilde;alizado cada km mediante cartel indicativo.<br /> \
  Existir&aacute;n carteles con flechas indicativas de la direcci&oacute;n a  tomar en las zonas de posible confusi&oacute;n, si bien en todas ellas existir&aacute;  personal voluntario con bander&iacute;n se&ntilde;alizador.<br /> \
  Habr&aacute; acompa&ntilde;amiento en bicicleta con el inicio y fin de  carrera, aunque tambi&eacute;n se acompa&ntilde;ar&aacute; la llegada a meta de la primera mujer"; 
	ponerDatosCapa("titulo", "Circuito 1&ordf; carrera a pie", "h2");
	ponerDatosCapa("cuerpo", texto, "p");
}

function nuevo_evento(elemento, evento, funcion) {
      if (elemento.addEventListener) {
            elemento.addEventListener(evento, funcion, false);
      } else {
            elemento.attachEvent("on"+evento, funcion);
      }
}
function igualarAlturas(divIzda, divDcha, divSeparador) {
        if ($(divDcha).height() > $(divIzda).height()) {
			//alert("dcha > izda - dcha:"+$(divDcha).height()+"; izda:"+$(divIzda).height()+"; separador:"+$(divSeparador).height());
			//$(divSeparador).height($(divDcha).height());
			//alert("ahora separador:"+$(divSeparador).height());
            $(divIzda).height($(divDcha).height())
			//alert("ahora - dcha:"+$(divDcha).height()+"; izda:"+$(divIzda).height()+"; separador:"+$(divSeparador).height());
        }else{
			//alert("izda > dcha - dcha:"+$(divDcha).height()+"; izda:"+$(divIzda).height()+"; separador:"+$(divSeparador).height());
            $(divDcha).height($(divIzda).height())
			//alert("ahora - dcha:"+$(divDcha).height()+"; izda:"+$(divIzda).height()+"; separador:"+$(divSeparador).height());
			//$(divSeparador).height($(divIzda).height());
			//alert("ahora separador:"+$(divSeparador).height());
        }
        $(divSeparador).height($(divDcha).height())
}


    
