// JavaScript Document

function NuevoAjax(){
        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 Cargar(id){
	var   contenedor;
	contenedor = document.getElementById('opcion_div');
	//t1 = document.getElementById('opcion').value; 
	
	ajax=NuevoAjax();
	ajax.open("POST", "chat_nuevo.php",true);
	ajax.onreadystatechange=function() {
	 if(ajax.readyState==1){
                        contenedor.innerHTML = "Cargando..."; 
					 
                }
				else
		if (ajax.readyState==4) {
			contenedor.innerHTML = ajax.responseText
	 	}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("opcion=" + id)
}


function opcion1()

{

  
  document.forma.empresa.disabled = true; 

}

function opcion2()

{

  
  document.forma.empresa.disabled = false; 
  document.forma.empresa.value = "";

}


function valido() 
{
	var rs1 = document.fractividad.email.value 
	var rs2 = document.fractividad.codidepa.value 
	var rs3 = document.fractividad.solicita.value 
	var rs4 = document.fractividad.titulo.value 
	var rs5 = document.fractividad.solicitud.value 
	
	if (rs1 != "" && rs2 != "00" && rs3 != "" && rs4 != "" && rs5 != "")
	{
		return true; 	 
	}
	else 
	{
		alert("No valido datos en blanco..."); 
		return false;
	}
}

function valido2() 
{
	var rs1 =  document.forma.evaluacion.value 
	var rs2 =  document.forma.observa.value 
	
	if (rs1 != "" && rs2 != "")
	{
		return true; 	 
	}
	else 
	{
		alert("No valido datos en blanco..."); 
		return false;
	}
}

function valido3()
 {

  var numedepo = document.forma.numedepo.value
  var banco = document.forma.banco.value
  var monto = document.forma.monto.value
  var observacion = document.forma.observacion.value 
 
   if (numedepo != "" && banco != "" && monto != "" && observacion != "")
      {
	
	  return true;
	  
	  }
   else 
      {
	  alert("No valido datos en blanco"); 
	  return false;
	  }
 }

function valido6()
 {

  var usuario = document.forma.usuario.value
  var nombres = document.forma.nombres.value
  var apellidos = document.forma.apellidos.value
  var cedula = document.forma.cedula.value
  var email = document.forma.email.value 
  var clave = document.forma.clave.value
  var clave2 = document.forma.clave2.value 
 
   if (usuario != "" && nombres != "" && apellidos != "" && cedula != "" && email != "" && clave != "" && clave2 != "")
      {
		if (clave == clave2)
		{
	  	return true;
	  	}
		else 
		{
		alert("No valido confirmacion de contraseņa"); 
	  	return false;
		}
	  }
   else 
      {
	  alert("No valido datos en blanco"); 
	  return false;
	  }
 }


function valida7()
 {

  var usuario = document.forma.usuario.value
  var nombres = document.forma.nombres.value
  var apellidos = document.forma.apellidos.value
  var cedula = document.forma.cedula.value
  var email = document.forma.email.value 
  var clave = document.forma.clave.value
  var anterior = document.forma.anterior.value 
  var clave1 = document.forma.clave1.value
  var clave2 = document.forma.clave2.value 
 
   if (usuario != "" && nombres != "" && apellidos != "" && cedula != "" && email != "" && anterior != "" && clave1 != "" && clave2 != "")
      {
		if (clave == anterior && clave1 == clave2)
		{
		
	  	return true;
	  	
		}
		else 
		{
		alert("Error: Invalido es contraseņa"); 
	  	return false;
		}
	  }
   else 
      {
	  alert("No valido datos en blanco"); 
	  return false;
	  }
 }

function valido4()
 {

  var anterior = document.forma.anterior.value
  var nuevo = document.forma.nuevo.value
  var confirmacion = document.forma.confirmacion.value
 
   if (anterior != "" && nuevo != "" && confirmacion != "")
      {
	
	  return true;
	  
	  }
   else 
      {
	  alert("No valido datos en blanco"); 
	  return false;
	  }
 }
 
 
function valido5()
 {

  var email = document.forma2.email.value
  var nombre = document.forma2.nombre.value

   if (email != "" && nombre != "")
      {	
	  return true; 
	  }
   else 
      {
	  alert("No valido datos en blanco"); 
	  return false;
	  }
 }

function validacion()
 {

  var empresa = document.forma.empresa.value
  var usuario = document.forma.usuario.value
  var clave = document.forma.clave.value
 
  if (empresa == "")
   {
   if (usuario != "" && clave != "")
      {
	  return true;
	  }
   else 
      {
	  alert("No valido datos en blanco"); 
	  return false;
	  }
  } 
  if (empresa != "")
   {
   if (empresa != "" && usuario != "" && clave != "")
      {
	
	  return true;
	  
	  }
   else 
      {
	  alert("No valido datos en blanco"); 
	  return false;
	  }
 } 
 }
 
 function prevista( )
 {  
	window.open("mensaje.php", "Mensaje", "scrollbars=1,location=0,statusbar=1,status=1,menubar=0,resizable=0,left=200,top=20,width=622,height=600")
 }

function chat()
{
   var wOpen;
   var sOptions;
   window.location = "index.php";
 sOptions = 'status=1,menubar=no,scrollbars=0,resizable=no,toolbar=no';
   sOptions = sOptions + ',width=' + (816).toString();
   sOptions = sOptions + ',height=' + (640).toString();
   sOptions = sOptions + ',screenX=0,screenY=0,left='+ ((screen.availWidth / 2) - 408).toString() +',top='+ ((screen.availHeight / 2) - 320).toString(); 
   wOpen = window.open( '', "Chat", sOptions );
   wOpen.location = "chat_inicio.php";
   wOpen.focus();
//   wOpen.moveTo( 0, 0 );
//   wOpen.resizeTo( screen.availWidth, screen.availHeight );
   
   return wOpen;
}

 function imprimir(numero)
 {  
	window.open("factura.php?id=" + numero, "Imprimir", "scrollbars=1,location=0,statusbar=1,status=1,menubar=1,resizable=0,left=200,top=20,width=622,height=600")
 }

function conta(n,el) {if(document.images){(new Image()).src="conta_dtml?url="+escape(el.href);}return true;}


function cambio()
{

window.location = "nueva_solicitud.php?codidepa=" + document.fractividad.codidepa.value + "&codiclie="+ "<? echo $codiclie; ?>" + "&email="+ document.fractividad.email.value + "&solicita=" + document.fractividad.solicita.value + "&titulo=" + document.fractividad.titulo.value + "&solicitud=" + document.fractividad.solicitud.value + "&file=" + document.fractividad.file.value;

}


function cambio3()
{

window.location = "nueva_solicitud_gp.php?codidepa=" + document.fractividad.codidepa.value + "&codiclie="+ "<? echo $var_cod; ?>" + "&email="+ document.fractividad.email.value + "&solicita=" + document.fractividad.solicita.value + "&titulo=" + document.fractividad.titulo.value + "&solicitud=" + document.fractividad.solicitud.value + "&file=" + document.fractividad.file.value;

}

function cambio2()
{

window.location = "re_solicitud.php?codidepa=" + document.fractividad.codidepa.value + "&numero="+ document.fractividad.numero.value + "&email="+ document.fractividad.email.value + "&solicita=" + document.fractividad.solicita.value + "&titulo=" + document.fractividad.titulo.value + "&solicitud=" + document.fractividad.solicitud.value + "&file=" + document.fractividad.file.value; 
}

function cambio4()
{

window.location = "re_solicitud_gp.php?codidepa=" + document.fractividad.codidepa.value + "&numero="+ document.fractividad.numero.value + "&email="+ document.fractividad.email.value + "&solicita=" + document.fractividad.solicita.value + "&titulo=" + document.fractividad.titulo.value + "&solicitud=" + document.fractividad.solicitud.value + "&file=" + document.fractividad.file.value; 
}

function regresar2()
{
	window.location = "menu.php";
}

function regresar3()
{
	window.location = "menugrupo.php";
}

function regresar4()
{
	window.location = "usuarios_gp.php";
}

// calculate the ASCII code of the given character
function CalcKeyCode(aChar) {
  var character = aChar.substring(0,1);
  var code = aChar.charCodeAt(0);
  return code;
}

function calculo(val) 
{
  var strPass = val.value;
  var strLength = strPass.length;
  var lchar = val.value.charAt((strLength) - 1);
  var cCode = CalcKeyCode(lchar);

  /* Check if the keyed in character is a number
     do you want alphabetic UPPERCASE only ?
     or lower case only just check their respective
     codes and replace the 48 and 57 */
  if (cCode <= 44 || cCode == 47 || cCode > 57) {
    var myNumber = val.value.substring(0, (strLength) - 1);
    val.value = myNumber;
  }
  return false;

}


function Lista(opcion) 
{
	
  sList = window.open("busq_correos.php?codiclie="+opcion, "Buscar", "scrollbars=1,location=0,statusbar=0,status=0,menubar=0,resizable=0,left =180,top = 90,width=650,height=550");
}

function remLink() {
  if (window.sList && window.sList.open && !window.sList.closed)
    window.sList.opener = null;
}
