// stripped down - original at http://static.ak.facebook.com/js/base.js

// === Get/Hide/Show/Toggle ===

function ge()
{
  var ea;
  for( var i = 0; i < arguments.length; i++ ) {
    var e = arguments[i];
    if( typeof e == 'string' )
      e = document.getElementById(e);
    if( arguments.length == 1 )
      return e;
    if( !ea )
      ea = new Array();
    ea[ea.length] = e;
  }
  return ea;
}


// === Event Attaching ===
// (see: http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html)

function addEvent(obj, type, fn, name_hash)
{ 
    if (obj.addEventListener)
        obj.addEventListener( type, fn, false );
    else if (obj.attachEvent)
    { 
                obj["e"+type+fn+name_hash] = fn;
        obj[type+fn+name_hash] = function() { obj["e"+type+fn+name_hash]( window.event ); }
        obj.attachEvent( "on"+type, obj[type+fn+name_hash] );
           
    } 
}     
    
  
// why name_hash? So you can use the same function and pass different name_hashes and ie won't get confused
function removeEvent(obj, type, fn, name_hash)
{
    if (obj.removeEventListener)
        obj.removeEventListener( type, fn, false );
    else if (obj.detachEvent)
    {
        obj.detachEvent( "on"+type, obj[type+fn+name_hash] );
        obj[type+fn+name_hash] = null;
        obj["e"+type+fn+name_hash] = null;
    }
}


// === Placeholder Text ===

function placeholderSetup(id) {
  var el = ge(id);
  if(!el) return;
  /*if(el.type != 'text') return;*/

  var ph = el.getAttribute("placeholder");
  if( ph && ph != "" ) {
    el.value = ph;
    el.style.color = '#777';
    el.is_focused = 0;
    addEvent(el, 'focus', placeholderFocus);
    addEvent(el, 'blur', placeholderBlur);
  }          
}            
             
function placeholderFocus() {
  if(!this.is_focused) {
    this.is_focused = 1;
    this.value = '';
    this.style.color = '#000';

    var rs = this.getAttribute("radioselect");
    if( rs && rs != "" ) {
      var re = document.getElementById(rs);
      if(!re) { return; }
      if(re.type != 'radio') return;

      re.checked=true;
    }
  }
}

function placeholderBlur() {
  var ph = this.getAttribute("placeholder")
  if( this.is_focused && ph && this.value == "" ) {
    this.is_focused = 0;
    this.value = ph;
    this.style.color = '#777';
  }
}

