/*Display ID*/

function objetoAjax(){
 var xmlhttp=false;
  try{
   xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  }catch(e){
   try {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   }catch(E){
    xmlhttp = false;
   }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
   xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}

function ShowHide(id) {
    if(document.getElementById(id).style["display"] != "none"){
        document.getElementById(id).style["display"] = "none";
    } else {
        document.getElementById(id).style["display"] = "";
    }
}

function cambiar(ch)
{
	if(ch.checked==true){
		ch.checked==false;
	}else{
		ch.checked==true;
	}
}

function cambiarcorreo(ch){
emailx=document.FormAlerta.emaildestino.value;
	if(ch.checked==true){
		FormAlerta.emaildestino.disabled=false;
		FormAlerta.emaildestino.focus();
	}else{
		FormAlerta.emaildestino.disabled=true;		
		FormAlerta.emaildestino.value=emailx;
	}
}
/*Ocultar Capa*/
	
var ns4 = (document.layers)? true:false
var ie4 = (document.all)? true:false
var ns6=document.getElementById &&! document.all

function ocultamuestracapa(capa){
  if (ns4=="true"){
    if (document.layers[capa].visibility=='show'){document.layers[capa].visibility='hide'; }
   else { document.layers[capa].visibility='show'; }
  }
  else{
    if (document.getElementById(capa).style.visibility=="visible")
        {document.getElementById(capa).style.visibility="hidden"; }
    else { document.getElementById(capa).style.visibility="visible";}
  } // fin del else de ns4
}// fin de la funcion


/****Funcion de Abrir Cerrar***/

function open(){
	document.getElementById('pop').style.display='block';
}
function openinst(){
	document.getElementById('popinst').style.display='block';
}
function close(){
	document.getElementById('pop').style.display='none';
}
function cerrar_aviso(){
	document.getElementById('avison').style.display='none';
}

function isEmailAddress(theElement, nombre_del_elemento )
{
var s = theElement.value;
var filter=/^\w+((-\w+)|(\.\w+))*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
if (s.length == 0 ) return true;
if (filter.test(s))
return true;
else
theElement.focus();
return false;
}

function enviarLog(){
  divResultado = document.getElementById('resultadoform');
  action=document.FormLogin.action.value;
  fr=document.FormLogin.fr.value;
  emailx=document.FormLogin.email.value;
  password=document.FormLogin.password.value;
  if(document.FormLogin.email.value.length!=0){
	rpta=isEmailAddress(document.FormLogin.email,'TextField');
	if(rpta==false){
		document.getElementById('mensajealerta').innerHTML="<div id='errorpopup'>Email incorrecto</div>";
	}else if(document.FormLogin.password.value.length<5){
	  document.getElementById('mensajealerta').innerHTML="<div id='errorpopup'>Por favor ingresa tu contrase&ntilde;a correctamente</div>";
	  }else{
		  ajax=objetoAjax();
		  ajax.open("POST", "logeo.php",true);
		  ajax.onreadystatechange=function() {
			if (ajax.readyState==1){
				 divResultado.innerHTML= '<div align="center"><img src="http://www.cursostotales.com/images/loading.gif"><br /><br />cargando...</div>';
			}
			if (ajax.readyState==4) {
				 divResultado.innerHTML = ajax.responseText
			}
		  }
		  ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		  ajax.send("action="+action+"&fr="+fr+"&email="+emailx+"&password="+password)
	  }			
  }else{
	  document.getElementById('mensajealerta').innerHTML="<div id='errorpopup'>Por favor ingresa tu email...</div>";	
  }
}

//Elimina un aņadir
function removecriterio(obj){
//if (!confirm("Seguro que deseas Eliminar?")) return false;
 var oTr = obj;
 while(oTr.nodeName.toLowerCase()!='tr'){
  oTr=oTr.parentNode;
 }
 var root = oTr.parentNode;
 root.removeChild(oTr);
}

function calcularaltura(){
//calculate height
var the_height=document.getElementById('perfil').contentWindow.document.body.scrollHeight;
//minimal height of 600
if (the_height < 600) {the_height=690}
//change height
document.getElementById('perfil').height=the_height;
}
function resizeIframe(){
document.getElementById('main').height = document.getElementById('main').contentWindow.document.body.scrollHeight;
}

//Agregar a favoritos
//onclick="agregarafavorito()"
function agregarafavorito(){
if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) {
	var url="http://www.cursostotales.com";
	var titulo="Cursostotales.com"; 
	window.external.AddFavorite(url,titulo);
}else {
	if(navigator.appName == "Netscape")
	var url="http://www.cursostotales.com";
	var titulo="Cursostotales.com"; 
	window.sidebar.addPanel(titulo,url,'');
	}
}

//Poner como pagina de inicio
//onclick="set_inicio(this,'http://www.cursostotales.com/')"
function set_inicio(objk,direccion){
    if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>3)){ 
        objk.style.behavior="url(#default#homepage)"; 
        objk.setHomePage(direccion); 
    }else{ 
        alert("Su navegador no permite establecer pagina de inicio"); 
    } 
} 
/****/
