//addEvent(window,'load',inicializarEventos,false);

function inicializarEventos()
{
  var ob;
  for(f=1;f<=12;f++)
  {
    ob=document.getElementById('enlace'+f);
    addEvent(ob,'click',presionEnlace,false);
  }
}

function presionEnlace(e)
{
  if (window.event)
  {
    window.event.returnValue=false;
    var url= "A105-SP471.gif";
	window.event.srcElement.getAttribute('href');
    cargarHoroscopo(url);     
  }
  else
    if (e)
    {
      e.preventDefault();
      var url=e.target.getAttribute('href');
      cargarHoroscopo(url);     
    }
}


var conexion1;
function cargarHoroscopo(url) 
{
  if(url=='')
  {
    return;
  }
  conexion1=crearXMLHttpRequest();
  conexion1.onreadystatechange = procesarEventos;
  conexion1.open("GET", url, true);
  conexion1.send(null);
}

function procesarEventos()
{
  var detalles = document.getElementById("cha");
  if(conexion1.readyState == 4)
  {
    detalles.innerHTML = conexion1.responseText;
  } 
  else 
  {
    detalles.innerHTML = 'Cargando...';
  }
}

//***************************************
//Funciones comunes a todos los problemas
//***************************************
function addEvent(elemento,nomevento,funcion,captura)
{
  if (elemento.attachEvent)
  {
    elemento.attachEvent('on'+nomevento,funcion);
    return true;
  }
  else  
    if (elemento.addEventListener)
    {
      elemento.addEventListener(nomevento,funcion,captura);
      return true;
    }
    else
      return false;
}

function crearXMLHttpRequest() 
{
  var xmlHttp=null;
  if (window.ActiveXObject) 
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  else 
    if (window.XMLHttpRequest) 
      xmlHttp = new XMLHttpRequest();
  return xmlHttp;
} 
 
 function puting_mode(url,lugar) {

      http_request = false;
	  //document.form1.timer.value=0;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // Ver nota sobre esta linea al final
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
				
                    http_request = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Falla :( No es posible crear una instancia XMLHTTP');
			
            return false;
        }
        http_request.onreadystatechange = function(){
			
			
			  if (http_request.readyState == 4) {
            if (http_request.status == 200) {
			   escribirme(lugar,http_request.responseText);
            }
			else {
                alert('Hubo problemas con la petición...');
            }
        }
		
		else{
			escribirme(lugar,"Cargando datos ...");
			}
			};
        http_request.open('GET', url, true);
        http_request.send(null);

    }
	function escribirme(lugar,valor){
		target = document.getElementById(lugar);
			   target.innerHTML = valor; 
			   //http_request.responseText;
		}
		
		function showme(cuales){
	var settings = new Array();
	var showing	 = new Array();
	settings = cuales.split(",");
	for(a=0;a<settings.length;a++){
		showing = settings[a].split(":");
		if(showing[1]==0) dis = "none";
		else 		   dis = "";
		
		target = document.getElementById(showing[0]);
		target.style.display=dis;
		
	}
		
	
}
function asignature(valor,campo,caser,sector){
	target = document.getElementById(campo);
	if(caser==false){
		target.value = target.value.replace("'"+valor+"',","");
		aaa = "id_"+valor;
		document.getElementById(aaa).style.background = "#FFFFFF";
		
	}
	else{
		target.value = "'"+valor+"',"+target.value;
		aaa = "id_"+valor;
		document.getElementById(aaa).style.background = "#ABD7F1";
		
	}

}

function chekeo(arrayers){
//	cosa = new Array();
	cosa = arrayers.split(",");
	for(a=0;a<cosa.length;a++){
			
			campus = cosa[a];
			if(document.form1[campus].checked ==false)
			document.form1[campus].click();
		}
	}
function horas(valuarte,campo){
		cora = document.form1[campo].value.split(":");
		newval = valuarte+":"+cora[1];
		document.form1[campo].value= newval;
	}
function minutos(valuarte,campo){
		cora = document.form1[campo].value.split(":");
		newval = cora[0]+":"+valuarte;
		document.form1[campo].value= newval;
	}

function reloj(){
	if(document.capa) {
	document.capa.segundos.value++;
	setTimeout("reloj()",1000);
	var sax = document.capa.segundos.value; 
	switch(sax){
		case '1': 
			showme("laps:1,telecom:0,lcdtv:0");
		break;
		case '7':
			showme("laps:0,telecom:1,lcdtv:0");
		break;
		case '14':
			showme("laps:0,telecom:0,lcdtv:1");
		break;
		case '21':
			document.capa.segundos.value='1';
			showme("laps:1,telecom:0,lcdtv:0");
		break;
		}
	}
	
}
function corporativos(){
	
	document.getElementById('contenedor').style.height=document.tupu.cume.value * 4 + 'px';
	if(document.tupu.cume.value<50)
	{
		setTimeout("corporativos()",0.5);
		document.tupu.cume.value++;
	}
}
function pymes(){
	
	if(document.tupu.cume.value > 0){
	setTimeout("pymes()",1);
	document.getElementById('contenedor').style.height=document.tupu.cume.value * 4 + 'px';
	document.tupu.cume.value--;
	}
}


// JavaScript Document