// JavaScript Document

function inst_exp(xmlhttp)
{   
   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();   
          }   
//alert(xmlhttp);
return xmlhttp;
}


function cargarCombo(cod_edo,cod_cda,cod_mun,id,opt,sta,cod_par)
{   
 // alert (opt);


switch (opt) 
  {
   case 1: //cargar ciudades
        //alert('edo:'+cod_edo+'cda:'+cod_cda+'mun:'+cod_mun);
        ul="php/provee/sql_combo.php?cod_edo=" + cod_edo + "&cod_cda=" + cod_cda + "&opt=" + opt + "&sta=" + sta;
		break;
   case 2: //cargar municios
        ul="php/provee/sql_combo.php?cod_edo=" + cod_edo + "&cod_cda=" + cod_cda + "&cod_mun=" + cod_mun 
		+ "&opt=" + opt + "&sta=" + sta;
		break;
   case 3: //cargar parroquisas
        ul="php/provee/sql_combo.php?cod_edo=" + cod_edo + "&cod_cda=" + cod_cda + "&cod_mun=" + cod_mun  + "&cod_par=" + cod_par 
		+ "&opt=" + opt + "&sta=" + sta;
		break;
   case 4: //cargar actividades
        ul="php/provee/sql_combo.php?cod_obj=" + cod_edo + "&opt=" + opt + "&sta=" + sta;
		break;		
 }

  //document.getElementById('nom_con').value = ul;
  cargarContenido(ul,id) 
 
}


function cargarContenido(pagina,destino)
{   


var contenedor;   
var ajax;      
var num = Math.random(); 
   // pagina = pagina + '&n=' + num;

contenedor = document.getElementById(destino);
ajax = inst_exp(ajax);   
ajax.open("GET", pagina, true);   
ajax.onreadystatechange=function() 
  {
	if (ajax.readyState==4) 
	    {
		//alert(contenedor);
		contenedor.innerHTML = ajax.responseText;      
		}   
  }   

ajax.send(null);
}


function CargarContenido(pagina,destino)
{ 

var contenedor;   
var ajax;      
var num = Math.random(); 
    pagina = pagina + '&n=' + num;

//alert(pagina);
contenedor = document.getElementById(destino);
ajax = inst_exp(ajax);   
ajax.open("GET", pagina, true);   
ajax.onreadystatechange=function() 
  {
	if (ajax.readyState==4) 
	    {
		
		contenedor.innerHTML = ajax.responseText;      
		}   
  }   

ajax.send(null);
	
} 

function CargarContenido2(url,text,destino)
{ 
    var ajax; 									//declaro mi variable 
	ajax = inst_exp(ajax);  	
   
    var contenedor =  document.getElementById(destino); //contenedor de destino
	
    var valor = document.getElementById(text) //el texto de codigo
    var p = valor.value 
	
	var t_url = url+'&'+text+'='+p;  //armo mi url final para pasar parametros
	    ajax.open("GET", t_url, true);   
   		ajax.onreadystatechange=function() 
       {
   	 		if (ajax.readyState==4) 
	        {
 	   			contenedor.innerHTML = ajax.responseText;      
		//contenedor.innerHTML = ajax.pagina;      
			}   
       }   
  		ajax.send(null);
		delete ajax;
	
} 


function armar_url(funcion,pagina,recarga,div) 
{
var e = '';
  for (var a=0; a < document.forms.length; a++) 
  {
  for (var i=0; i < document.forms[a].length; i++) 
   {
    if (document.forms[a].elements[i].type !== "button") 
	  {
      if (document.forms[a].elements[i].type == "checkbox" ) 
	     {
          e = e + '&' + document.forms[a].elements[i].name + '=';
          e = e + document.forms[a].elements[i].checked;
		  }
      else
	      {
		  var linea = document.forms[a].elements[i].value;
          //linea = linea.toUpperCase();     //convierte en mayustula
          linea = linea.replace(/&/g, "~"); //remplaza los ampersan por ~
          linea = linea.replace(/#/g, "^"); //remplaza los ampersan por ~
          e = e + '&' + document.forms[a].elements[i].name + '='+linea;
          }
       }
     }
   }

  var num = Math.random(); 
  url = pagina + e + '&n=' + num;
  //document.getElementById('contenedor').innerHTML=url;
 // document.getElementById('direccion').value=url;
 
 ObtenerDatos(funcion,url,recarga,div) 
// alert(url);
  
}



function armar_url2(funcion,pagina) 
{
var e = '';
  for (var a=0; a < document.forms.length; a++) 
  {
  for (var i=0; i < document.forms[a].length; i++) 
   {
    if (document.forms[a].elements[i].type !== "button") 
	  {
      if (document.forms[a].elements[i].type == "checkbox" ) 
	     {
          e = e + '&' + document.forms[a].elements[i].name + '=';
          e = e + document.forms[a].elements[i].checked;
		  }
      else
	      {
          e = e + '&' + document.forms[a].elements[i].name + '=';
          e = e + document.forms[a].elements[i].value;
          }
       }
     }
   }

  var num = Math.random(); 
  url = pagina + e + '&n=' + num;
  //document.getElementById('observacion').value=url;
  ObtenerPorGETDatosHTML_2(funcion,url) 
  //alert(url);
  
}


function mostrar_datos(datos,recarga,div) 
{
  
  //document.getElementById('nom_con').value=datos;
  //alert(datos);
  a = car(datos); //quita saltos de lineas
  
  b = isNaN(a);
  if (b == false){ a = eval(a); }
  
 //alert(a);
  switch (a) 
  {
   case 0: 
		msj_error(0);
		break;
   case 1: 
  	    msj_error(1);
		//alert(recarga);
		if (recarga != null )
		 { 
		   if (recarga != "" )
		   {
			 CargarContenido(recarga,div); 
		   }
		 }

        if (div == 'reload' )
		  {
		    document.location.reload();
		  }
	   
	    if (recarga != "html/inicio.html")
 		{ 
		   blanquear_form();
		}
		break;
   case 2: 
        msj_error(2);
		break;
   case 3: 
        msj_error(3);
		break;
   case 4: 
        msj_error(4);
		break;			
   case 5: 
        msj_error(5);
		break;
   case 6: 
        msj_error(6);
		break;		
   case 7: 
        msj_error(7);
		break;	
   case 8: 
        msj_error(8);
		break;			
   case 9: 
        msj_error(9);
		break;		
   case 10: 
        msj_error(10);
		break;				
   case 11: 
        msj_error(11);
		break;				
   case 12: 
        msj_error(12);
		break;
	case 20: 
        msj_error(20);
		break;	
	case 21: 
        msj_error(21);
		break;	
		
   default: 
  	    var vec = datos.split('|');
	    a=vec.length;	
	    for (i=1;i < a; i++)
	    {
		 var vec2 = vec[i].split('=');
		 var elemento = document.getElementById(vec2[0]);
		
		switch (vec2[0]) 
        {
            case 'cod_edo':
		      	 var cod_edo =  vec2[1];
			     break;
	        case 'cod_cda':
		         var cod_cda =  vec2[1];
			     break;			
   	        case 'cod_mun':
		         var cod_mun =  vec2[1];
			     break;	
			case 'cod_par':
		         var cod_par =  vec2[1];
			     break;		 
		}
			
		if (elemento != null )
		  {
			elemento.value = vec2[1];
		  }
	    }
		
		//cod_edovalert(cod_edo);
		var element = document.getElementById('cod_edo')
        if(element != null)
		{
		
		//alert('edo:'+cod_edo+'cda:'+cod_cda+'mun:'+cod_mun);
		cargarCombo(cod_edo,cod_cda,cod_mun,'div_cda',1,cod_par)
		cargarCombo(cod_edo,cod_cda,cod_mun,'div_mun',2,cod_par)
		cargarCombo(cod_edo,cod_cda,cod_mun,'div_par',3,cod_par)
		}

  }//end swt
  
}//end fuction



function datos_provee(valor)
{
	var url="php/provee/sql.php?opt=3&cod_pro="+valor;
//	document.getElementById('nro_fact').value=url;

	ObtenerPorGETDatosHTML_2(mostrar_datos,url);
}



function msj_error(valor)
{
  //var opt = document.getElementById('opt').value;
  //alert(valor);
  switch (valor) 
  {
              case 0:
			        alert ("Proceso Denegado");
					break;
			  case 1:
			        alert ("Proceso Satisfactorio");
					break;
			  case 2:
			        alert ("Datos Ya Existen.");
					break;
			  case 3:
			        //alert ("Patente no Valida, Revise.");
					break;
              case 4:
			        alert ("No se encontraron Datos");
					break;						
			  case 5:
			        alert ("El Rif no es Igual al del Usuario");
					break;	
			  case 6:
			        alert ("Fechas Incorrectas");
					break;	
			  case 7:
			        alert ("Limite Exedido");
					break;	
			  case 8:
			        alert ("No ha Incluido una Solicitud");
					break;		
			  case 9: 
			       alert ("Faltan Datos / Valor nulo o Inconsitentes.");
				   break;					
			  case 10: 
			       alert ("Codigo de Proveedor Asignado,Imposible Modificar");
				   break;					
			  case 11: 
			       alert ("Proveedor No existe");
				   break;					
			  case 12: 
			       alert ("Nro de Factura ya existe");
				   break;	
			  case 20: 
			       alert ("Empresa NO puede ser Registrada, Comuniquese con Sistema");
				   break;	
			  case 21: 
			       alert ("Faltan Datos del RNC");
				   break;	   
				   
			  default: 
			       alert ("error no codificado.");
				   break;
  }

}


function car(cadena) 
{
 var texto="";	
  for (var i=0; i < cadena.length; i++) 
  {
   if (cadena.charAt(i)!="\n")
   {
     texto = texto + cadena.charAt(i);
   }
  }
  return texto;
}

function blanquear_form() 
{
  for (var a=0; a < document.forms.length; a++) 
  {
  for (var i=0; i < document.forms[a].length; i++) 
   {
    if (document.forms[a].elements[i].type !== "button") 
	  {
      if (document.forms[a].elements[i].name != "opt" ) 
	     {  
		   document.forms[a].elements[i].value="";     
		 }
      }
   }
 }
}

function blanquear_form2(a) 
{
   for (var i=0; i < document.forms[a].length; i++) 
   {
    if (document.forms[a].elements[i].type !== "button") 
	  {
      if (document.forms[a].elements[i].name != "opt" ) 
	     {  
		   document.forms[a].elements[i].value="";     
		 }
      }
   }
 
}



function openw(pagina)
{
	var url=pagina;
window.open(url,null,"height=250,width=350,status=yes,toolbar=no,menubar=no,location=no,left=200,top=300");
}

function windows(pagina)
{
	var url=pagina;
window.open(url,null);
}

function openpag(pagina)
{
var url=pagina;
window.open(url,null,"width=550,height=200,top=100,left=100,resizable=no,scrollbars=yes,menubar=no,toolbar=no,status=no,location=no");
}


function A(e,t)
{
var k=null;
(e.keyCode) ? k=e.keyCode : k=e.which;
if(k==13) (!t) ? B() : t.focus();
}

function B()
{
document.forms[0].submit();
return true;
}

function foco(id)
{
var element = document.getElementById(id);
    element.focus();
}

function enter(e,id)
{
var k=null;
(e.keyCode) ? k=e.keyCode : k=e.which;
if(k==13)
  {
	   //  var element = document.getElementById(id);
	   foco(id);
	  //    element.focus();  //AQUI
  }
}

function mayus(id)
{ 
  var element = document.getElementById(id).value;
  var m = toUpperCase(element);
  element.value=m;
}


function dos_dec(numero)
{
  var num = numero.toFixed(2);
  return num;
}


function registrar()
{
  var url='php/registro/regi_usuario.php?opt=5';
  armar_url2(very_reg,url);
}


function ocultar(id)
{
  var element = document.getElementById(id);
  document.all.formul.style.visibility="visible";
 }

function desplegar(id)
{
  var element = document.getElementById(id);
  document.all.formul.style.visibility="hidden";

}



function very_reg(resp)
{
    var x =eval(resp);
    switch (x) 
           {
              case 0:
			        alert ("Sus datos no pueden ser Registrados,\n verifique sus datos o comuniquese con soporte telefonico");
					break;
			  case 1:
			        alert ("Su Registro Fue Satisfactorio");
					blanquear_form2('registro');
					foco('userid');
					cargarContenido('html/inicio.html','contenedor')
					break;
			  case 2:
			        alert ("No se Puede Registrar, Usuario o Codigo ya estan Registrados");
					break;
   			  case 3:
			        alert ("No se Puede Registrar, Codigo de Proveedor NO Existe");
					break;					
		   }
}


function very_user(user) 
{
  if(typeof user =='undefined'){ user = ""; }
  if(user !="")
  {
	 url ='php/registro/regi_usuario.php?opt=1&login='+user;
     
     ObtenerPorGETDatosHTML_2(mostrar,url);
  }
}

function mostrar(resp) 
{
  var div = document.getElementById('very_user');	
  if (resp == 0)
  {
	div.innerHTML = "Usuario ya Existe";
	//alert("Usuario ya Existe");
	foco('login');
  }
  else
  {
	div.innerHTML = ""; 
  }

}

function very_pass(valor,id,des) 
{
  var element = document.getElementById(id).value;
  var contenedor = document.getElementById(des);
  if(typeof valor =='undefined'){ valor = ""; }
  if(typeof element =='undefined'){ element = ""; }
  if(valor !="")
  {
	 alert(element);
	 alert(valor);
	 if (element == valor)
	 {
		contenedor.innerHTML = "";
	 }
	 {
		var msj = "Las Contraseñas no Coinciden";
		contenedor.innerHTML = msj;
		foco(id);
	 }
  }
}

function limpiar(cadena) 
{
 var texto="";	
  for (var i=0; i < cadena.length; i++) 
  {
   if (cadena.charAt(i)!=" ")
   {
     texto = texto + cadena.charAt(i);
   }
  }
  return texto;
}


function aleatorio(inferior,superior){ 
numPosibilidades = superior - inferior 
aleat = Math.random() * numPosibilidades 
aleat = Math.round(aleat) 
return parseInt(inferior) + aleat 
} 


function Clear(id,tip)
{
//tip: tipo de elemtento false para div el resto para elementos
//id es el id del elemento
element = document.getElementById(id);
var ajax;     
var valor = " ";
ajax = inst_exp(ajax); 
var N = Que_Navegador();

  if (N == true)
	{ //internet Explorer
	   if (tip == true)
		{
		   element.value = "";
		}
	   else
		{
		   element.innerHTML = "";
		}
	}
  else
   {// Nescape o firefox
   	   if (tip == true)
		{
		   element.value = null;
		}
	   else
		{
		   element.innerHTML = null;
		}
   }
}

function Que_Navegador()
{
var navegador = navigator.appName
if (navegador == "Microsoft Internet Explorer")
	{
    	var navi=1;
	}
else
	{
	   var navi=0;
	}
	return navi;
}

//MENSAJE EN LA BARRA DE ESTADO
var Nav = Que_Navegador();

if (Nav == true)
{//internet explorer

var speed = 100 
var pause = 3000
var timerID = null
var bannerRunning = false
var ar = new Array()
ar[0] = ">>>> Almacaroni - Servicios a Proveedores <<<<"
ar[1] = " Consultas tus Pagos o Cheques, ....."
ar[2] = "..... Imprime Lo que necesitas saber para Retirar tus Cheques, ....."
ar[3] = "..... No olvides de visitar http://www.almacaroni.gob.ve, ....."
ar[4] = "..... Pronto mas Servicios En-Linea, ....."
ar[5] = "..... Almacaroni al Dia con los Pagos a Proveedores ....."
ar[6] = "..... Servicios a Proveedores la forma mas facil de conocer tus Pagos ....."
var currentMessage = 0
var offset = 0

function stopBanner() 
{
	if (bannerRunning)
		clearTimeout(timerID)
		bannerRunning = false
}

function startBanner() 
{
	stopBanner()
	showBanner()
}


function showBanner() 
{
	var text = ar[currentMessage]

 if (offset < text.length) 
  {
	if (text.charAt(offset) == " ")
	offset++ 
	var partialMessage = text.substring(0, offset + 1) 
	window.status = partialMessage
	offset++ // IE sometimes has trouble with "++offset"
	timerID = setTimeout("showBanner()", speed)
	bannerRunning = true
  } 
 else 
  {
	offset = 0
	currentMessage++
	if (currentMessage == ar.length)
		currentMessage = 0
		timerID = setTimeout("showBanner()", pause)
		bannerRunning = true
  }
}
startBanner();

}

else
{//FIREFOX y nescape
   
	window.status='Almacaroni...';
	//return true;
}

function cancelar(cual)
{
    document.getElementById(cual).className = "invisible";
}





//*************************************funcion valida fecha********************************
function esDigito(sChr){
var sCod = sChr.charCodeAt(0);
return ((sCod > 47) && (sCod < 58));
}

function valSep(oTxt){
var bOk = false;
bOk = bOk || ((oTxt.value.charAt(2) == "-") && (oTxt.value.charAt(5) == "-"));
bOk = bOk || ((oTxt.value.charAt(2) == "/") && (oTxt.value.charAt(5) == "/"));
return bOk;
}

function finMes(oTxt){
var nMes = parseInt(oTxt.value.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(oTxt){
var bOk = false;
var nDia = parseInt(oTxt.value.substr(0, 2), 10);
bOk = bOk || ((nDia >= 1) && (nDia <= finMes(oTxt)));
return bOk;
}

function valMes(oTxt){
var bOk = false;
var nMes = parseInt(oTxt.value.substr(3, 2), 10);
bOk = bOk || ((nMes >= 1) && (nMes <= 12));
return bOk;
}

function valAno(oTxt){
var bOk = true;
var nAno = oTxt.value.substr(6);
bOk = bOk && ((nAno.length == 2) || (nAno.length == 4));
if (bOk){
for (var i = 0; i < nAno.length; i++){
bOk = bOk && esDigito(nAno.charAt(i));
}
}
return bOk;
}

function valFecha(oTxt){
var bOk = true;
if (oTxt.value != ""){
bOk = bOk && (valAno(oTxt));
bOk = bOk && (valMes(oTxt));
bOk = bOk && (valDia(oTxt));
bOk = bOk && (valSep(oTxt));
if (!bOk){
alert("Fecha inválida");
oTxt.value = "";
oTxt.focus();
}
}
}

function solonumero(evt){
	
    evt = (evt) ? evt : event
	var key = (evt.which) ? evt.which : evt.keyCode;
	if (key > 47 && key < 58 || key == 8 || key == 13 || key == 39 || key == 37 || evt.keyCode == 46) 	{ return true;}
	else 
	{return false;}
	
}

function FechaManual(event,Valor,Fecha){

//Coloca El Slash Automaticamente Por El Usuario, Toma El Valor y el Campo de la Fecha
//Evalua en que posicion se encuantra el valor   y coloca el valor de la fecha automatica

 if(event.keyCode != 46 && event.keyCode != 8){
  
 var ValorFecha = document.getElementById(Fecha).value;
 var arrayDatos = ValorFecha.split('/');
  
   switch (ValorFecha.length){
     case 1:
         	 if(arrayDatos[0] > 3){
		       alert('Valor de Dia Invalido Dias No Reconocido')
		       document.getElementById(Fecha).value = '';
		     }
	 break;  
     case 2:
    	     if(arrayDatos[0] > 31){
		       alert('Valor de Dia Invalido Dias No Reconocido, Los Dias No Pueden Ser Mayor de 31 ')
		       document.getElementById(Fecha).value = '';
	         }else{
		       document.getElementById(Fecha).value = ValorFecha + '/'
		     }
	 break;
	 case 4:
		     if(arrayDatos[1] > 1){
				alert('Valor de Mes Invalido Mes No Reconocido, El Mes No Comienza con ' + arrayDatos[1])
   			   document.getElementById(Fecha).value = arrayDatos[0] + '/'
			 }
	 break;
	 case 5:
		      if(arrayDatos[1] > 12 || arrayDatos[1] < 0){
				alert('Valor de Mes Invalido Mes No Reconocido, El Mes No Puede Ser ' + arrayDatos[1])
				document.getElementById(Fecha).value = arrayDatos[0] + '/'
			  }else{
				document.getElementById(Fecha).value = ValorFecha + '/' 
			  }
	  break;
	}
 }
   
}

//fin funcion valida fecha

//Funcion ajax
function ObtenerPorGETDatosHTML_2(retorno, urlDatos) {
  var XMLHttpRequestObject = false;
  if (window.XMLHttpRequest) {
    XMLHttpRequestObject = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
  }


  if (XMLHttpRequestObject) {
	  
	    XMLHttpRequestObject.open("GET", urlDatos);
	   XMLHttpRequestObject.onreadystatechange = function() {
      if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
        {
          var respGetHTML = XMLHttpRequestObject.responseText;
          retorno(respGetHTML);
          delete XMLHttpRequestObject;
          XMLHttpRequestObject = null;
        }
    }
    XMLHttpRequestObject.send(null);
  }
}

///Fin Funcion Ajax

function ObtenerDatos(retorno,urlDatos,recarga,div) {
  var XMLHttpRequestObject = false;
  if (window.XMLHttpRequest) {
    XMLHttpRequestObject = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
  }

if (XMLHttpRequestObject) {
	  
	    XMLHttpRequestObject.open("GET", urlDatos);
	   XMLHttpRequestObject.onreadystatechange = function() {
      if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
        {
          var respGetHTML = XMLHttpRequestObject.responseText;
          retorno(respGetHTML,recarga,div);
          delete XMLHttpRequestObject;
          XMLHttpRequestObject = null;
        }
    }
    XMLHttpRequestObject.send(null);
  }
}


function rutas(op,v,formul)//op = la ruta de armado  y la v= si verifica los datos o no   - y formul =nombre del formulario
{
 if (v==1) 
 {
	verifica(formul);
 }
 var num = Math.random(); 
 
   switch (op)
   {
     case 1://Registro principal
	   	var ul="php/provee/mant_provee.php?"; 
		//var rut="php/provee/formul/frm_registro.php";
		//var div="contenedor";
        break;
     case 2://registro mercantil	    
		var ul="php/provee/mant_reg_mercantil.php?"; 
		var rut="php/provee/formul/grp_reg_mer.php?" + "&n=" + num;	
		var div="formul";
        break;
     case 3://mantenimiento accionista	    
		var ul="php/provee/mant_accionistas.php?"; 
        var rut="php/provee/formul/grp_accionistas.php?" + "&n=" + num;
		var div="formul";
        break;
     case 4://registro actividades	    
		var ul="php/provee/mant_dedicaciones.php?"; 
		var rut="php/provee/formul/frm_dedicaciones.php?" + "&n=" + num;
		var div="formul";
		break;	
	 case 5://registro obras/serv/bienes
		var ul="php/provee/mant_obraserv.php?"; 
		var rut="php/provee/formul/frm_obras.php?" + "&n=" + num;
		var div="formul";
        break;	
	 case 6://registro objetos
		var ul="php/provee/mant_objeto.php?"; 
		var rut="php/provee/formul/frm_objetos.php?" + "&n=" + num;
		var div="contenedor";
        break;
	case 7://registro actividaedes
		var ul="php/provee/mant_actividad.php?"; 
		var rut="php/provee/formul/frm_actividades.php?" + "&n=" + num;
		var div="contenedor";
        break;	
	case 8://registro tipos de registro
		var ul="php/provee/mant_regism.php?"; 
		var rut="php/provee/formul/frm_tipos_reg.php?" + "&n=" + num;
		var div="contenedor";
        break;		
	case 9://registro deominaciones comercial
		var ul="php/provee/mant_tipoemp.php?"; 
		var rut="php/provee/formul/frm_denomin.php?" + "&n=" + num;
		var div="contenedor";
        break;		
    case 10://consignacion de requisitos
		var ul ="php/provee/mant_consi_req.php?"; 
		var rut="php/provee/formul/frm_consi_req.php?" + "&n=" + num;
		var div="formul";
        break;	        
        
     case 11://Registro principal de contratos
	   	var ul="php/provee/mant_contrato.php?"; 
        break;
        
    case 12://mantenimiento de actividades asociadas al contrato   
		var ul="php/provee/mant_actividades.php?"; 
		var rut="php/provee/formul/frm_actividad.php?" + "&n=" + num;
		var div="formul";	
		break;

    case 13://Supervision de servicios y mantenimiento    
		var ul="php/provee/mant_serv_mant.php?"; 
		var rut="php/provee/formul/frm_serv_mant.php?" + "&n=" + num;
		var div="formul";	
		break;

    case 14://Supervision de Actividades   
		var ul="php/provee/mant_super_act.php?"; 
		var rut="php/provee/formul/frm_super_act.php?" + "&n=" + num;
		var div="formul";	
		break;

    case 15://Supervision de Actividades   
		var ul="php/provee/mant_sumin_cont.php?"; 
		var rut="php/provee/formul/frm_sumin_cont.php?" + "&n=" + num;
		var div="formul";	
		break;

    case 16://Supervision de Insumos o suministros    
		var ul="php/provee/mant_super_insu.php?"; 
		var rut="php/provee/formul/frm_super_insu.php?" + "&n=" + num;
		var div="formul";	
		break;

    case 17://Supervision de Insumos o suministros    
		var ul="php/provee/mant_mod_cont.php?"; 
		var rut="php/provee/formul/frm_mod_cont.php?" + "&n=" + num;
		var div="formul";	
		break;

	case 18://Supervision de Insumos o suministros    
		var ul="php/provee/mant_super_aseo.php?"; 
		var rut="php/provee/formul/frm_super_aseo.php?" + "&n=" + num;
		var div="formul";	
		break;

    case 19://Mantenimiento de ubicacion del contrato    
		var ul="php/provee/mant_ubicacion.php?"; 
		var rut="php/provee/formul/frm_ubicacion.php?" + "&n=" + num;
		var div="formul";	
		break;



    case 20://registro estado    
		var ul="php/provee/mant_estados.php?"; 
		var rut="php/provee/formul/frm_estados.php?" + "&n=" + num;
		var div="contenedor";	
		break;	
     case 21://registro ciudades    
		var ul="php/provee/mant_ciudades.php?"; 
		var rut="php/provee/formul/frm_ciudades.php?" + "&n=" + num;
		var div="contenedor";
		break;	
	 case 22://registro municipios  
		var ul="php/provee/mant_municipio.php?"; 
		var rut="php/provee/formul/frm_municipios.php?" + "&n=" + num;
		var div="contenedor";
		break;	
	 case 23://registro parroquias  
		var ul="php/provee/mant_parroquias.php?"; 
		var rut="php/provee/formul/frm_parroquias.php?" + "&n=" + num;
		var div="contenedor";
		break;		
	 case 24://registro de usuarios al sistema  
		var ul="php/provee/mant_reg_provee.php?"; 
		var rut="html/inicio.html";
		var div="contenedor";
		break;		
	 case 25://Cambiar la clave del usuario 
		var ul="php/provee/mant_reg_provee.php?"; 
		var rut="html/inicio.html";
		var div="contenedor";
		break;
	case 26://Cambiar la rif del usuario  
		var ul="php/provee/mant_rif.php?"; 
		var rut="index.php";
		var div="reload";
		break;	
     case 27://registro de suministros    
		var ul="php/provee/mant_sumin.php?"; 
		var rut="php/provee/formul/frm_sumin.php?" + "&n=" + num;
		var div="contenedor";	
		break;	
     case 28://registro de requisitos    
		var ul="php/provee/mant_requisito.php?"; 
		var rut="php/provee/formul/frm_requisito.php?" + "&n=" + num;
		var div="contenedor";	
		break;	
     case 29://registro supervision    
		var ul="php/provee/mant_regimen.php?"; 
		var rut="php/provee/formul/frm_regimen.php?" + "&n=" + num;
		var div="contenedor";	
		break;	
     case 30://registro evaluacion    
		var ul="php/provee/mant_eval.php?"; 
		var rut="php/provee/formul/frm_eval.php?" + "&n=" + num;
		var div="contenedor";	
		break;	
     case 31://modalidad de pago    
		var ul="php/provee/mant_mod_pag.php?"; 
		var rut="php/provee/formul/frm_mod_pag.php?" + "&n=" + num;
		var div="contenedor";	
		break;		
		
    case 32://Calificacion final de proveedores    
		var ul="php/provee/mant_califica.php?"; 
		var rut="php/provee/formul/frm_calif_pro.php?" + "&n=" + num;
		var div="formul";	
		break;				

     case 33://registro evaluacion    
		var ul="php/provee/mant_fase.php?"; 
		var rut="php/provee/formul/frm_fase.php?" + "&n=" + num;
		var div="contenedor";	
		break;	

     case 34://registro evaluacion    
		var ul="php/provee/mant_adjudicacion.php?"; 
		var rut="php/provee/formul/frm_adjudicacion.php?" + "&n=" + num;
		var div="contenedor";	
		break;	

   }
   	armar_url(mostrar_datos,ul,rut,div);
}


function registro(op,formul)//op = la ruta de armado  y formul =nombre del formulario
{
    var rif = document.getElementById('rif_con').value;
	var nro_sol = document.getElementById('nro_sol').value;
	
    if(typeof rif =='undefined'){ rif = ""; }
  
    if (rif != "")
    {
      var num = aleatorio(1,9999);
      switch (op)
      {
       case 1://activa solicitud
	   	  var ul="php/provee/mant_provee.php?opt=6&rif_con="+rif+"&nro_sol="+nro_sol+"&n="+num; 
          break;
       case 2://desactiva solicitud	    
		  var ul="php/provee/mant_provee.php?opt=5&rif_con="+rif+"&nro_sol="+nro_sol+"&n="+num; 
		  break;
       case 3://asignacodigo solicitud	    
		  var ul="php/provee/mant_provee.php?opt=4&rif_con="+rif+"&nro_sol="+nro_sol+"&n="+num; 
          break;
      }
	 //document.getElementById('rif_con').value=ul;
      ObtenerPorGETDatosHTML_2(mostrar_datos,ul) ;	
	}
}





function consultas(objeto,op)//op = la ruta de armado 
{
   
   switch (op)
   {
     case 1://objetos
	       var ul="php/provee/mant_objeto.php?opt=4&cod_obj="+objeto.value; 
   	       break;  
     case 2://objetos
	       var ul="php/provee/mant_estados.php?opt=4&cod_edo="+objeto.value; 
   	       break; 	 
   }
   //document.getElementById('des_edo').value=ul;
   ObtenerPorGETDatosHTML_2(mostrar_datos,ul) 
}


function del_grip(url,grip,div) //url:url a ejecutar,grip:que va a cargar,div:div que va a cargar
{
    var num = Math.random(); 
    var grip=grip + '?n=' + num;
    //document.getElementById('dani').value=url;
     
   // if (confirm('¿Deseas Eliminar los Datos?'))
	//		 {
			 // cargarContenido(grip,div);
			  ObtenerDatos(mostrar_datos,url,grip,div) 
			  // ObtenerPorGETDatosHTML_2(nula,url);
			    
		//     }
   
   
}

function nula(datos) //esto no hace nada solo para que no de error otras funciones
{
   //alert(datos);
}






// Modificado por Almacaroni

// Variables Globales 
var swOK=0; 
var nEle=0; 
var sError=''; 

// VERIFICA EL FORMULARIO 
//=================================== 
function Verifica(name) { 
   var nTot=0; 
   var nPas=0; 
   var nTorna=0; 
   sError="Lista de errores: "+"\n"; 
   for (var j=0; j<10; j++) { 
     nEle=j; 

     // AVERIGUA LOS TIPOS 
     var sNom=document.forms[name].elements[j].name; 
     var sOne=sNom.substring(0,1); 
     var sTwo=sNom.substring(1,2); 
  

     // CORREO OBLIGATORIO 
     if (sOne=='e' && sTwo=='r') { 
       CaracterNoValid(document.forms[name].elements[j].value,'Er',name); 
       nTot+=swOK; 
     } 
     else 
       if (sOne=='e' && document.forms[name].elements[nEle].value!='') { 
         CaracterNoValid(document.forms[name].elements[j].value,'Eo',name); 
         nTot+=swOK; 
       } 
  

     // NUMERICO Y OBLIGATORIO else NUMERICO NO OBLIGATORIO PERO INFORMADO 
     if (sOne=='n' && sTwo=='r') { 
       CaracterNoValid(document.forms[name].elements[j].value,'Nr',name); 
       nTot+=swOK; 
     } 
     else 
       if (sOne=='n' && document.forms[name].elements[nEle].value!='') { 
         CaracterNoValid(document.forms[name].elements[j].value,'No',name); 
         nTot+=swOK; 
       } 

     // CADENA Y OBLIGATORIA 
     if (sOne=='s' && sTwo=='r') { 
       CaracterNoValid(document.forms[name].elements[j].value,'Sr',name); 
       nTot+=swOK; 
     } 

     // LISTA DE ERRORES 
     if (nPas==0 && nTot>0) { 
       document.forms[name].elements[nEle].focus() 
       nPas=1 
     } 
   } 

   if (nTot>0) 
     alert(sError) 
  // else 
    // registrar();
} 

// ANALIZA CAMPO A CAMPO SI SON NUMERICOS 
//========================================= 
function CaracterNoValid(pCaracter,pType,name) { 
   swOK=0; 
  // E-MAIL OBLIGATORIO 
  if (pType=='Er') { 
     swOK=2 
     for (var i=0;i<pCaracter.length;i++) {
      var sByte=pCaracter.substring(i,i+1); 
     if (sByte=="@" || sByte==".") { 
         swOK=swOK-1; 
     } 
   } 
   if (swOK>0) 
     sError+="Campo "+document.forms[name].elements[nEle].name.substr(2)+" ha de ser valido y es obligatorio" +"\n"; 
   return; 
} 

   // NUMERICO OBLIGATORIO 
   if (pType=='Nr') { 
     swOK=0; 
     if (pCaracter=='') { 
       swOK=1 
       sError+="Campo "+document.forms[name].elements[nEle].name.substr(2)+" ha de ser numérico y es obligatorio" +"\n" 
       return 
     } 

     for (var i=0;i<pCaracter.length;i++) {
        var sByte=pCaracter.substring(i,i+1); 
       if (sByte<"0" || sByte>"9") { 
         sError+="Campo "+document.forms[name].elements[nEle].name.substr(2)+" ha de ser numérico y es obligatorio" +"\n" 
         swOK=1; 
         return; 
       }  
     } 
   } 

   // NUMERICO INFORMADO 
   if (pType=='No') {  
     swOK=0; 
     if (pCaracter=='') { 
       swOK=1 
       sError+="Campo "+document.forms[name].elements[nEle].name.substr(2)+" ha de ser numérico" +"\n" 
       return 
     } 
     for (var i=0;i<pCaracter.length;i++) {
        var sByte=pCaracter.substring(i,i+1); 
       if (sByte<"0" || sByte>"9") { 
         sError+="Campo "+document.forms[name].elements[nEle].name.substr(2)+" ha de ser numérico" +"\n" 
         swOK=1; 
         return; 
       }  
     } 
   } 

   // CADENA 
   if (pType=='Sr') {  
     if (pCaracter=='') { 
       sError+="Campo "+document.forms[name].elements[nEle].name.substr(2)+" es obligatorio"+"\n" 
       swOK=1; 
       return 
     } 
   } 
} 


function valida_env(comando,a)
{
var b=0;

for (var i=0; i < document.forms[a].length; i++) 
   {
    if (document.forms[a].elements[i].type !== "button") 
	  {
      if (document.forms[a].elements[i].name != "opt" ) 
	     {  
		     
		     if (document.forms[a].elements[i].value=="")
			 {
			   //alert('paso2')	 
			   //b=1;   	 
			 }
			 
		 }
      }
   }

if (b!=1)
  {
    document.forms[a].submit();
  }
}

function doPrint()
{
 
  document.all.item("noprint").style.visibility='hidden' 
  window.print()
  document.all.item("noprint").style.visibility='visible'
  
}
function calendar(par1,par2)
{

var cal5 = new calendar2(document.forms[par1].elements[par2]);
	cal5.year_scroll = true;
	cal5.time_comp = false;

}

function desabi_acci(combo,op)
{
   switch (op)
   {
     case 1://combo accionista
		if (combo.value == 'NO')
		{
          document.getElementById('porc_acci').readOnly = true;	  
          document.getElementById('fec_adq').readOnly = true;		  	  		  
		}
		else
		{				
          document.getElementById('porc_acci').readOnly = false;
          document.getElementById('fec_adq').readOnly = false;		  
		}
        break;
     case 2://combo accionista
		if (combo.value == 'NO')
		{
          document.getElementById('cargo').readOnly = true;		  
		}
		else
		{				
          document.getElementById('cargo').readOnly = false;
		}
        break;
     case 3://combo accionista
		if (combo.value == 'NO')
		{
          document.getElementById('tip_oblig').disabled = true;		  
		}
		else
		{				
          document.getElementById('tip_oblig').disabled = false;
		}
        break;
     case 4://combo tip_per
		if (combo.value == 'J')
		{
          document.getElementById('apellido').readOnly = true;		
          document.getElementById('nacionali').disabled = true;
          document.getElementById('edo_civil').disabled = true;		  
		}
		else
		{				
          document.getElementById('apellido').readOnly = false;
          document.getElementById('nacionali').disabled = false;
          document.getElementById('edo_civil').disabled = false;			  
		}
        break;	
   }
}

function valida_rif() 
{
  var rif = document.getElementById('rif_con').value;
  if(typeof rif =='undefined'){ rif = ""; }
  
if (rif != "")
 {
  var linea = rif;
  linea = linea.toUpperCase();     //convierte en mayustula
  linea = linea.replace(/-/g, ""); //elimina los guiones
  linea = linea.replace(/ /g, ""); //elimina los espacios
  rif = linea;
  document.getElementById('rif_con').value = rif
  
  var sOne=rif.substring(0,1); 
  var ar = new Array();
  ar[0]="J";
  ar[1]="V";
  ar[2]="P";
  ar[3]="E";
  ar[4]="G";
  
  var swc = 0;
  for (var i=0 ; i < 5; i++)
  {
    if (sOne == ar[i])
	    swc=1;  //encontro una letra valida   
  }
  
  var Mlen = rif.length;
  if (Mlen < 8 || Mlen >12)
    {
	 //alert("El RIF "+ rif +" no es Valido");
	 //foco('rif_con');
	 var swa=0;
	}

  if (swc==0)
    {
    // foco('rif_con');
	 var swa=0;
	}

  if (swa==0)
    {
       alert("El RIF "+ rif +" no es Valido");
	}


  if (swa != 0)
  {
      var num = aleatorio(1,9999);
      var url='php/provee/mant_provee.php?opt=3&rif_con='+rif+'&r='+num;
	  //document.getElementById('nom_con').value = url;		 
      ObtenerPorGETDatosHTML_2(mostrar_datos,url) ;
  }
  
 }
}


function rif_val(element)
{
  var rif = element.value;
  if(typeof rif =='undefined'){ rif = ""; }
  
  var linea = rif;
  linea = linea.toUpperCase();     //convierte en mayustula
  linea = linea.replace(/-/g, ""); //elimina los guiones
  linea = linea.replace(/ /g, ""); //elimina los espacios
  rif = linea;
  element.value = rif 
  
  var sOne=rif.substring(0,1); 
  var ar = new Array();
  ar[0]="J";
  ar[1]="V";
  ar[2]="P";
  ar[3]="E";
  ar[4]="G";
  
  var swc = 0;
  for (var i=0 ; i < 5; i++)
  {
    if (sOne == ar[i])
	    swc=1;  //encontro una letra valida   
  }
  
  var Mlen = rif.length;
  if (Mlen < 8 || Mlen >12)
    {
	 //alert("El RIF "+ rif +" no es Valido");
	 //foco('rif_con');
	 var swa=0;
	}

  if (swc==0)
    {
    // foco('rif_con');
	 var swa=0;
	}

  if (swa==0)
    {
       alert("El RIF "+ rif +" no es Valido");
	  // element.value ='';
	   //element.focus();	
	}

}

function rif_val2(element)
{
  var rif = element.value;
  if(typeof rif =='undefined'){ rif = ""; }
  
  var linea = rif;
  linea = linea.toUpperCase();     //convierte en mayustula
  linea = linea.replace(/-/g, ""); //elimina los guiones
  linea = linea.replace(/ /g, ""); //elimina los espacios
  rif = linea;
  element.value = rif

  var sOne=rif.substring(0,1); 
  var ar = new Array();
  ar[0]="V";
  ar[1]="E";
  
  var swc = 0;
  for (var i=0 ; i < 5; i++)
  {
    if (sOne == ar[i])
	    swc=1;  //encontro una letra valida   
  }
  
  var Mlen = rif.length;
  if (Mlen < 8 || Mlen >12)
    {
	 //alert("El RIF "+ rif +" no es Valido");
	 //foco('rif_con');
	 var swa=0;
	}

  if (swc==0)
    {
    // foco('rif_con');
	 var swa=0;
	}

  if (swa==0)
    {
       alert("El RIF "+ rif +" no es Valido");
	  // element.value ='';
	   //element.focus();	
	}

}


// funcion para validar un email valido

function valida_email(theElement, nombre_del_elemento )
{
var s = theElement.value;
var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
if (s.length == 0 )
 return true;
if (filter.test(s))
 return true;
else
  alert("Ingrese una dirección de correo válida");
  document.getElementById(nombre_del_elemento).focus();		  
  //theElement.focus();
  return false;
}

function ocultar_ayuda(id)
{
 var div =document.getElementById(id);
 div.style["display"] = "none"; 
}

function mostrar_ayuda(id)
{
 var div =document.getElementById(id);
 div.style["display"] = "";
}


function valida_clave(clave1,clave2)
{
  var v1 =  document.getElementById(clave1).value;		  
  var v2 =  document.getElementById(clave2).value;		  
  if (v1!= v2)
   {
    alert("Las contraseñas no son Iguales Verifique");
    document.getElementById(clave1).value = "";		    
    document.getElementById(clave2).value = "";		    
    document.getElementById(clave1).focus();		    
   }	
}

function porcentaje(obj)
{
  var valor =  obj.value;  
  var swc =0;
  b = isNaN(valor);
  if (b == false)
  { 
    valor = eval(valor); 
  }
  else
  {
	swc=1;  
  }

  if (valor > 100)
  {
    swc=1;  
  }

  if (swc == 1)
  {
    alert("Valor Incorrecto");
	obj.value="";
  }
}


function valida_contrato() 
{
  var nro_contrato = document.getElementById('nro_contrato').value;
  if(typeof nro_contrato =='undefined'){ nro_contrato = ""; }
  
  var num = aleatorio(1,9999);
  var url='php/provee/mant_contrato.php?opt=3&nro_contrato='+nro_contrato+'&r='+num;
	  //document.getElementById('nom_con').value = url;		 
  ObtenerPorGETDatosHTML_2(mostrar_datos,url) ;

}

