var openwindow=new Array(10);
var winame;
var openwindow2;
weekdays 	= new Array("Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado");
months 		= new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
today 		= new Date();
weekday 	= today.getDay();
monthday 	= today.getDate();
month 		= today.getMonth();
year 		= today.getFullYear();
weekday		= weekdays[weekday];
month 		= months[month];
dateString	= (String(weekday))+" "+(String(monthday))+" "+(String(month))+" , "+(String(year));
var xmlHttp;
var xmlHttpStream;
var xmlHttp1;
var xmlHttpStream1;
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 OpenContribuyentes(id){
    winame="contribuyentes";
    var fields="";
    var values="";
    if (!openwindow[winame] || openwindow[winame].closed){
	win ="window.open('../bin/GMFL.pl?lan=es&appid=LaUnion&clase=contribuyentes&id="+id+"&fields="+fields+"&values="+values+"','"+winame+"','left=0,top=0,width=100,height=100,resizable=yes,scrollbars=yes')";
	openwindow[winame]=eval(win);
    }
    else{openwindow[winame].focus()}
}
function OpenBalance(id){
    winame="empresa_balance";
    var fields="";
    var values="";
    if (!openwindow[winame] || openwindow[winame].closed){
        win ="window.open('../bin/BSWS.pl?lan=es&appid=LaUnion&clase=empresa&id="+id+"&fields="+fields+"&values="+values+"','"+winame+"','left=0,top=0,width=100,height=100,resizable=yes,scrollbars=yes')";
        openwindow[winame]=eval(win);
    }
    else{openwindow[winame].focus()}
}
function OpenComparacionR(id){
    winame="empresa_comparacion_r";
    var fields="";
    var values="";
    if (!openwindow[winame] || openwindow[winame].closed){
        win ="window.open('../pl/comparar_expediente_r_p.pl?lan=es&appid=LaUnion&clase=empresa&id="+id+"&fields="+fields+"&values="+values+"','"+winame+"','left=0,top=0,width=100,height=100,resizable=yes,scrollbars=yes')";
        openwindow[winame]=eval(win);
    }
    else{openwindow[winame].focus()}
}
function OpenComparacionS(id){
    winame="empresa_comparacion_s";
    var fields="";
    var values="";
    if (!openwindow[winame] || openwindow[winame].closed){
        win ="window.open('../pl/comparar_expediente_s_p.pl?lan=es&appid=LaUnion&clase=empresa&id="+id+"&fields="+fields+"&values="+values+"','"+winame+"','left=0,top=0,width=100,height=100,resizable=yes,scrollbars=yes')";
        openwindow[winame]=eval(win);
    }
    else{openwindow[winame].focus()}
}
function OpenExpediente(id){
    winame="contribuyentes";
    var fields="";
    var values="";
    if (!openwindow[winame] || openwindow[winame].closed){
	win ="window.open('../bin/REPT.pl?lan=es&appid=LaUnion&clase=empresas&id="+id+"&fields="+fields+"&values="+values+"','"+winame+"','left=10,top=1,width=900,height=700,resizable=yes,scrollbars=yes')";
	openwindow[winame]=eval(win);
    }
    else{openwindow[winame].focus()}
}
function OpenIdentificacion(id){
    winame="empresas";
    var fields="";
    var values="";
    if (!openwindow[winame] || openwindow[winame].closed){
	win ="window.open('../bin/RCRD.pl?lan=es&appid=LaUnion&clase=empresa_ubicacion&id="+id+"&fields="+fields+"&values="+values+"','"+winame+"','left=0,top=0,width=100,height=100,resizable=yes,scrollbars=yes')";
	openwindow[winame]=eval(win);
    }
    else{openwindow[winame].focus()}
}
function OpenServicios(id){
    winame="empresa_servicios";
    var fields="";
    var values="";
    if (!openwindow[winame] || openwindow[winame].closed){
	win ="window.open('../bin/GDFL.pl?lan=es&appid=LaUnion&clase=empresa_servicios&id="+id+"&fields="+fields+"&values="+values+"','"+winame+"','left=0,top=0,width=100,height=100,resizable=yes,scrollbars=yes')";
	openwindow[winame]=eval(win);
    }
    else{openwindow[winame].focus()}
}
function OpenBases(id){
    winame="empresa_bases_imponibles";
    var fields="";
    var values="";
    if (!openwindow[winame] || openwindow[winame].closed){
        win ="window.open('../bin/GDFL.pl?lan=es&appid=LaUnion&clase=empresa_bases_imponibles&id="+id+"&fields="+fields+"&values="+values+"','"+winame+"','left=0,top=0,width=100,height=100,resizable=yes,scrollbars=yes')";
        openwindow[winame]=eval(win);
    }
    else{openwindow[winame].focus()}
}
function OpenNic(id){
    winame="empresa_bases_imponibles";
    var fields="";
    var values="";
    if (!openwindow[winame] || openwindow[winame].closed){
	win ="window.open('../bin/GDFL.pl?lan=es&appid=LaUnion&clase=empresa_suministro_nics&id="+id+"&fields="+fields+"&values="+values+"','"+winame+"','left=0,top=0,width=100,height=100,resizable=yes,scrollbars=yes')";
	openwindow[winame]=eval(win);
    }
    else{openwindow[winame].focus()}
}
function OpenAceptacion(id){
    winame="empresa_aceptacion";
    var fields="";
    var values="";
    if (!openwindow[winame] || openwindow[winame].closed){
	win ="window.open('../bin/RCRD.pl?lan=es&appid=LaUnion&clase=empresa_aceptacion&id="+id+"&fields="+fields+"&values="+values+"','"+winame+"','left=0,top=0,width=100,height=100,resizable=yes,scrollbars=yes')";
	openwindow[winame]=eval(win);
    }
    else{openwindow[winame].focus()}
}
function OpenPropietarios(id){
    winame="empresa_contribuyentes";
    var fields="";
    var values="";
    if (!openwindow[winame] || openwindow[winame].closed){
	win ="window.open('../bin/GDFL.pl?lan=es&appid=LaUnion&clase=empresa_contribuyentes&id="+id+"&fields="+fields+"&values="+values+"','"+winame+"','left=0,top=0,width=100,height=100,resizable=yes,scrollbars=yes')";
	openwindow[winame]=eval(win);
    }
    else{openwindow[winame].focus()}
}
function OpenFicha(id){
    winame="OpenFichas";
    var fields="";
    var values="";
    if (!openwindow[winame] || openwindow[winame].closed){
        win ="window.open('../pl/empresa_ficha_cuenta_rept.pl?lan=es&appid=LaUnion&clase=empresas&id="+id+"&fields="+fields+"&values="+values+"','"+winame+"','left=0,top=0,width=100,height=100,resizable=yes,scrollbars=yes')";
        openwindow[winame]=eval(win);
    }
    else{openwindow[winame].focus()}
}
function SubirFicha(id){
    winame="SubirFichas";
    var fields="";
    var values="";
    if (!openwindow[winame] || openwindow[winame].closed){
        win ="window.open('../bin/UPLD.pl?lan=es&appid=LaUnion&clase=empresa_fichas&id="+id+"','"+winame+"','left=0,top=0,width=100,height=100,resizable=yes,scrollbars=yes')";
        openwindow[winame]=eval(win);
    }
    else{openwindow[winame].focus()}
}
function Revisado(id){
    var elem = "chk_r_"+id;
    if(document.getElementById(elem).checked){
        document.getElementById(elem).disabled = true
        var URL = "../pl/set_expediente_revisado.pl?appid=LaUnion&lan=es&clase=empresa&id="+id+"&estado=1&elemento=revisado";
        xmlHttp	= GetXmlHttpObject(stateChangedSetRevisado);
        xmlHttp.open("GET",URL,true) ;
        xmlHttp.send(null);            
    }else{
        var URL = "../pl/set_expediente_revisado.pl?appid=LaUnion&lan=es&clase=empresa&id="+id+"&estado=0&elemento=revisado";
        xmlHttp	= GetXmlHttpObject(stateChangedSetRevisado);
        xmlHttp.open("GET",URL,true) ;
        xmlHttp.send(null);            
    }       
}
function stateChangedSetRevisado(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
        xmlHttpStream = xmlHttp.responseText;
        document.getElementById(xmlHttpStream).disabled = false;
    }
}
function Supervisado(id){
    var elem = "chk_s_"+id;
    if(document.getElementById(elem).checked){
        document.getElementById(elem).disabled = true
        var URL = "../pl/set_expediente_revisado.pl?appid=LaUnion&lan=es&clase=empresa&id="+id+"&estado=1&elemento=supervisado";
        xmlHttp	= GetXmlHttpObject(stateChangedSetRevisado);
        xmlHttp.open("GET",URL,true) ;
        xmlHttp.send(null);            
    }else{
        var URL = "../pl/set_expediente_revisado.pl?appid=LaUnion&lan=es&clase=empresa&id="+id+"&estado=0&elemento=supervisado";
        xmlHttp	= GetXmlHttpObject(stateChangedSetRevisado);
        xmlHttp.open("GET",URL,true) ;
        xmlHttp.send(null);            
    }
}
function stateChangedSetSupervisado(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
        xmlHttpStream = xmlHttp.responseText;
        document.getElementById(xmlHttpStream).disabled = false;
    }
}
function GestorAsignar(){
    var count = 0;
    var expe  = "";
    var exp_id = document.form.i8_user_id.value;
    var nombre = document.form.v32_lname.value+", "+document.form.v32_fname.value;    
    for (i=1; i<document.getElementById('grid').rows.length-1; i++){
        if(eval("document.form.chk_"+i+".checked")){
            document.getElementById('grid').rows[i].cells[9].innerHTML = exp_id;
            document.getElementById('grid').rows[i].cells[10].innerHTML = nombre;
            if(document.getElementById('grid').rows[i].cells[9].innerHTML!=""){
                expe += document.getElementById('grid').rows[i].cells[1].innerHTML+"|"+document.getElementById('grid').rows[i].cells[9].innerHTML+"~";
                count++;
            }
        }
    }
    document.form.str_expedientes.value = expe;
    if(count>0){document.form.submit();}else{alert("Favor Asigne Gestor..")}
}