function regError(msg)
{
  alert(msg);
}

// This block of code fixes the bug in Flash and IE where a flash object
// embedded only with the embed tag will cause an Object Expected error
// when the page is unloaded.
// It works by rewriting the __flash__removeCallback function with a better version every 100 ms
(function(){var s=function(){__flash__removeCallback=function(i,n){if(i)i[n]=null;};window.setTimeout(s,100);};s();})();


var cur_subnav;

function showSubNav(name)
{
  //console.debug('showSubNav: ' + name + ' [currently: ' + cur_subnav + ']');
  if (name != cur_subnav)
  {
    $('.subnav').fadeOut('fast');
    $('#navigation>div').removeClass('selected');
    
    $('#nav-' + name).addClass('selected');
    if (name == 'membership')
      $('#subnav-membership').width(200).css('right', '462px');
    $('#subnav-' + name).fadeIn('slow');
  }
  cur_subnav = name;
}

function showHomepageHeader()
{
  //console.debug('showHomepageHeader');
  var div = document.getElementById('header');
  div.style.height = '305px';
  div.style.backgroundImage = 'url(/images/udma-hp-header.jpg)';
  div.innerHTML = '<div id="hp-intro-text">' + document.getElementById('noshow').innerHTML + '</div>';
  document.getElementById('header-gap').style.height = '320px';
}

function showSubpageHeader(section)
{
  //console.debug('showSubpageHeader: ' + section);
  var div = document.getElementById('header');
  div.style.height = '130px';
  div.style.backgroundImage = 'url(/images/udma-header-' + section + '.jpg)';
  div.innerHTML = '<img src="/images/udma-logo.png" width="173" height="118" alt="UDMA Logo" />';
  document.getElementById('header-gap').style.height = '142px';
}


function loadPage(page) {
  var oRPC = new jsRPC();
  if (page.indexOf('?') != -1)
    oRPC.href = '/' + page + '&html_load=1';
  else
    oRPC.href = '/' + page + '/?html_load=1';
  oRPC.execute();    
}

function onHTMLLoader_load(href)
{

}
      
      
  function qs_replace(qs, name, value)
  {
    name = name.toLowerCase();
    qs = qs.toLowerCase();
    loc = qs.indexOf('?' + name + '=') + 1;
    
    if (loc == 0)
      loc = qs.indexOf('&' + name + '=') + 1;
    var t;
    
    if (loc == 0)
    {
      // simplest case, the attribute does not exist in the qs
      if (value.length)
      {
        if (qs.length)
          t = qs + '&' + name + '=' + escape(value);
        else
          t = qs + name + '=' + escape(value);
      }
      else t = qs;
    }
    else
    {
      end_loc = qs.substr(loc, qs.length).indexOf('&') + loc;
      t = '';
      // if not the first item in the list, prepend the start of the list
      if (loc > 1)
        t += qs.substr(0, loc);
      
      if (value && value.length)
        t += name + '=' + escape(value);
      
      // if not the last item in the list, append the rest of the list
      if (end_loc > loc)
        t += qs.substr(end_loc);
    }
  
    while (t.indexOf('&&') != -1)
      t = t.replace('&&', '&');
      
    while (t.substr(t.length - 1) == '&')
      t = t.substr(0, t.length - 1);

    while (t.substr(t.length - 1) == '?')
      t = t.substr(0, t.length - 1);
      
    return t;
  }
  

