// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function destroy_action(elem,href) {
    
    if (confirm('Are you sure?')) { 
        var f = document.createElement('form');
        f.style.display = 'none'; 
        elem.parentNode.appendChild(f); 
        f.method = 'POST';
        f.action = href;
        var m = document.createElement('input');
        m.setAttribute('type', 'hidden'); 
        m.setAttribute('name', '_method');
        m.setAttribute('value', 'delete'); 
        f.appendChild(m);
        var s = document.createElement('input'); 
        s.setAttribute('type', 'hidden');
        s.setAttribute('name', 'authenticity_token'); 
        s.setAttribute('value', AUTH_TOKEN); 
        f.appendChild(s);
        f.submit();
    };

    return false;
}

function booleanFormatter(elCell, oRecord, oColumnm, oData ) {
    elCell.innerHTML = oData == "1" || oData == "true" ? "Yes" : "No";
}

document.observe("dom:loaded", function() { 
    if ( $("notice") ) {
        $("notice").style.visibility = "visible";
        setTimeout(hideFlashMessages, 1000);
    }
});

function hideFlashMessages() {
  $$('p#notice, p#warning, p#error, p#ajax_notice').each(function(e) { 
    if (e) {
        Effect.Fade(e, { duration: 10.0 });
    } 
  });
}

function showAjaxFlashMessages( msg ) {
  $('ajax_notice').update( msg );
  $("ajax_notice").style.visibility = "visible";
  setTimeout( hideFlashMessages, 1000 );
}
