// funkiness for changing the login form when focussed
Event.observe(window, 'load', function() {
  DD_belatedPNG.fix('#case_study_banner .next, #footer a.engine');

  // IE is daft and we can't just change the type: we have to create a
  // whole new element of the new type and replace the old one
  var change_input_type = function(o, type) {
    var rep = document.createElement('input');
    rep.type = type;
    var props = ['value', 'name', 'id', 'size', 'className'];
    for (var n = 0; n < props.length; n++) {
      var prop = props[n];
      if (typeof o[prop] != 'undefined') { rep[prop] = o[prop]; }
    }
    o.parentNode.replaceChild(rep, o);
    return rep;
  }

  // handle a click in one of the login fields to hide the initial
  // text (and replace the 'password' field with an actual password
  var handle_click = function(event) {
    var e = Event.element(event);
    if (!e.hasClassName('active')) {
      e.value = '';
      e.addClassName('active');
      if (e.hasClassName('is_password')) {
        // IE needs to replace the input element, not just change the type
        if (/msie/i.test(navigator.userAgent)) {
          var rep = change_input_type(e, 'password');
          // we also want to focus, but need to wait a mo for the element to be drawn
          setTimeout(function() { rep.focus(); }, 10);
        // proper browsers can just change the input type on the fly
        } else { e.type = 'password'; }
      }
    }
  }

  // watch for focus within the email and password fields
  if ($('login_email') && $('login_passw')) {
    Event.observe($('login_email'), 'focus', function(e) { handle_click(e); });
    Event.observe($('login_passw'), 'focus', function(e) { handle_click(e); });
  }

	// find anything with a tooltip attribute and use it as a tooltip
  $$('a[tooltip]').each(function(tip) {
    new Control.Modal(tip, {
			hover: true,
			position: 'relative',
			offsetLeft: 27,
			offsetTop: -40,
			containerClassName: 'tooltipContainer',
			contents: function() {
			  return '<div class="tooltip"><div class="sub">'+ tip.readAttribute('tooltip') +'</div></div>';
			}
		});
  });
  
  $$('.moooore').each(function(ele){
    ele.hide();
  });
  
  $$('.more_things').each(function(ele){
    $(ele).observe('click', function(){
      $(ele).next('.moooore').toggle();
      return false;
    });
  });

});

function caseStudyPage(which) {
  new Ajax.Updater('case_study_page', '/case-study-page/' + which, {method:'get'});
}

//function clientList(category, page_no) {
  // new Ajax.Updater('client-list', '/clients/' + category, { parameters: { page: page_no }, method:'get' });

	//jQuery.getScript('/clients/' + category + '?page=' + page_no );	

//}

