// JavaScript Document
function getXMLHTTPRequest()
{
var req = false;
try
  {
    req = new XMLHttpRequest(); /* p.e. Firefox */
  }
catch(err1)
  {
  try
    {
     req = new ActiveXObject("Msxml2.XMLHTTP");
  /* algunas versiones IE */
    }
  catch(err2)
    {
    try
      {
       req = new ActiveXObject("Microsoft.XMLHTTP");
  /* algunas versiones IE */
      }
      catch(err3)
        {
         req = false;
        }
    }
  }
return req;
}
var miPeticion = getXMLHTTPRequest();
//*****************************************************************************
//Valida correo
function valida_correo(correo) {
		  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(correo)){
			
		   return (true)
		  } else {
		   
		   return (false);
		  }
		 }
//*************************************************************************************************************************************
//valida n?meros
function valida_numero(numero)
{
if (!/^([0-9])*$/.test(numero)){
		return false;
}else{
		return true;
	}
}

//*************************************************************************************************
//Funci?n para validar direcci?n web
function valida_url() {
	var url=document.enviar.web.value;
var re=/^(http|ftp)(s)?:\/\/\w+(\.\w+)*(-\w+)?\.([a-z]{2,3}|info|mobi|aero|asia|name)(:\d{2,5})?(\/)?((\/).+)?$/;
return re.test(url);
if (!valida_url(url)){
		alert("La direcci?n Web ingresada no es válida");
		document.enviar.web.value="";
	}

}
//*********************************************************************************************
function valida_contacto()
{
		var form=document.form;
		if (form.nom.value==0)
		{
				alert("Debe indicar el nombre");
				form.nom.value="";
				form.nom.focus();
				return false;
		}
		if (form.correo.value==0)
		{
				alert("Debe indicar el E-Mail");
				form.correo.value="";
				form.correo.focus();
				return false;
		}
		if (valida_correo(form.correo.value)==false)
		{
				alert("Debe ingresar un E-Mail correcto");
				form.correo.value="";
				form.correo.focus();
				return false;
		}
		if (form.texto.value==0)
		{
				alert("Debe indicar el mensaje");
				form.texto.value="";
				form.texto.focus();
				return false;
		}
		if (form.verificacion.value !=form.veri.value)
		{
				alert("El codigo de verificacion no es correcto, intente otra vez por favor");
				form.verificacion.value="";
				form.verificacion.focus();
				return false;
		}
		form.url.value=location.href;
		form.submit();	
}
//**************************************************************************************+
//reloj
function muestraReloj()
{
	var navegador = navigator.appName;
		//alert(navegador);
		/*switch (navegador){
		case "Microsoft Internet Explorer":
		//alert("Su navegador es Internet Explorer");
			document.getElementById("reloj").style.marginLeft="750px";
			document.getElementById("reloj").style.marginTop="30px";
		break;
		case "Netscape":
		//alert("Su navegador es Mozilla o Google Chrome");
			document.getElementById("reloj").style.marginLeft="900px";
			document.getElementById("reloj").style.marginTop="30px";
		break;
		}*/
// Compruebo si se puede ejecutar el script en el navegador del usuario
if (!document.layers && !document.all && !document.getElementById) return;
// Obtengo la hora actual y la divido en sus partes
var fechacompleta = new Date();
var horas = fechacompleta.getHours();
var minutos = fechacompleta.getMinutes();
var segundos = fechacompleta.getSeconds();
var mt = "AM";
// Pongo el formato 12 horas
if (horas> 12) {
mt = "PM";
horas = horas - 12;
}
if (horas == 0) horas = 12;
// Pongo minutos y segundos con dos digitos
if (minutos <= 9) minutos = "0" + minutos;
if (segundos <= 9) segundos = "0" + segundos;
// En la variable 'cadenareloj' puedes cambiar los colores y el tipo de fuente
//cadenareloj = "<font size='-1' face='verdana'>" + horas + ":" + minutos + ":" + segundos + " " + mt + "</font>";
cadenareloj =horas + ":" + minutos + ":" + segundos + " " + mt;
// Escribo el reloj de una manera u otra, segun el navegador del usuario
if (document.layers) {
document.layers.spanreloj.document.write(cadenareloj);
document.layers.spanreloj.document.close();
}
else if (document.all) spanreloj.innerHTML = cadenareloj;
else if (document.getElementById) document.getElementById("spanreloj").innerHTML = cadenareloj;
// Ejecuto la funcion con un intervalo de un segundo
setTimeout("muestraReloj()", 1000);
}
 //*********************************************************************************************
 //funci?n para contar_caracteres en un textarea
 function cuenta_caracteres(campo,contador,maxlimite)
		{
		 if (campo.value.length > maxlimite){
		 campo.value = campo.value.substring(0, maxlimite);
		 }
		 else{
		 contador.value = maxlimite - campo.value.length;
		 }
		return true;
} 
 function cuenta_caracteres_2(campo,contador,maxlimite)
		{
		 if (campo.value.length > maxlimite){
		 campo.value = campo.value.substring(0, maxlimite);
		 }
		 else{
			 var numero=maxlimite - campo.value.length;
		 contador.innerHTML ="L&iacute;mite&nbsp;" + numero;
		 }
		return true;
} 
 //**************************************************************************************
 //Finci?n para Comentarios
 function comentarios(id){
	 	var form=document.enviar;
		if (form.nom.value==0)
		{
				alert("Debe indicar el nombre");
				form.nom.value="";
				form.nom.focus();
				return false;
		}
		if (form.correo.value==0)
		{
				alert("Debe indicar el Correo");
				form.correo.value="";
				form.correo.focus();
				return false;
		}
		if (valida_correo(form.correo.value)==false)
		{
				alert("Debe ingresar un correo correcto");
				form.correo.value="";
				form.correo.focus();
				return false;
		}
		if (form.com.value==0)
		{
				alert("Debe indicar el mensaje");
				form.com.value="";
				form.com.focus();
				return false;
		}
		if (form.verificacion.value !=form.veri.value)
		{
				alert("El codigo de verificacion no es correcto, intente otra vez por favor");
				form.verificacion.value="";
				form.verificacion.focus();
				return false;
		}
		form.submit();
}
//*************************************************************************************
function no_copiar()
{
	document.form.verificacion.value="";	
}
//**************************************************************************************
 //Finci?n para Comentarios
 function comentarios_articulos(id){
	 	var nom=document.enviar.nom.value;
		var correo=document.enviar.correo.value;
		var web=document.enviar.web.value;
		var com=document.enviar.com.value;
		if (nom==0){
				alert("Debe Ingresar su nombre");
				document.enviar.nom.value="";
				document.enviar.nom.focus();
			}else{
					var emi=valida_correo(correo);
					if (emi==false || correo==0){
							alert("Debe ingresar una direccion de correo valida");
							document.enviar.correo.value="";
							document.enviar.correo.focus();
						}else{
								if (com==0){
										alert("Debe escribir un comentario");
										document.enviar.com.value="";
										document.enviar.com.focus();
									}else{
											
		var url="comentarios_articulos.php?nom="+nom+"&correo="+correo+"&web="+web+"&com="+com+"&id="+id;
		//alert(url);//alert(id);
		var mi_aleatorio=parseInt(Math.random()*99999999);//para que no guarde la p?gina en el cach?...
		
		miPeticion.open("GET",url+"&rand="+mi_aleatorio,true);//ponemos true para que la petici?n sea asincr?nica
		miPeticion.onreadystatechange=miPeticion.onreadystatechange=function(){
               if (miPeticion.readyState==4)
               {
                       if (miPeticion.status==200)
                       {
                               var http=miPeticion.responseText;
							   //cadena=unescape(http);
							   //cadenafinal=cadena.replace(/\+/gi," ");
							   document.enviar.nom.value="";
							   document.enviar.correo.value="";
							   document.enviar.web.value="";
							   document.enviar.com.value="";
							   document.getElementById("detalle").innerHTML= http;
							   
                       }
               }else{
				   			   document.getElementById("detalle").innerHTML= "<img src='../../ima/ajax.gif' title='cargando....'>";
				   }
       }
       miPeticion.send(null);
	   
										}
							}
				}
}
//****************************************************************************************++
//Funci?n para mostrar y ocultar los men?s del curr?culum
function ocultar(id){
		document.getElementById(id).style.display="none";
	}
function mostrar(id){
		ocultar("uno");
		ocultar("dos");
		ocultar("tres");
		document.getElementById(id).style.display="block";
	}
function posiciona_reloj()
	{
		var navegador = navigator.appName;
		//alert(navegador);
		switch (navegador){
		case "Microsoft Internet Explorer":
		//alert("Su navegador es Internet Explorer");
			document.getElementById("reloj").style.marginLeft="750px";
			document.getElementById("reloj").style.marginTop="30px";
		break;
		case "Netscape":
		//alert("Su navegador es Mozilla o Google Chrome");
			document.getElementById("reloj").style.marginLeft="900px";
			document.getElementById("reloj").style.marginTop="30px";
		break;
		}
	}
//*****************************************************************************************************
function popup(url)
		{
				window.open(url,'window','directories=no,width=550,height=450,hotkeys=no,location=no,menubar=no,personalbar=no,resizable=no,scrollbars=no,status=no,toolbar=no,left=350,top=100')
		}
//**************************************************************************************		
function limpia_formulario()
{
	document.form.reset();
	document.form.nom.focus();
}		
function btn_roll(id,ima)
{
    document.getElementById(id).src=ima;
}
function botones_sidebar(id,ima)
{
	document.getElementById(id).style.backgroundImage=ima;	
}
function limpia_buscar()
{
	document.buscador.s.value="";	
}
//*****************************************************
function comentar()
{
		var form=document.form;
		if (form.nom.value==0)
		{
				alert("Debe indicar el nombre");
				form.nom.value="";
				form.nom.focus();
				return false;
		}
		if (form.correo.value==0)
		{
				alert("Debe indicar el E-Mail");
				form.correo.value="";
				form.correo.focus();
				return false;
		}
		if (valida_correo(form.correo.value)==false)
		{
				alert("Debe ingresar un E-Mail correcto");
				form.correo.value="";
				form.correo.focus();
				return false;
		}
		if (form.texto.value==0)
		{
				alert("Debe indicar el mensaje");
				form.texto.value="";
				form.texto.focus();
				return false;
		}
		if (form.verificacion.value !=form.veri.value)
		{
				alert("El codigo de verificacion no es correcto, intente otra vez por favor");
				form.verificacion.value="";
				form.verificacion.focus();
				return false;
		}
		form.url.value=location.href;
		form.submit();	
}