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


function image_on_off(event) {
  img = event.element();
  if ( img.src.indexOf("_on.") != -1 ) {
    img.src = img.src.replace(/_on\./, "_off.");
  }else {
    img.src = img.src.replace(/_off\./, "_on.");
  }
}

// apply image swapping handler
Event.observe(window, 'load', function() {  
  $$('img.on_off').concat($$('input[type=image].on_off')).each( 
    function(e) { 
      Event.observe(e, "mouseover", image_on_off);  
      Event.observe(e, "mouseout", image_on_off);  
    }
  );
});


// update welcome/signin text if user is logged in
Event.observe(window, 'load', function() {  
  name = '';
  try {
    name = mlo.userInfo.name;
  }catch(e) {
    name = getCookie('mlo_name');
  }
  if ( name != null && name != 'null' && name.length > 0 ) {
    name = name.replace(/ .*/, '');
    href = 'http://svcs.mylifeonline.com/jsapi/submit/logoutredirect?link=' + escape('http://' + document.location.host);
    $('welcome').innerHTML = "Good to see you again " + name + "!" + "&nbsp;&nbsp;<a href='" + href + "' onclick=\"deleteCookie('mlo_username'); deleteCookie('mlo_name');\">Logout</a>";
  }
});

