//-------------------------------------------------------//
// Author:Rodolfo Machon
// Company:WebSoft, SA de CV 
// Nombre del archivo: solvencias_p.js
// Created: 2016-03-09
// Updates: 2016-03-09
//-------------------------------------------------------//
//-------------------------------------------------------//
var xmlHttp;
var xmlHttpStream;
//-------------------------------------------------------//
window.onload = function(){

}
//-------------------------------------------------------//
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 Save(){
    var lan 	= document.form.lan.value;
    var appid	= document.form.appid.value;
	var clase	= document.form.clase.value;
	var id		= document.form.id.value;
	var sol_id	= document.form.i8_solvencia_id.value;
	var institu = document.form.v128_institucion.value;
	var vencimi	= document.form.dt_vencimiento.value;
	var emision = document.form.dt_emision.value;
	var con_id	= document.form.i8_contribuyente_id.value;
	var con_nom	= document.form.v128_contribuyente.value;
	var con_dir	= document.form.txt_direccion.value;
	var gen_id	= document.form.c3_tipo_generador_id.value;
	var emi_id	= document.form.i8_emisor_id.value;
	var use_id	= document.form.i8_user_id.value;
	var dir_exp	= document.form.txt_expediente_direccion.value;
	if (sol_id>1) {alert("El correlativo y solvencia ya existen....");return}
	if (institu=="") {alert("Favor Ingrese el Nombre de la Institucion");return}
	var str		= "appid="+appid+"&lan="+lan+"&id="+id+"&clase="+clase+"&vencimiento="+vencimi+"&emision="+emision+"&con_id="+con_id+"&con_nom="+con_nom+"&con_dir="+con_dir+"&gen_id="+gen_id+"&emi_id="+emi_id+"&use_id="+use_id+"&dir_exp="+dir_exp+"&institucion="+institu;
    var URL     = "/cgi-bin/"+appid+"/pl/solvencia_s.pl";	
    xmlHttp		= GetXmlHttpObject(stateChangedSave);
    xmlHttp.open("POST",URL,true) ;
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(str);
}
function stateChangedSave(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
        xmlHttpStream=xmlHttp.responseText;
		//alert(xmlHttpStream);
        if (xmlHttpStream!="error!" && xmlHttpStream!=""){
			document.form.i8_solvencia_id.value=xmlHttpStream;
        }
    } 
}
function Clean(){
	document.form.i8_solvencia_id.value		="";
	document.form.v128_institucion.value	="";	
}