// JavaScript Document
function sTextoEspacio(sObjeto){
	if(sObjeto.value==" ") sObjeto.value = "";
}
function sTextoUpload(sValue){
	return sValue.substr(sValue.lastIndexOf("\\")+1);
}
function sMuestra( sBlock , sNone ) {
	
	if(sBlock != null && typeof(sBlock) == 'object' )
		for(i=0;i<sBlock.length;i++) document.getElementById(sBlock[i]).style.display = "block";
	else if(sBlock != null && typeof(sBlock) == 'string' )
		document.getElementById(sBlock).style.display = "block";

	if(sNone != null && typeof(sNone) == 'object' )
		for(i=0;i<sNone.length;i++) document.getElementById(sNone[i]).style.display = "none";
	else if(sNone != null && typeof(sNone) == 'string' ) 
		document.getElementById(sNone).style.display = "block";

}
var sOtherA = null;
var sOtherB = null;
function sMuestraOther( sBlockA , sBlockB ) {
	
	document.getElementById(sBlockA).style.display = "block";
	document.getElementById(sBlockB).style.display = "block";

	if(sOtherA != null){
		document.getElementById(sOtherA).style.display = "none";
		document.getElementById(sOtherB).style.display = "none";
	}
	
	if(sOtherA!=sBlockA){
		sOtherA = sBlockA; 
		sOtherB = sBlockB; 
	} else {
		sOtherA = null;
		sOtherB = null;
	}
	
}
function sMuestraForm( sObjeto , sPropiedad ) {
	document.getElementById(sObjeto).style.display = sPropiedad;
}
// Para validar FECHAS
function sDigito(valor){
	var sCod = valor.charCodeAt(0);
	return ((sCod > 47) && (sCod < 58));
}
function valSep(valor){
	var bOk = false;
	bOk = bOk || ((valor.charAt(2) == "-") && (valor.charAt(5) == "-"));
	bOk = bOk || ((valor.charAt(2) == "/") && (valor.charAt(5) == "/"));
	return bOk;
}
function finMes(valor){
	var nMes = parseInt(valor.substr(3, 2), 10);
	var nRes = 0;
	switch (nMes){
		case 1: nRes = 31; break;
		case 2: nRes = 29; break;
		case 3: nRes = 31; break;
		case 4: nRes = 30; break;
		case 5: nRes = 31; break;
		case 6: nRes = 30; break;
		case 7: nRes = 31; break;
		case 8: nRes = 31; break;
		case 9: nRes = 30; break;
		case 10: nRes = 31; break;
		case 11: nRes = 30; break;
		case 12: nRes = 31; break;
	}
	return nRes;
}
function valDia(valor){
	var bOk = false;
	var nDia = parseInt(valor.substr(0, 2), 10);
	bOk = bOk || ((nDia >= 1) && (nDia <= finMes(valor)));
	return bOk;
}
function valMes(valor){
	var bOk = false;
	var nMes = parseInt(valor.substr(3, 2), 10);
	bOk = bOk || ((nMes >= 1) && (nMes <= 12));
	return bOk;
}
function valAno(valor){
	var bOk = true;
	var nAno = valor.substr(6);
	bOk = bOk && (nAno.length == 4);
	if (bOk){
		for (var i = 0; i < nAno.length; i++){
			bOk = bOk && sDigito(nAno.charAt(i));
		}
	}
	return bOk;
}
function valFecha(valor){
	var bOk = true;
	if (valor.value != ""){
		bOk = bOk && (valAno(valor));
		bOk = bOk && (valMes(valor));
		bOk = bOk && (valDia(valor));
		bOk = bOk && (valSep(valor));
	}
	return bOk;
}

// Para validar correos
function sValidaCorreo( objeto , valor ) {
	if( valor ) var s = valor;
	else var s = objeto.value;
	var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	if ( filter.test(s) ) {
		return true;
	} else {
		return false;
		if( !valor ) s.focus();
	}
}
function imprimir(nombre, titulo){
	var ficha = document.getElementById(nombre);
	var ventimp = window.open(' ', 'popimpr', 'toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=544,height=400,left=0,top=0' );
	ventimp.document.write( '<html>' );
	ventimp.document.write( '<head>' );
	ventimp.document.write( '<title>' + titulo + '</title>' );
	ventimp.document.write( '<link rel="stylesheet" type="text/css" href="estilos.css" media="all">' );
	ventimp.document.write( '</head>' );
	ventimp.document.write( '<body style="background-color:#FFF;background-imagen:none;">' );
	ventimp.document.write( ficha.innerHTML );
	ventimp.document.write( '</body>' );
	ventimp.document.write( '</hmtl>' );
	ventimp.document.close();
	ventimp.print( );
	ventimp.close();
}
function abrir(sURL,sTitulo){
	window.open(sURL, 'ventana', 'toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,width=544,height=400,left=0,top=0' );
}

function ValidaUsu()
{
	var opciones;

    opciones = "scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width=770,height=530,top=0,left=0";
    if(window.Event.keycode == 13)
    {
      window.open ("","InfolexNet",opciones);
      self.document.forms("form1").submit;
    }
}
  
function AbreInfolex()
{
    var opciones;
    opciones = "scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width=770,height=530,top=0,left=0";
    window.open ("","InfolexNet",opciones);
    return true;
}
