var OpacidadInicial=0;

function MostrarTexto(TextoAMostrar){
  if (!document.getElementById)
  return
  textcontainerobj=document.getElementById("DescripcionLink")
  browserdetect=textcontainerobj.filters? "ie" : typeof textcontainerobj.style.MozOpacity=="string"? "mozilla" : ""
  instantset(OpacidadInicial)
  document.getElementById("DescripcionLink").innerHTML=TextoAMostrar
  highlighting=setInterval("gradualfade(textcontainerobj)",70)
}

function OcultarTexto(){
  LimpiarTiempo()
  instantset(OpacidadInicial)
}

function instantset(degree){
  if (browserdetect=="mozilla")
  textcontainerobj.style.MozOpacity=degree/100
  else if (browserdetect=="ie")
	  textcontainerobj.filters.alpha.opacity=degree
  else if (document.getElementById && OpacidadInicial==0)
	  document.getElementById("DescripcionLink").innerHTML=""
}
function LimpiarTiempo(){
  if (window.highlighting) clearInterval(highlighting)
}

function gradualfade(cur2){
  if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
	  cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.2, 0.99)
  else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
	  cur2.filters.alpha.opacity+=5
  else if (window.highlighting)
	clearInterval(highlighting)
}

function concatenarValores(form){
    var cadena='';
	for ( var i = 0; i < document.forms[form].elements.length; i++ ) {
		if (document.forms[form].elements[i].type != 'submit'){
			cadena = cadena + document.forms[form].elements[i].name+'='+document.forms[form].elements[i].value+'&amp;';
		}
	}
	cadena = cadena.substring(0,cadena.length-5);
	return cadena;
}

function crearAjax(){
	var objetoAjax=false;
	try {
		objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			objetoAjax = false;
		}
	}

	if (!objetoAjax && typeof XMLHttpRequest!='undefined') {
		objetoAjax = new XMLHttpRequest();
	}
	return objetoAjax;
} // end function

function loginByAjax(url, valores) {
	var ajax=crearAjax();
	var mensaje = document.getElementById('mensaje');

   	ajax.open ('POST', url, true);
    ajax.onreadystatechange = function() {
   	if (ajax.readyState==1) {
       	mensaje.innerHTML="Por favor espere...";
		mensaje.style.color="#000000";
	} else if (ajax.readyState==4){
		if(ajax.status==200) {
			//mensaje.innerHTML=ajax.responseText; 
			if (ajax.responseText == 'true'){
				document.location.href='micuenta.php';
			} else {
				mensaje.innerHTML='<strong>Error al intentar iniciar sesión.</strong><br>Por favor revise su nombre de usuario y contraseña.'; 
				mensaje.style.color = '#FF0000';
			}
		} else if(ajax.status==404) {
			mensaje.innerHTML = "La direccion existe";
		} else {
			mensaje.innerHTML = "Error: ".ajax.status;
			}
		}
	}
   	ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	ajax.send(valores);
   	return;
}
