//-------------------------------------------------------//
// Author:Rodolfo Machon
// Company:WebSoft, SA de CV 
// Nombre del archivo: inmueble_bsws.js
// Created: 2015-11-01
// Updates: 2015-11-01
// Copyright - All Rights Reserved
//-------------------------------------------------------//
//-------------------------------------------------------//
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();
mes		    = today.getMonth();
year 		= today.getFullYear();
weekday		= weekdays[weekday];
month 		= months[month];
dateString	= (String(weekday))+" "+(String(monthday))+" "+(String(month))+" , "+(String(year));
var xmlHttpStream;
//-------------------------------------------------------//
window.onload = function(){
        resizeTo(1000,700);
        setDate();
}
//-------------------------------------------------------//
function OpenLink(id,clase,nombre){
        var openwindow1;
	if (!openwindow1 || openwindow1.closed){
		win ="window.open('/cgi-bin/RTM_v30/pl/mora_cartera_sector_expedientes_p.pl?lan=es&appid=RTM_v30&clase="+clase+"&c11_sector_id="+id+"&v64_sector="+nombre+"','ReciboCuentasContables','left=100,top=20,width=675,height=550,scrollbars=yes,toolbar=no,menubar=yes,resizable=yes')";
		openwindow1=eval(win);
	}else{openwindow1.focus()}
}
function GenerarMoraSector(sector){
    var dr      = "NO";
    var dim     = days_in_month(document.form.year.value,(document.form.month.value*1)-1);
    var dt      = document.form.year.value+"-"+document.form.month.value+"-"+dim;
    var dt_corte= document.form.year.value+"-"+document.form.month.value+"-01";        
    var dt_corte1= document.form.year.value+"-"+document.form.month.value+"-"+dim;    
    var URL     = "/cgi-bin/RTM_v30/bin/gmswsp.pl?lan=es&appid=RTM_v30&clase=empresa&dt_vencimiento="+dt+"&dr="+dr+"&sector="+sector;
    alert(URL);
    xmlHttp	= GetXmlHttpObject(stateChanged);
    xmlHttp.open("GET",URL,true) ;
    xmlHttp.send(null);
    document.form.disabled = true;
}
function stateChanged(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
        xmlHttpStream=xmlHttp.responseText;
        location.reload();
    } 
}
function GetXmlHttpObject(handler){ 
    var objXmlHttp=null
    if (navigator.userAgent.indexOf("Opera")>=0){
        alert("This example doesn't work in Opera") 
        return 
    }
    if (navigator.userAgent.indexOf("MSIE")>=0){ 
        var strName="Msxml2.XMLHTTP"
        if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
                strName="Microsoft.XMLHTTP"
        }try{ 
                objXmlHttp=new ActiveXObject(strName)
                objXmlHttp.onreadystatechange=handler 
                return objXmlHttp
        }catch(e){ 
                alert("Error. Scripting for ActiveX might be disabled") 
                return 
        } 
    } 
    if (navigator.userAgent.indexOf("Mozilla")>=0){
        objXmlHttp=new XMLHttpRequest()
        objXmlHttp.onload=handler
        objXmlHttp.onerror=handler 
        return objXmlHttp
    }
}
function days_in_month (y, m) {
     return 32 - new Date(y, m, 32).getDate();
}
function setDate() {
    mes = (mes*1)+1;
    if(mes<10){
        mes = "0"+mes;
    }
    document.form.year.value=year;
    document.form.month.value=mes;    
}