/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
var reloadTimer;

function setReloadTime(secs,page)
{
    if (arguments.length == 1) {
        if (reloadTimer) clearTimeout(reloadTimer);
        reloadTimer = setTimeout("setReloadTime()", Math.ceil(parseFloat(secs) * 1000));
    }
    else {
        if (page) {
            location.replace(page);
        } else {
            location.reload();
        }

    }
}

function processLogin(data){
    var status=$('#login .status');
    status.html(data);
    status.show();
    if(data=='login success'){
        setReloadTime(2,'http://www.carmelitesisters.ie/index.php?article=members_index');
    }
}
function processLogoff(data,status){
    if(status=='success'){
        var status=$('#login .status');
        status.html('logout success');
        status.show();
        setReloadTime(2);
    }

}


$(document).ready(function(){
    $('#login form').submit(function() {
      var data;
      data='Submit=Login&api=1&';
      data+=$(this).serialize();
      
      //alert(data);
      $.post("ewrite/check.php",data,processLogin);
      return false;
    });
    $('#logout').click(function() {
        $.get("ewrite/logoff.php",processLogoff);
    });


});

