﻿function init(evt)
{
    clock();
    
    OrderByTable("table_data_imoveis");    
    setConfigFieldsForms();  
    
}
Initialize.add(init);
//---------------------------

function sendMail(_this)
{
    var f = getElementFather(_this, "form");
    if(isFieldsValid(f))
    {
        if(dialog("Enviar email agora!"))
        {            
            "status_sendmail".setValue("Aguarde, enviando e-mail...");  
            StandByButton(_this);
            RemoteObject
            (
                "handlers/sendMail.ashx",
                getValuesJson(f),
                function(data)
                {
                    StandByButton(_this);
                    "status_sendmail".setValue(data.html);                
                },
                true
            ); 
        }      
    }
}

//--------------------------------------------------------

function clock()
{
    var hr = "", dt = new Date();
    var miliss = "milliseconds_server".getValue().toDate().getTime();
    setInterval( 
        function()
        {
            miliss += 1000;
            dt.setTime(miliss);
            var h = dt.getHours();
            var m = dt.getMinutes()
            var s = dt.getSeconds();
            hr = (h<10 ? "0"+h : h) + ":" + (m<10 ? "0"+m : m) + ":" + (s<10 ? "0"+s : s);
            "label_hours".setValue(hr);
        },
        1000
    );
}

//--------------------------------------------------------

function getDetailsImovel(row)
{
    windowPopup("details", "details.aspx?id=" + (typeof row=="number" ? row : row.cells[0].innerHTML), 970, 550, true);
    return void(0);
}