/**
    @file
    @brief Base JavaScript Library for Imperium
    $Id: imperium.js 1112 2008-08-16 18:58:08Z david.busby $
*/

function ajax_view(u)
{
    $('#ajax-view').load(u,function() {
        $('#ajax-view').show();
    });
    return false;
}

// func: pop_big(e) - Pops this element over-itself in bigger font
function pop_big(e)
{
    var e = $(e);
    
    var be = document.createElement('div');
    // be.className = 'pc';
    // be.onclick = function() { be.parentNode.removeChild(be); }

    var te = document.createTextNode( e.html() );
    be.appendChild( te );
    
    document.body.appendChild(be);
    
    var l = (e.offset().left) - ($(be).width() / 2);
    var t = e.offset().top - ($(be).height() / 2);

    // @todo Detect if Displayed off Screen and Correct?
    $(be).css('left',l);
    $(be).css('top',t);
    $(be).show('slow');
}

// func: pop_map(x)
function pop_map(x)
{
    var u = 'http://maps.google.com/maps?f=q&hl=en&ie=UTF8&om=1&q=' + x;
    pop_window(u);
}

// func: pop_window(u)
function pop_window(u)
{
    var f = 'fullscreen=no,toolbar=yes,status=no,menubar=yes,scrollbars=yes,resizable=yes,directories=no,location=yes,width=800,height=600,left=20,top=20';
    var n = 'imperium_pop';
  var w = window.open(u,n,f);
  if (w) {
        w.focus();
    }
}

function toNumeric(e,l)
{
    if (!l) {
        l = 4;
    }
    var n = parseFloat(e.value ? e.value : 0);
    if (isNaN(n)) {
        n = 0;
    }
    e.value = parseFloat(n).toFixed(l);
}

