//-------------------------------------------------------//
// Author:Rodolfo Machon
// Company:WebSoft, SA de CV 
// Nombre del archivo: tramites_rcrd.js
// Created: 2016-08-03
// Updates: 2016-08-03
// Copyright - All Rights Reserved
//-------------------------------------------------------//
//-------------------------------------------------------//
var isIE 		= document.all?true:false;
var isNS 		= document.layers?true:false;
var xmlHttp;
var xmlHttpStream;
//-------------------------------------------------------//
window.onload = function(){
	
};
//-------------------------------------------------------//
// LEVEL 1
function saveTramite(){
	var mot = document.getElementById('c2_motivo_tramite_id').options[document.getElementById('c2_motivo_tramite_id').selectedIndex].text;
	var cla = document.getElementById('c2_clase_tramite_id').options[document.getElementById('c2_clase_tramite_id').selectedIndex].text;
	var tip = document.getElementById('c2_tipo_tramite_id').options[document.getElementById('c2_tipo_tramite_id').selectedIndex].text;
	var dui = document.getElementById('c11_dui_id').value;
	document.form.v128_tramite.value = mot+" - "+cla+" - "+tip+" - "+dui;
	//alert(document.form.v128_tramite.value);
	Save();	
}
function ActivarNombre(){
    document.form.i8_contribuyente_id.value =99999999;
	document.getElementById("v128_contribuyente").readOnly=false;
}
function GetExpediente(){
    var generador = document.form.v64_tipo_generador.value.toLowerCase();
    if(generador!==""){
	var command = "GetBack('LTMD','contribuyente_"+generador+"s','i8_"+generador+"_id|i8_expediente_id,txt_ubicacion|txt_expediente_direccion','parent.opener.form',100,100,'i8_contribuyente_id','i8_expediente_id')";
	//alert(command);
	eval(command);
    }else{alert("Seleccione el Generador");}
}
function getUserCajaDepartamento(){
    var URL = "/cgi-bin/RTM_v30/pl/user.caja.departamento.get.pl?appid=RTM_v30&lan=es";
    xmlHttp	= GetXmlHttpObject(getUserCajaDepartamentoSC);
    xmlHttp.open("GET",URL,true) ;
    xmlHttp.send(null);
}
//-------------------------------------------------------//
// LEVEL 2
function getUserCajaDepartamentoSC(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
        xmlHttpStream=xmlHttp.responseText;
		if (xmlHttpStream!=="false" && xmlHttpStream!==""){
			var datos=xmlHttpStream.split("|");
			document.form.i8_user_id.value				= datos[0];
			document.form.v128_user.value				= datos[1]+" "+datos[2];
			document.form.i2_tipo_departamento_id.value	= datos[3];
			document.form.v64_tipo_departamento.value	= datos[4];
			document.form.i2_cajero_id.value			= datos[5];
		}
    }
}
//-------------------------------------------------------//
// AUXLIAR
function GetXmlHttpObject(handler){
	var objXmlHttp=null;	
	if(window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		objXmlHttp = new XMLHttpRequest();
		objXmlHttp.onload=handler;
		objXmlHttp.onerror=handler; 		
	}
	if(window.ActiveXObject){// code for IE6, IE5
		objXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		objXmlHttp.onreadystatechange=handler;
	}
	if(objXmlHttp===null){alert("Your Browser Does Not Suppport AJAX");}
	return objXmlHttp;
}
function onlyDigits(e,decReq) {
	var key = (isIE) ? window.event.keyCode : e.which;
	var obj = (isIE) ? event.srcElement : e.target;
	var isNum = (key > 47 && key < 58) ? true:false;
	var dotOK = (key===46 && decReq==='decOK' && (obj.value.indexOf(".")<0 || obj.value.length===0)) ? true:false;
	window.event.keyCode = (!isNum && !dotOK && isIE) ? 0:key;
	e.which = (!isNum && !dotOK && isNS) ? 0:key;
	return (isNum || dotOK);
}
function noRet(e,decReq) {
	var key = (isIE) ? window.event.keyCode : e.which;
	var obj = (isIE) ? event.srcElement : e.target;
	var isRet = (key==13 || key=="35" || key=="34" || key=="126" || key=="124") ? false:true;
	window.event.keyCode = (!isRet && isIE) ? 0:key;
	return (isRet);
}