// JavaScript Document

/*---redireccion-realizada por form---*/
function red_gen(a,b,c,d,e,f)
{  	//a   = formulario
	//b   =	URL. 
	//c   = extension
	//d   =	nombre variable
	//e   =	valor variable	
		
	formulario = document.forms[a];	

	formulario.action = b + c;
	if (e != "")
	{	 formulario.action += "&" + d + "=" + e;
	}	
	/*---si-existe-un-tiempo-especificado...---*/
	if (d == 2)
 	{	formulario.action = "../"+formulario.action;
 	}

	if (f != "") 
	{	if (typeof(f) == "number")
		{	setTimeout("formulario.submit();",f);
		}
		else
		{	
			formulario.target = f;
			
		}
	}
	else
	{   
			formulario.submit();
	}
}
/*
function ajax (a,b,c,d,e,f,g,h,i,j,k,l,m,n)
{	//	a 	= archivo ajx a ejecutar
	//  b 	= ID donde se incluirį la respuesta
	//  c   = Accion Mintras Carga
	//  d   = Valor Mientras Carga
	//  e   = Accion al finalizar Carga
	//  f   = Valor al finalizar Carga
	//  g   = Realizar Ejecucion
	//  h   = Valor Ejecucion / ID de Accion Mientras Carga	
	//  i   = Formulario
	//  j   = Metodo de Envio
	//  k   = Variable DES
	//  l 	= Variable Index?
	//  m 	= Variable Idioma
	//  n 	= Variable Extension
	
	ext = "";	
	var myConn = new XHConn();
	var cerrar = false;
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
		
	//acciones al llamar a ajax
	
	if (g != 1)
	{	if (h == "idem")
		{	ele = document.getElementById(b);						
		}
		else
		{	
			if ((h == "idem_parrafo") || (h == "idem_usuario"))
			{	
				ele = document.getElementById(b);
				
				ele[c] = "<p class='CENTER_text' style='background-color:transparent;' id='talla_cargando'>"+d+"</p>"

								
			}		
			else
			{	ele = document.getElementById(h);
			}	
		}
		
		//
	} 
	else
	{	
		switch (document.getElementById('tip_bloques').value)
		{	case "2":
						document.getElementById('preloader').style['display'] = 'inline';
						
						document.getElementById('preloader').innerHTML  = "<div class='preloader_text' id='preloader_text'></div>";			
						document.getElementById('preloader_text').innerHTML = document.getElementById('preloader_text').innerHTML + "<p class='LEFT_text' id='talla_preloader'>Proceso de Carga de Contenidos</p>";
						document.getElementById('preloader_text').innerHTML = document.getElementById('preloader_text').innerHTML + "<p class='CENTER_text' id='talla_blanco' style='color:#000'>Cargando contenido de <span style='color:#f00'>" + document.getElementById('tot_bloques').value + "</span></p>";
						document.getElementById('preloader_text').innerHTML = document.getElementById('preloader_text').innerHTML + "<p class='CENTER_text' id='talla_blanco' style='color:#000'>espere un momento...</p>";
							
		} 						  	  			
	}

	var include_terminado = function (oXML)
	{	/*---antes-de-cargar-los-contenidos-eliminamos-los-bordes-de-los-divs---*/
/*
		switch (document.getElementById('tip_bloques').value)
		{	case "1":	document.getElementById(b).style['border'] = "0px";		
						document.getElementById('bloques').value = eval(document.getElementById('bloques').value)+1;
						if (document.getElementById('bloques').value == document.getElementById('tot_bloques').value)
						{	document.getElementById('preloader').style['display'] = 'none';
							document.getElementById('bloques').value = '0';
						}
						document.getElementById('preloader').innerHTML  = "<div class='preloader_text' id='preloader_text'></div>";			
						document.getElementById('preloader_text').innerHTML = document.getElementById('preloader_text').innerHTML + "<p class='LEFT_text' id='talla_preloader'>Proceso de Carga de Contenidos</p>";
						document.getElementById('preloader_text').innerHTML = document.getElementById('preloader_text').innerHTML + "<p class='CENTER_text' id='talla_blanco' style='color:#000'>Cargando bloque <span style='color:#f00'>" + a.substr(8 , a.length) + "</span></p>";
						document.getElementById('preloader_text').innerHTML = document.getElementById('preloader_text').innerHTML + "<p class='CENTER_text' id='talla_blanco' style='color:#000'>espere un momento...</p>";						
						document.getElementById('preloader_text').innerHTML = document.getElementById('preloader_text').innerHTML + "</div>";
						break;
			case "2":	
						document.getElementById('preloader').innerHTML  = "<div class='preloader_text' id='preloader_text'></div>";			
						document.getElementById('preloader_text').innerHTML = "";
						document.getElementById('preloader').style['display'] = 'none';							
						break;							
		}												
			
		
		document.getElementById(b).innerHTML = oXML.responseText;

		
		switch (h)
		{	case "contenedor_men_expresate":
		
				if (document.getElementById('num_mensajes').value != 0)
				{	Scroller_Vertical(1,"expresate_div",60,0);
				}				
					
				break
			case "idem_usuario":
			    lanza = "&fld_usuario="+document.getElementById('usuario_res').value;
       			document.getElementById('usuario_log').value = document.getElementById('usuario_res').value;
       			ajax ("ajx_crear_sesion","contenedor_sesion",c,'',e,f,g,'idem_parrafo',i,j,k,l,m,lanza)
		}
		
		
	};
	
	ext +="&des="+k+"&index="+l;
		
	if (m != "")
	{	ext += "&lan="+m;
	}
	if (n != "")
	{	ext += n;
	}
	
	
	myConn.connect("ajx/ajx_redirect.php", j, "url="+a+ext, include_terminado);
	
}
*/
function Scroller_Vertical(a,b,c,d,e)
{	//a	=	Velocidad
	//b	=	ID
	//c	=	Altura
	//d	=	Inicio	
	
	if (document.getElementById("num_mensajes").value > 1)
	{	//setInterval("Empezar_Scroll('"+a+"','"+b+"','"+c+"','"+d+"');",8000);
		Empezar_Scroll(a,b,c,d);	
	}
	else
	{	if (document.getElementById("num_mensajes").value == 1)		
		{	document.getElementById(b+"0").style['display']='inline';
		}		
	}
	
}
var Numero_de_Mensaje = 0;
var Scroller;
function Empezar_Scroll(a,b,c,d)
{	if (Numero_de_Mensaje >= document.getElementById("num_mensajes").value)
	{	Numero_de_Mensaje = 0;				
	}		
	for (contador = 0; contador < document.getElementById("num_mensajes").value ; contador++)
	{	if (Numero_de_Mensaje == contador)
		{	document.getElementById(b+Numero_de_Mensaje).style['display'] = 'inline';
		}
		else
		{	document.getElementById(b+contador).style['display'] = 'none';
		}
		document.getElementById(b+contador).style['top'] = '0pt';
	}
		
	temporizador = 0;
	opacidad = 9;
	filter = 0;
	
	if (Scroller != "undefined")
	{	clearInterval(Scroller);		
	}	
	Scroller = setInterval("Temporizar('"+a+"','"+b+"','"+c+"','"+d+"','"+Numero_de_Mensaje+"')",2);
	Numero_de_Mensaje++;	
}

var temporizador = 0;
var transicion = 0;
var vel = 1;
function Temporizar(a,b,c,d,e)
{	if (temporizador <= c/3)
	{	if ((temporizador >= c/3) && (transicion == 0))
		{	clearInterval(Scroller);
			transicion = 1;
			setTimeout("ejecutar_Temporizador('"+a+"','"+b+"','"+c+"','"+d+"','"+e+"');",6000);			
		}
		else
		{	if (temporizador > c/3)
			{								
			}
			else
			{	if (opacidad < 9)
				{	//opacidad = opacidad+1;
				}
				temporizador++;
			}					
		}		
		
		document.getElementById(b+e).style['top'] = temporizador+"pt";
		document.getElementById(b+e).style['opacity'] = "0."+opacidad;
		document.getElementById(b+e).style['filter'] = "alpha(opacity="+opacidad+"0)";			
	}	
	else
	{	document.getElementById(b+e).style['top'] = "0pt";		
		temporizador = 0;
		transicion = 0;
		clearInterval(Scroller);
		
		Empezar_Scroll(a,b,c,d);	
			
	}	
	
	
}

function ejecutar_Temporizador(a,b,c,d,e)
{	Scroller = setInterval("Temporizar('"+a+"','"+b+"','"+c+"','"+d+"','"+e+"')",2);
}
	
function Inicializar_Selects(a)
{	//a	=	formulario
	form_ruta = document.forms[a];	
		
	for (contador = 0 ; contador < 3 ; contador++)
	{	
		if (form_ruta['Hidden_'+contador].value != "0")
		{	valor_ini = form_ruta['Hidden_'+contador].value.lastIndexOf('@')+1;			
			valor_fin = form_ruta['Hidden_'+contador].value.length
			form_ruta['Valor_'+contador].value = form_ruta['Hidden_'+contador].value.substr(valor_ini , valor_fin);
			
			ele_BOT = document.getElementById("ima_"+contador);			
			ele_BOT.src = "ima/menu_desplegable_b.png";
		}
	}
}
/*
function XHConn()
{	var xmlhttp, bComplete = false;
  	try
	{	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
  	catch (e)
	{	try
		{	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
  		catch (e)
		{	try
			{	xmlhttp = new XMLHttpRequest();
			}
  			catch (e)
			{	xmlhttp = false;
			}
		}
	}
  	if (!xmlhttp) return null;
  	this.connect = function(sURL, sMethod, sVars, fnDone)
  	{	
	  	if (!xmlhttp) return false;
    	bComplete = false;
    	sMethod = sMethod.toUpperCase();
	    try
		{   
			if (sMethod == "GET")
	      	{	xmlhttp.open(sMethod, sURL+"?"+sVars, true);
    	    	sVars = "";
      		}
      		else
      		{	xmlhttp.open(sMethod, sURL, true);
        		xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        		xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
      		}
      		xmlhttp.onreadystatechange = function()
			{	if (xmlhttp.readyState == 4 && !bComplete)
        		{	bComplete = true;
          			fnDone(xmlhttp);
        		}
			};
      		xmlhttp.send(sVars);
    	}
    	catch(z)
		{	return false;
		}
    	return true;
  	};
  	return this;
}
*/
