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))+" de "+(String(year));
var openwindow  = new Object();
function OpenBalance(id,clase){
    var winame = "Balance";
    var fields = "";
    var values = "";
    if (!openwindow[winame] || openwindow[winame].closed){
	win ="window.open('../bin/bsws.pl?lan=es&appid=RTM_LaHerradura&clase="+clase+"_balance_financiamientos&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,clase){
    var winame = "Expediente";
    var fields = "";
    var values = "";
    if (!openwindow[winame] || openwindow[winame].closed){
	win ="window.open('../bin/REPT.pl?lan=es&appid=RTM_LaHerradura&clase="+clase+"s&id="+id+"&fields=&values=','"+winame+"','left=0,top=0,width=800,height=600,resizable=yes,scrollbars=yes')";
	openwindow[winame]=eval(win);
    }
    else{openwindow[winame].focus()}
}
function OpenNotificaciones(id,clase){
    var winame = "Notificaciones_"+id;
    if (!openwindow[winame] || openwindow[winame].closed){
	win ="window.open('../pl/notificaciones_p.pl?lan=es&appid=RTM_LaHerradura&clase="+clase+"&id="+id+"','"+winame+"','left=0,top=0,width=1000,height=700,resizable=yes,scrollbars=yes')";
	openwindow[winame]=eval(win);
    }
    else{openwindow[winame].focus()}
}
function OpenAdministrativo(id,clase){
    if(clase=="inmueble"){clase="inmueble_administrativo"}
    if(clase=="empresa"){clase="empresa_administrativo"}
    
    winame="Balance";
    var fields="";
    var values="";
    if (!openwindow[winame] || openwindow[winame].closed){
	win ="window.open('../bin/gdfl.pl?lan=es&appid=RTM_LaHerradura&clase="+clase+"&id="+id+"&fields="+fields+"&values="+values+"&dt_vencimiento=2008-07-31','"+winame+"','left=0,top=0,width=100,height=100,resizable=yes,scrollbars=yes')";
	openwindow[winame]=eval(win);
    }
    else{openwindow[winame].focus()}
}
function MarkAll(){
    var T     = document.getElementById('grid');
    var trows = T.rows;
    for (i = trows.length-2; i != 0; i--) {
	if(eval("document.form.chk_"+i+".checked")){
		eval("document.form.chk_"+i+".checked=false")
	}else{
		eval("document.form.chk_"+i+".checked=true")			
	}
    }
}
function GestionAgregar(){
    var lan   = document.form.lan.value;
    var appid = document.form.appid.value;
    var clase = document.form.clase.value;
    var id    = "";
    var openwindow;
    if (!openwindow || openwindow.closed){
	win ="window.open('../bin/rcrd.pl?lan="+lan+"&appid="+appid+"&clase="+clase+"_gestiones&id="+id+"','GestorGet','left=100,top=20,width=675,height=550,scrollbars=no,toolbar=no,menubar=no,resizable=no')";
	openwindow=eval(win);
    }else{openwindow.focus()}
}
function GestionCerrar(id,gid){
    var lan   = document.form.lan.value;
    var appid = document.form.appid.value;
    var clase = document.form.clase.value;
    var openwindow;
    if (!openwindow || openwindow.closed){
	win ="window.open('../pl/gestion_cerrar.pl?lan="+lan+"&appid="+appid+"&clase="+clase+"_gestiones&id="+id+"&gid="+gid+"','GestorGet','left=100,top=20,width=200,height=100,scrollbars=no,toolbar=no,menubar=no,resizable=no')";
	openwindow=eval(win);
    }else{openwindow.focus()}
    window.close();
}
function Recargar(){
   this.location.reload(true);
}
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..")}
}
function GestorDesAsignar(){
    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")){
		expe += document.getElementById('grid').rows[i].cells[1].innerHTML+"|"+document.getElementById('grid').rows[i].cells[9].innerHTML+"~";
		count++;
	}
    }
    document.form.str_expedientes1.value = expe;
    if(count>0){document.form.submit();}else{alert("Favor Asigne Gestor..")}
}