// JavaScript Document
  var xmlhttp;
  var url;
  var ACTION2;
  function AJAX( ACTION, OPT)  
  {
	ACTION2	=	ACTION;

	switch(ACTION)
	{
		case	1	:	

			url		=	( "../f_shared/pcs.status.online.php?opt="+OPT+"&clave="+document.getElementById("clave").value+"&CMD=1&"+ Math.random() );
			break;

		case	2	:	

			url		=	( "../f_shared/admin.ven2.php?opt="+OPT+"&CMD=2&"+ Math.random() );
			break;

		case	3	:	

			url		=	( "../f_shared/admin.ven2.php?opt="+OPT+"&CMD=3&"+ Math.random() );
			break;

   }

	xmlhttp =	null;
	
	if( window.XMLHttpRequest )
	{
			xmlhttp =       new XMLHttpRequest();
	}
	else if ( window.ActiveXObject )
	{
			xmlhttp =       new ActiveXObject("Microsoft.XMLHTTP");
	}
	if ( xmlhttp != null )
	{
			xmlhttp.onreadystatechange      =       state_Change;
			xmlhttp.open( "GET" , url , true );
			xmlhttp.send( null );
	}
	else
	{
			alert("Your browser does not support XMLHTTP.");
	}

  }
  
  
function state_Change()
{
        if (xmlhttp.readyState==4)
        {
			if (xmlhttp.status==200)
        	{
				strResponse 	= xmlhttp.responseText;
				strCadena  		= strResponse.split('@');

				switch(ACTION2)
				{
					case	1:	
							switch(strCadena[0]){
			
								case "1":
									document.getElementById('tbl_proceso').style.display = 'none';	
									document.getElementById('tbl_msj_sistema').style.display = 'block';																				
									document.getElementById("div_msj").innerHTML = strCadena[1];																	

								break;

								case "2":
									document.getElementById('tbl_proceso').style.display = 'none';		
									document.getElementById('tbl_msj_sistema').style.display = 'block';											
									document.getElementById("div_msj").innerHTML = strCadena[1];																	

								break;
								
								case "3":
									document.getElementById('tbl_proceso').style.display = 'none';		
									window.location = strCadena[1];
								break;								


							}
					break;							
					
					case 2:
							window.location = strCadena[1];
							return;
					break;
					
					case	3:	
							switch(strCadena[0]){
			
								case "1":

									document.getElementById("div_result").innerHTML = strCadena[1];																	

								break;

							}
					break;						
				}
        	}
            else
        	{
				if( xmlhttp.responseText == '')
				{
					alert('Error A215.');
				}
				else
				{
					alert('Error A216');
				}
        	}
        }
}
function valida_clave(){if(document.getElementById("clave").value != ''){
	document.getElementById('tbl_proceso').style.display = 'block';		
	AJAX( 1, 1);}else{	alert('Debe proporcionar la clave de rastreo.');}}
function fileimport()
{
	if( document.getElementById('file').value != '' ){
		process( 1 );
		document.FORM_Import.submit();
	}
	else
	{
		alert('Debe seleccionar la Carta de Instrucciones.');
	}
}
function process( ACTION )
{
	switch( ACTION )
	{
		case	0	:	
					
					document.getElementById("tbl_proceso").style.display	=	'none';
					document.getElementById("tbl_msj_sistema").style.display	=	'none';					
					
					break;
					
		case	1	:	
		
					document.getElementById("tbl_proceso").style.display	=	'block';
					document.getElementById("tbl_msj_sistema").style.display	=	'block';										
					break;
	}
}

