//////////////////////////////////////////////////////////////////////////////////////////
// Este script de desarrollo, ha sido codificado por  Lucio H. Mora Horta, 				//
// lucio.mora@keyword.net.co. Usted asume el riesgo  al modificarlo. Está 				//
// prohibida, su reproducción total o parcial,distribución a un tercero, o 				//
// cualquier otra situación relacionada, sin autorización expresa del 					//
// implementador y siempre con sujeción a lo dispuesto en el Setup Licence. 			//
// ninguna persona está autorizada a modificar, eliminar o suprimir parte o   			//
// totalmente la glosa de implementación que está leyendo. En caso contrario  			//
// se constituirá  una conducta que atenta flagrantemente contra el derecho de			//
// autor. Tal conducta será perseguida penalmente e interpuestas las demás    			//
// acciones conducentes a resarcir los daños que se ocasionen							//
//																						//
// Si desea más información envie un correo a info@keyword.net.co o visite la			//
// web http://www.keyword.net.co.	KeyWord e-Factory Ltda.								//
//  "The first e-online assembly solution"             									//
//////////////////////////////////////////////////////////////////////////////////////////

//Primera Función AJAX
function XHConn()
{
	var xmlhttp, bComplete = false;
  	try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  	catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  	catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  	catch (e) { xmlhttp = false; }}}
  	if (!xmlhttp) return null;
  	this.connect = function(sURL, sMethod, sVars, fnDone)
  	{
    	if (!xmlhttp) return false;
    	bComplete = false;
    	sMethod = sMethod.toUpperCase();

	try
	{
     		if (sMethod == "GET")
      		{
        		xmlhttp.open(sMethod, sURL+"?"+sVars, true);
       			sVars = "";
      		}
      		else
      		{
		        xmlhttp.open(sMethod, sURL, true);
		        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
		        xmlhttp.setRequestHeader("Content-Type",
		          "application/x-www-form-urlencoded");
      		}
      		xmlhttp.onreadystatechange = function()
      		{
        		if (xmlhttp.readyState == 4 && !bComplete)
        		{
          			bComplete = true;
          			fnDone(xmlhttp);
        		}
        	};
      		xmlhttp.send(sVars);
    	}
    	catch(z)
    	{
    		return false; 
    	}
    	return true;
  	};
	return this;
}

//Segunda Función AJAX
var ajaxdestination="";
function getdata(what,where)
{ 
	try
	{
		xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
		new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch (e) 
	{ 
		/* do nothing */ 
	}

	//document.getElementById(where).innerHTML = "<CENTER><IMG src='../../resources/images/kwajax.gif'></CENTER>";
 	ajaxdestination=where;
 	xmlhttp.onreadystatechange = triggered;
 	xmlhttp.open("GET", what);
 	xmlhttp.send(null);
  	return false;
}

function triggered()
{ 
	if (xmlhttp.readyState == 4)
	if (xmlhttp.status == 200)
	document.getElementById(ajaxdestination).innerHTML = xmlhttp.responseText;
}

//Tercera Función Ajax
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;
}

//Función Ajax para Contáctenos
function enviarContacto()
{
	var c1, c2, c3, c4, c5, c6, idioma, contenedor;
	contenedor = document.getElementById('contenidodinamico');
	c1 = document.getElementById('remitente').value;
	c2 = document.getElementById('empresa').value;
	c3 = document.getElementById('direccion').value;
	c4 = document.getElementById('telefono').value;
	c5 = document.getElementById('email').value;
	c6 = document.getElementById('comentarios').value;
	idioma = document.getElementById('idioma').value;
	ajax=nuevoAjax();	
	ajax.open("GET", "pubcontactenos.kwe?c1="+c1+"&c2="+c2+"&c3="+c3+"&c4="+c4+"&c5="+c5+"&c6="+c6+"&idioma="+idioma,true);
	ajax.onreadystatechange=function() 
	{
		if (ajax.readyState==4) 
		{
			contenedor.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)
}


//Función Ajax para Enviar Hoja de Vida
function enviarHojaVida()
{
	var h1, h2, h3, h4, h5, h6, h7, idioma, contenedor;
	contenedor = document.getElementById('contenidodinamico');
	h1 = document.getElementById('fechapresentacion').value;
	h2 = document.getElementById('numeroproceso').value;
	h3 = document.getElementById('aspirante').value;
	h4 = document.getElementById('codigotipoidentificacionoperario').value;
	h5 = document.getElementById('numeroidentificacion').value;
	h6 = document.getElementById('archivo').value;
	h7 = document.getElementById('comentarios').value;
	idioma = document.getElementById('idioma').value;
	ajax=nuevoAjax();	
	ajax.open("GET", "pubkwcurriculum.kwe?h1="+h1+"&h2="+h2+"&h3="+h3+"&h4="+h4+"&h5="+h5+"&h6="+h6+"&h7="+h7+"&idioma="+Base64.encode(idioma),true);
	ajax.onreadystatechange=function() 
	{
		if (ajax.readyState==4) 
		{
			contenedor.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)
}

//Función Ajax para Comentario en Hoja de Vida
function enviarComentarioHojaVida()
{
	var c1, c2, c3, c4, c5, c6, idioma, contenedor;
	contenedor = document.getElementById('contenidodinamico');
	c1 = document.getElementById('remitente').value;
	c2 = document.getElementById('empresa').value;
	c3 = document.getElementById('direccion').value;
	c4 = document.getElementById('telefono').value;
	c5 = document.getElementById('email').value;
	c6 = document.getElementById('comentarios').value;
	idioma = document.getElementById('idioma').value;
	ajax=nuevoAjax();	
	ajax.open("GET", "pubkwvistabolsaempleosaspirantes.kwe?c1="+c1+"&c2="+c2+"&c3="+c3+"&c4="+c4+"&c5="+c5+"&c6="+c6+"&idioma="+Base64.encode(idioma),true);
	ajax.onreadystatechange=function() 
	{
		if (ajax.readyState==4) 
		{
			contenedor.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)
}


//Función Ajax para Informativa Externa
function enviarInformativaExterna()
{
	var f1, idioma, contenedor;
	contenedor = document.getElementById('contenidodinamico');
	f1 = document.getElementById('annio').value;
	idioma = document.getElementById('idioma').value;
	ajax=nuevoAjax();	
	ajax.open("GET", "vistainformativaexterna.kwe?f1="+f1+"&idioma="+idioma,true);
	ajax.onreadystatechange=function() 
	{
		if (ajax.readyState==4) 
		{
			contenedor.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)
}

//Función Ajax para Normativa Externa
function enviarNormativaExterna()
{
	var f1, idioma, contenedor;
	contenedor = document.getElementById('contenidodinamico');
	f1 = document.getElementById('annio').value;
	idioma = document.getElementById('idioma').value;
	ajax=nuevoAjax();	
	ajax.open("GET", "vistanormativaexterna.kwe?f1="+f1+"&idioma="+idioma,true);
	ajax.onreadystatechange=function() 
	{
		if (ajax.readyState==4) 
		{
			contenedor.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)
}

//Función Validar Nombre y Clave Intemediario
function validarNombreClaveIntermediario()
{
	var nombre, clave, idioma, contenedor;
	contenedor = document.getElementById('contenidodinamico');
	nombre=document.getElementById('user').value;
	clave=document.getElementById('password').value;	
	idioma=document.getElementById('idioma').value;
	ajax=nuevoAjax();	
	ajax.open("GET", "login.kwe?&idioma="+Base64.encode(idioma)+"&user="+Base64.encode(nombre)+"&password="+Base64.encode(clave)+"&target="+Base64.encode('1')+"&loginclass="+Base64.encode('1')+"&options="+Base64.encode('0'),true);
	ajax.onreadystatechange=function() 
	{
		if (ajax.readyState==4) 
		{
			contenedor.innerHTML = ajax.responseText;			
		}
	}
	ajax.send(null)
}

//Función Validar Nombre y Clave Usuario
function validarNombreClaveOperario()
{
	var nombre, clave, idioma, contenedor;
	contenedor = document.getElementById('contenidodinamico');
	nombre=document.getElementById('user').value;
	clave=document.getElementById('password').value;	
	idioma=document.getElementById('idioma').value;
	ajax=nuevoAjax();	
	ajax.open("GET", "./login.kwe?&idioma="+Base64.encode(idioma)+"&user="+Base64.encode(nombre)+"&password="+Base64.encode(clave)+"&target="+Base64.encode('5')+"&loginclass="+Base64.encode('5')+"&options="+Base64.encode('0'),true);
	ajax.onreadystatechange=function() 
	{
		if (ajax.readyState==4) 
		{
			contenedor.innerHTML = ajax.responseText;			
		}
	}
	ajax.send(null)
}

//Función Publicidad
function bloquearPublicidad()
{
	var publicidad, idioma, contenedor;
	idioma=document.getElementById('idioma').value;
	contenedor = document.getElementById('principal');
	ajax=nuevoAjax();	
	ajax.open("GET", "./index.kwe?&idioma="+idioma+"&estadopublicidad=0",true);
	ajax.onreadystatechange=function() 
	{
		if (ajax.readyState==4) 
		{
			contenedor.innerHTML = ajax.responseText;			
		}
	}
	ajax.send(null)
}

//Función Validar Nombre y Clave Intemediario
function activarAcceso()
{
	if(document.frm.aceptarcondiciones.checked==true)
  	{
   		document.getElementById('abriracceso').disabled=false;	
  	}
  	if(document.frm.aceptarcondiciones.checked==false)
  	{
  		document.getElementById('abriracceso').disabled=true;	    	
  	}

}

function accederIntermediario()
{
	var nombre, clave, idioma,
	nombre=document.getElementById('user').value;
	clave=document.getElementById('password').value;
	idioma=document.getElementById('idioma').value;	
	//alert('Intermediarios');
	window.open("controlaccesointermediarios.kwe?&idioma="+Base64.encode(idioma)+"&user="+Base64.encode(nombre)+"&password="+clave+"&options="+Base64.encode('0')+"&open="+Base64.encode('1'),'_top');
	
}

function accederUsuario()
{
	var nombre, clave, idioma,
	nombre=document.getElementById('user').value;
	clave=document.getElementById('password').value;
	idioma=document.getElementById('idioma').value;	
	window.open("controlaccesousuarios.kwe?&idioma="+Base64.encode(idioma)+"&user="+Base64.encode(nombre)+"&password="+clave+"&options="+Base64.encode('0')+"&open="+Base64.encode('1'),'_top');
	
}


function votarEncuesta()
{
	var nur, respondido, contenedor;
	nur=document.getElementById('numerounicoregistro').value;
	respondido=document.getElementById('respondido').value;
	contenedor=document.getElementById('resultados');
	ajax=nuevoAjax();
	ajax.open("GET", "verencuesta.kwe?nur="+nur+"&respondido="+respondido,true);
	ajax.onreadystatechange=function() 
	{
		if (ajax.readyState==4) 
		{
			contenedor.innerHTML = ajax.responseText
	 	}
	}
	ajax.send(null);
}

