addEvent(window,'load',inicializarEventos,false);

function inicializarEventos() {
	var ob;
	for(f=6;f<=13;f++) {
		ob=document.getElementById('enlace'+f);
		addEvent(ob,'click',presionEnlace,false);
	}
}

function presionEnlace(e) {
	if (window.event) {
		window.event.returnValue=false;
		var url=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("cuerpo");
	if(conexion1.readyState == 4) {
		detalles.innerHTML = conexion1.responseText;
	} else {
		detalles.innerHTML = '<h1>Cargando...</h1>';
	}
}

//*************************************************
//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");
		//xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.5.0");
		//xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	else 
		if (window.XMLHttpRequest) 
			xmlHttp = new XMLHttpRequest();
	return xmlHttp;
}


function validar() {

if (trim(formcv.nombre.value)=='') {
	alert('Debe rellenar el Nombre');
	formcv.nombre.focus();
	formcv.nombre.select();
	return; 
}
if (formcv.tipo.value=='') {
	alert('Debe seleccionar empresa o particular')
	formcv.tipo.focus();
	return; 
}

if (trim(formcv.email.value) == '')
	{
		alert('Debe proporcionar una dirección de e-mail.');
		formcv.email.select();
		formcv.email.focus();
		return;
	} else if (trim(formcv.email.value) != '' && !esEmail(formcv.email.value))
	{
		alert('La dirección de email no es válida. \nDebe proporcionar una dirección de e-mail válida.');
		formcv.email.select();
		formcv.email.focus();
		return;
	}
	
if (trim(formcv.direccion.value) == '')
	{
		alert('Debe proporcionar una dirección física.');
		formcv.direccion.select();
		formcv.direccion.focus();
		return;
	}
	
if (trim(formcv.localidad.value) == '')
	{
		alert('Debe proporcionar la localidad.');
		formcv.localidad.select();
		formcv.localidad.focus();
		return;
	}

if (trim(formcv.provincia.value) == '')
	{
		alert('Debe proporcionar la provincia.');
		formcv.provincia.select();
		formcv.provincia.focus();
		return;
	}
	
if (trim(formcv.pais.value) == '')
	{
		alert('Debe proporcionar el país de desidencia.');
		formcv.pais.select();
		formcv.pais.focus();
		return;
	}

if (trim(formcv.cod_post.value) == '')
	{
		alert('Debe proporcionar un código postal.');
		formcv.cod_post.select();
		formcv.cod_post.focus();
		return;
	}

if (trim(formcv.telefono.value) == '')
	{
		alert('Debe proporcionar un número de teléfono para contactarle.');
		formcv.telefono.select();
		formcv.telefono.focus();
		return;
	}

if (trim(formcv.mensajero.value) == '')
	{
		alert('Debe proporcionar un el sistema de mensajería intantánea que utiliza.');
		formcv.mensajero.select();
		formcv.mensajero.focus();
		return;
	}

if (trim(formcv.conocimientos.value) == ""  || formcv.mensajero.lenght >= 1800)
	{
		alert('Denos una breve descripción de sus conocimientos y experiencias.\n Hasta 1800 caracteres');
		formcv.conocimientos.select();
		formcv.conocimientos.focus();
		return;
	}

if (trim(formcv.idiomas.value) == ""  || formcv.idiomas.value.lenght >= 100)
	{
		alert('Liste los idiomas que maneja (incluido el materno).\n Hasta 100 caracteres');
		formcv.idiomas.focus();
		return;
	}

if (trim(formcv.herramientas.value) == "" || formcv.herramientas.value.lenght >= 900)
	{
		alert('Denos un breve listado de las herramientas que domina.\n Hasta 900 caracteres');
		formcv.herramientas.focus();
		return;
	}
	
if (formcv.programacion.value.lenght >= 1800)
	{
		alert('El listado de lenguajes de programación que maneja no debe superar los 900 caracteres');
		formcv.programacion.focus();
		return;
	}

	//formcv.submit()
}


function esEmail(s)
{
	s = '' + s;
   var r, re;
   re = /^[a-zA-Z0-9\._-]+@[a-zA-Z0-9\._-]+\.[a-zA-Z0-9_]+$/g;
   r = s.match(re);
   return (r != null);
}
function trim(s){return s.replace(/(^\s*)|(\s*$)/g, '');}

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
