/*
 *  @author:   Bryan Bramlett
 *  @email:    <bbramlett1@atu.edu>
 *  @created:  Fri May  7 15:54:01 CDT 2010
 *
 *  @filename: core.js
 *
 *  @purpose:
 *    This file contains the core javascript code that is needed to make
 *    the template work.
 *
 */

function load() {
  var page=window.location.pathname.split('/')[(window.location.pathname.split('/').length - 1)];

  if(page.match(/index/) || page == "") {
    set_top_menu_ends();
  }
  set_search_event();
}

function set_top_menu_ends() {
  try {
    var tm = document.getElementById('top_menu');
    if(tm!= null) {
      var iml = './images/atu-top-menu-left.png';
      var imr = './images/atu-top-menu-right.png';

      var nil = document.createElement('img');
      var nir = document.createElement('img');
      nil.setAttribute('alt', 'ATU Top Menu End Image');
      nir.setAttribute('alt', 'ATU Top Menu End Image');
      nil.setAttribute('src', iml);
      nir.setAttribute('src', imr);

      tm.insertBefore(nil, tm.getElementsByTagName('UL')[0]);
      tm.appendChild(nir);
    }
  }
  catch(e) {}
}

function set_search_event() {
  document.getElementById('search').onfocus = function() {
    if(document.getElementById('search').value == 'Search') document.getElementById('search').value = '';
  };
  document.getElementById('search').onblur = function() {
    if(document.getElementById('search').value == '') document.getElementById('search').value = 'Search';
  };
};

window.onload = load;

