// JavaScript Document
function overTD(td,color){td.bgColor=color; td.border=1; td.bordercolor="#00AA00";}
function outTD(td,color){td.style.cursor='default';td.bgColor=color; td.border=0;} 
var voy_imagen=0;

function sube_imagen(myField)
{
	var direc=prompt("Introduce dirección de la imagen (Debe estar previamente subida a internet)");
	if (direc!=null) insertAtCaret(myField, "[IMG]" + direc + "[/IMG]");
}

function sube_video(myField)
{
	var direc=prompt("Introduce código del video (Debe estar previamente subido a internet)");
	var inicio=direc.indexOf ("http", 0);
	var fin;
	
	if (inicio!=-1) fin=direc.indexOf(">", inicio);
	if (direc!=null) insertAtCaret(myField, "[VDO]" + direc.substring(inicio, fin-1) + "[/VDO]");
}

function abre_ventana(imagen, x, y) {
    cadena="width=" + x +", height=" + y + ",scrollbars=NO, resizable=NO";
	window.open(imagen,'visor de fotografías',cadena);
}

function oscurece()
{
   var altura;
   var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1

   altura=document.body.scrollHeight;

   window.document.getElementById('tr1').style.height = altura; 
   window.top.lftFr.document.getElementById('tr2').style.height = altura;
   window.top.superior.document.getElementById('dv_sup').style.height = 81;
   window.top.vacio1.document.getElementById('tr3').style.height = altura;   
   window.top.vacio2.document.getElementById('tr4').style.height = altura;
   
   if (ie4)
   {
	   window.document.getElementById('tr1').filters.alpha.opacity=70;
	   window.top.lftFr.document.getElementById('tr2').filters.alpha.opacity=70;
	   window.top.superior.document.getElementById('dv_sup').filters.alpha.opacity=70;
       window.top.vacio1.document.getElementById('tr3').filters.alpha.opacity=70;
       window.top.vacio2.document.getElementById('tr4').filters.alpha.opacity=70;
   } else  
   {
	   window.document.getElementById('tr1').style.MozOpacity = 0.7; 
       window.top.lftFr.document.getElementById('tr2').style.MozOpacity = 0.7;
       window.top.superior.document.getElementById('dv_sup').style.MozOpacity = 0.7;  
       window.top.vacio1.document.getElementById('tr3').style.MozOpacity = 0.7; 
       window.top.vacio2.document.getElementById('tr4').style.MozOpacity = 0.7;
   }
   window.top.superior.document.getElementById('anuncio').style.visibility="hidden";
}

function aclara()
{
   var altura;
   var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1

   window.document.getElementById('tr1').style.height = 0; 
   window.top.lftFr.document.getElementById('tr2').style.height = 0;
   window.top.superior.document.getElementById('dv_sup').style.height = 0;
   window.top.vacio1.document.getElementById('tr3').style.height = 0;
   window.top.vacio2.document.getElementById('tr4').style.height = 0;
   
   if (ie4)
   {
       window.document.getElementById('tr1').filters.alpha.opacity=0;
       window.top.lftFr.document.getElementById('tr2').filters.alpha.opacity=0;
       window.top.superior.document.getElementById('dv_sup').filters.alpha.opacity=0;
       window.top.vacio1.document.getElementById('tr3').filters.alpha.opacity=0;
       window.top.vacio2.document.getElementById('tr4').filters.alpha.opacity=0;
   } else {
        window.document.getElementById('tr1').style.MozOpacity = 0;
	    window.top.lftFr.document.getElementById('tr2').style.MozOpacity = 0;
   		window.top.superior.document.getElementById('dv_sup').style.MozOpacity = 0;
 	    window.top.vacio1.document.getElementById('tr3').style.MozOpacity = 0;
		window.top.vacio2.document.getElementById('tr4').style.MozOpacity = 7;
   }
   window.top.superior.document.getElementById('anuncio').style.visibility="visible";
}

function ver_ventana(nombre, ancho)
{
	if (window.document.getElementById(nombre).style.visibility == "visible")
	{
		   window.document.getElementById(nombre).style.visibility = "hidden"; 
           window.document.getElementById(nombre).style.width = 0; 
	}
	else
	{
           window.document.getElementById(nombre).style.visibility = "visible"; 
           window.document.getElementById(nombre).style.width = ancho; 
	}
}

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_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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.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];}
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;
	var suma;
	
    if (speed<0) speed=-speed;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			if (millisec>0) suma=-1; else suma=0;
			setTimeout("changeOpac(" + i + ",'" + id + "'," + suma + ")",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			if (millisec>0) suma=1; else suma=0;
			setTimeout("changeOpac(" + i + ",'" + id + "'," + suma +")",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id, suma) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";

    document.images[id-1].height+=suma;
}

function llamar (url, id_contenedor)
{
	   var pagina_requerida = false;
	   if (window.XMLHttpRequest)
	   {
		      // Si es Mozilla, Safari...
			  pagina_requerida = new XMLHttpRequest ();
	   } else if (window.ActiveXObject)
	   {
		      // Pero si es IE
			  try
			  {
				      pagina_requerida = new ActiveXObject ("Msxml2.XMLHTTP");
			  }
			  catch (e)
			  {
				     // en caso que sea una version antigua
					 try
					 {
						 pagina_requerida = new ActiveXObject ("Microsoft.XMLHTTP");
					 }
					 catch (e)
					 {
					 }
			  }
	   }
	   else
	   return false;
	   pagina_requerida.onreadystatechange = function ()
	   {
		      // Función de respuesta
			  cargarpagina (pagina_requerida, id_contenedor);
	   }
	   pagina_requerida.open ('GET', url, true);
	   pagina_requerida.send (null);
}

function cargarpagina(pagina_requerida, id_contenedor)
{
	  if (pagina_requerida.readyState == 4 && (pagina_requerida.status ==200 || window.location.href.indexOf ("http") == -1))
	     document.getElementById (id_contenedor).innerHTML = pagina_requerida.responseText;
}

function insertAtCaret(myField, myValue) 
{
   //IE support
   if (document.selection) {
      myField.focus();
      sel = document.selection.createRange();
      sel.text = myValue;
   }
   //MOZILLA/NETSCAPE support
   else if (myField.selectionStart || myField.selectionStart == '0') {
   var startPos = myField.selectionStart;
   var endPos = myField.selectionEnd;
   myField.value = myField.value.substring(0, startPos)
   + myValue 
   + myField.value.substring(endPos, myField.value.length);
   } else {
      myField.value += myValue;
   }
}

function in_diapositiva(total)
{
	var nombre="";
	
	nombre="intro" + voy_imagen;
	if (voy_imagen==0) nombre = nombre + ".png"; else nombre = nombre + ".gif";
	voy_imagen = voy_imagen + 1;
	if (voy_imagen>total) voy_imagen=0;
    MM_swapImage('im_tit','',nombre);

	opacity('im_tit', 0, 100, 1000);

    var funcion="diapositiva("+total+")";
	window.setTimeout(funcion,10000);
}
function diapositiva(total)
{
	opacity('im_tit', 100, 0, 1000);
 
    var funcion = "in_diapositiva(" + total + ")";
	window.setTimeout(funcion, 1000);
}

function llamar_foro(url, id_contenedor)
{
	oscurece();

    var tipo = escape(document.frm.tema.value);
	
	if (tipo=="")
	{
	   var valor=document.frm.tema.selectedIndex;
	   tipo=escape(document.frm.tema.options[valor].text);
	}
		
url = url + "&vistaprevia=" + document.frm.boton.value + "&titulo=" + escape(document.frm.titulo.value) + "&tema=" + tipo + "&mensaje=" + escape(document.frm.mensaje.value);

  
  llamar(url, id_contenedor);
}

function gourl(url)
{
	location.href=url;
}

function countgoogle()
{
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
try {
   var pageTracker = _gat._getTracker("UA-10911646-1");
   pageTracker._trackPageview();
    } catch(err) {}
}