if (isJsEnabled()) {
  addLoadEvent(weoLoad);
}



function clearText(thefield){
  if (thefield.defaultValue==thefield.value){
	  thefield.value = "";
	} 
}
function restoreText(thefield){
  if (thefield.value == "") {
    thefield.value = thefield.defaultValue;
  }
}




function weoLoad(){

roundCorners();
getDeo();
getLeo();
Event.observe('leo_link', 'click', showLists,false);
$("leo_link").onclick = function() {return false;};
Event.observe('deo_link', 'click', showDirectory,false);
$("deo_link").onclick = function() {return false;};
Event.observe('articles_link', 'click', function(e){showArticles()});

}

function roundCorners() {
  
if(!NiftyCheck())
    return;
RoundedTop("div#wrapper","#5ca8f0","#d6d7b6");
//RoundedTop("div#header li","transparent","#4d8eca");
//RoundedTop("li#work_link","transparent","#898989");
RoundedTop("li#work_link","#50a3f0","#999999");
RoundedTop("li#test_link","#50a3f0","#4d8eca");
RoundedTop("li#play_link","#50a3f0","#4d8eca");
RoundedTop("li#donate_link","#50a3f0","#4e98dd");
RoundedTop("li#articles_link","#d6d7b6","#ffffff","small");
RoundedTop("li#leo_link","#d6d7b6","#4d8eca","small");
RoundedTop("li#deo_link","#d6d7b6","#4d8eca","small");
//RoundedTop("div.comment-body","#ffffff","#f5f7e5");
RoundedBottom("div#footer","#90c1f0","#333333");
}

function getDeo()
	{
		var url = '/themes/weo/content/deo.ahah';
		
var myAjax = new Ajax.Updater( 'directory-content', url, { method: 'get'});

	}
function getLeo()
	{
		var url = '/themes/weo/content/leo.ahah';
var myAjax = new Ajax.Updater( 'lists-content', url, { method: 'get'});
	}



function showArticles() {
  Effect.Fade('lists-content');
  Effect.Fade('directory-content');
  return false;
}
function showLists(e) {
  Effect.Phase('lists-content',{duration:0.5});
      Effect.Fade('directory-content',{duration:0});
    Event.stop(e);
}

function showDirectory(e) {
  new Effect.Phase('directory-content',{duration:0.5});
    Effect.Fade('lists-content',{duration:0});
  //Effect.toggle('directory-content','slide',{duration:0.3});
    Event.stop(e);
}

// Resizable pre blocks, based on drupal textareas
//$Id: textarea.js,v 1.6 2006/03/09 23:20:24 unconed Exp $

if (isJsEnabled()) {
  addLoadEvent(function() {
    // Attach to all visible textareas
    textareas = document.getElementsByTagName('pre');
    var textarea;
    for (var i = 0; textarea = textareas[i]; ++i) {
      if (!hasClass(textarea, 'noresize')) {
        if (typeof dimensions(textarea).width != 'undefined' && dimensions(textarea).width != 0) {
          new textArea(textarea);
        }
      }
    }
  });
}

function textArea(element) {
  var ta = this;
  this.element = element;
  this.parent = this.element.parentNode;
  this.dimensions = dimensions(element);

  // Prepare wrapper
  this.wrapper = document.createElement('div');
  this.wrapper.className = 'resizable-textarea';
  this.parent.insertBefore(this.wrapper, this.element);

  // Add grippie and measure it
  this.grippie = document.createElement('div');
  this.grippie.className = 'grippie';
  this.wrapper.appendChild(this.grippie);
  this.grippie.dimensions = dimensions(this.grippie);
  this.grippie.onmousedown = function (e) { ta.beginDrag(e); };

  // Set wrapper and textarea dimensions
  this.wrapper.style.height = this.dimensions.height + this.grippie.dimensions.height + 1 +'px';
  this.element.style.marginBottom = '0px';
  this.element.style.width = '100%';
  this.element.style.height = this.dimensions.height +'px';

  // Wrap textarea
  removeNode(this.element);
  this.wrapper.insertBefore(this.element, this.grippie);

  // Measure difference between desired and actual textarea dimensions to account for padding/borders
  this.widthOffset = dimensions(this.wrapper).width - this.dimensions.width;

  // Make the grippie line up in various browsers
  if (window.opera) {
    // Opera
    this.grippie.style.marginRight = '4px';
  }
  if (document.all && !window.opera) {
    // IE
    this.grippie.style.width = '100%';
    this.grippie.style.paddingLeft = '2px';
  }
  // Mozilla
  this.element.style.MozBoxSizing = 'border-box';

  this.heightOffset = absolutePosition(this.grippie).y - absolutePosition(this.element).y - this.dimensions.height;
}

textArea.prototype.beginDrag = function (event) {
  if (document.isDragging) {
    return;
  }
  document.isDragging = true;

  event = event || window.event;
  // Capture mouse
  var cp = this;
  this.oldMoveHandler = document.onmousemove;
  document.onmousemove = function(e) { cp.handleDrag(e); };
  this.oldUpHandler = document.onmouseup;
  document.onmouseup = function(e) { cp.endDrag(e); };

  // Store drag offset from grippie top
  var pos = absolutePosition(this.grippie);
  this.dragOffset = event.clientY - pos.y;

  // Make transparent
  this.element.style.opacity = 0.5;

  // Process
  this.handleDrag(event);
}

textArea.prototype.handleDrag = function (event) {
  event = event || window.event;
  // Get coordinates relative to text area
  var pos = absolutePosition(this.element);
  var y = event.clientY - pos.y;

  // Set new height
  var height = Math.max(32, y - this.dragOffset - this.heightOffset);
  this.wrapper.style.height = height + this.grippie.dimensions.height + 1 + 'px';
  this.element.style.height = height + 'px';

  // Avoid text selection
  stopEvent(event);
}

textArea.prototype.endDrag = function (event) {
  // Uncapture mouse
  document.onmousemove = this.oldMoveHandler;
  document.onmouseup = this.oldUpHandler;

  // Restore opacity
  this.element.style.opacity = 1.0;
  document.isDragging = false;
}


