function traerPagina(sPagina, sActualizada) {
	var sResp;
	var oXmlHttp;
	var str;
	
	oXmlHttp = false;
	
   //CREO EL OBJETO PARA HACER EL REQUEST
    if(window.ActiveXObject) {
       	try {
       		// Internet Explorer
        	oXmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		oXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		oXmlHttp = false;
        	}
		}
    } else if(window.XMLHttpRequest) {
		// Otros navegadores
    	try {
			oXmlHttp = new XMLHttpRequest();
        } catch(e) {
			oXmlHttp = false;
		}
    } 

    //PROCESO LA RESPUESTA '/new'+
	if (oXmlHttp) {
		str = '';
		if (sPagina.indexOf('?')<0){
			sPagina = sPagina+'?';
		} 
		if (sActualizada=="S"){
			oXmlHttp.open('GET', sPagina+'&pasacache='+ new Date().getTime()+'&llamadaLocal=S', false);		
		} else {
			oXmlHttp.open('GET', sPagina+'&llamadaLocal=S', false);			
		}
		oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); 
		oXmlHttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
		oXmlHttp.setRequestHeader("Content-Length", str.length); 
		oXmlHttp.send(str); 
		
		sResp = oXmlHttp.responseText;
				
		if (sResp.substring(0, 6) == 'ERROR:'){
			alert(sResp);
			return 'ERROR';
		}
		else {
			return sResp;
		}
	}
	else {
		Alert('Connection error');
		return 'ERROR';
	}
	
}

function cargarPagina(sPagina, sActualizada){
	var sCadena;
	sCadena = traerPagina(sPagina, sActualizada);
	document.getElementById('mainWindow').innerHTML = sCadena;
}

function cargarHeader(sPagina){
	var sCadena;
	sCadena = traerPagina(sPagina);
	document.getElementById('headerWindow').innerHTML = sCadena;
}

function EnviarEmail(sNombre,sApellido,sEmpresa,sCargo,sEmail,sDir,sLoc,sPais,sTel,sFax,sSector,sInteresado,sNosConocio,sConsulta,sMotivo){
	if ( sNombre == "" ){
	  alert("El campo NOMBRE es requerido.");
	  return;
	}
	if ( sApellido == "" ){
	  alert("El campo APELLIDO es requerido.");
	  return;
	}
	if ( sEmpresa == "" ){
	  alert("El campo EMPRESA es requerido.");
	  return;
	}
	if ( sEmail == "" ){
	  alert("El campo EMAIL es requerido.");
	  return;
	}
	if ( sPais == "" ){
	  alert("El campo PAIS es requerido.");
	  return;
	}
	if ( sInteresado == "" ){
	  alert("El campo INTERESADO EN es requerido.");
	  return;
	}
	if (sMotivo == "C") {
		if ( sConsulta == "" ){
		  alert("El campo CONSULTA es requerido.");
		  return;
		}
	}
	cargarPagina("/php/emailsend.php?nom=" + sNombre + "&ape=" + sApellido + "&emp=" + sEmpresa + "&car=" + sCargo + "&email=" + sEmail + "&dir=" + sDir + "&loc=" + sLoc + "&pais=" + sPais + "&tel=" + sTel + "&fax=" + sFax + "&sector=" + sSector + "&int=" + sInteresado +"&nc=" + sNosConocio + "&cs=" + sConsulta + "&motivo=" + sMotivo);
	return;
}

function Registrar(sNick,sEmail,sPwd,sPwd2,sNombre,sApellido,sEmpresa,sCargo,sDir,sPais,sTel,sFax,sSector,sInteresado,sNosConocio){
	if ( sNick == "" ){
	  alert("El campo NICK es requerido.");
	  return;
	}
	if ( sEmail == "" ){
	  alert("El campo EMAIL es requerido.");
	  return;
	}
	if ( sPwd == "" ){
	  alert("El campo CLAVE es requerido.");
	  return;
	}
	if ( sPwd != sPwd2 ){
	  alert("Las CLAVES indicadas deben ser iguales.");
	  return;
	}
	if ( sNombre == "" ){
	  alert("El campo NOMBRE es requerido.");
	  return;
	}
	if ( sNombre == "" ){
	  alert("El campo NOMBRE es requerido.");
	  return;
	}
	if ( sApellido == "" ){
	  alert("El campo APELLIDO es requerido.");
	  return;
	}
	if ( sEmpresa == "" ){
	  alert("El campo EMPRESA es requerido.");
	  return;
	}
	if ( sCargo == "" ){
	  alert("El campo CARGO es requerido.");
	  return;
	}
	if ( sDir == "" ){
	  alert("El campo DIRECCION es requerido.");
	  return;
	}
	if ( sPais == "" ){
	  alert("El campo PAIS es requerido.");
	  return;
	}
	if ( sTel == "" ){
	  alert("El campo TELEFONO es requerido.");
	  return;
	}
	if ( sNosConocio == "" ){
	  alert("El campo NOS CONOCIO es requerido.");
	  return;
	}

	document.RegistroForm.submit();

}

function LogIn(sNick,sPwd){
	if ( sNick == "" ){
	  alert("El campo NICK es requerido.");
	  return;
	}
	if ( sPwd == "" ){
	  alert("El campo CLAVE es requerido.");
	  return;
	}
	document.LoginForm.submit();
}

function popUp(mylink, windowname){
	if (!window.focus) return true;
	var href;
	if (typeof(mylink) == 'string')
	   href=mylink;
	else
	   href=mylink.href;
	window.open(href, windowname, 'width=320,height=240,scrollbars=no');
	return false;
}


