var animateOver = function(event, el, doc) {
  el = new YAHOO.util.Element(el);
  var bg = new YAHOO.util.ColorAnim(el, {backgroundColor: {to: "9C9D9F", from: "B9BABC"}, color: {to: 'FFFFFF'} }, .25);
  bg.animate();
}

var animateOut = function(event, el, doc) {
  el = new YAHOO.util.Element(el);
  var bg = new YAHOO.util.ColorAnim(el, {backgroundColor: {to: "B9BABC"}, color: {to: "2D2E2E"} }, .25);
  bg.onComplete.subscribe(function() {
    el.setStyle("backgroundColor", "transparent");
  });
  bg.animate();
}

YAHOO.util.Event.delegate("doc", "mouseenter", animateOver, ".a0");
YAHOO.util.Event.delegate("doc", "mouseleave", animateOut, ".a0");

var animateArrowOver = function(event, el, doc) {
  el = new YAHOO.util.Element(el);
  var bg = new YAHOO.util.ColorAnim(el, {backgroundColor: {to: "C5C6C7"} }, .25);
  bg.animate();

  domArrow = el.getElementsByClassName("arrow")[0];
  if(domArrow) {
    arrow = new YAHOO.util.Element(domArrow);
    var motion = new YAHOO.util.Anim(arrow, {left: { to: 185}}, .35);
    motion.animate();
  }
}

var animateArrowOut = function(event, el, doc) {
  el = new YAHOO.util.Element(el);
  var bg = new YAHOO.util.ColorAnim(el, {backgroundColor: {to: "939597"} }, .25);
  bg.animate();

  domArrow = el.getElementsByClassName("arrow")[0];
  if(domArrow) {
    arrow = new YAHOO.util.Element(domArrow);
    var motion = new YAHOO.util.Anim(arrow, {left: { to: 175}}, .35);
    motion.animate();
  }
}

YAHOO.util.Event.delegate("doc", "mouseenter", animateArrowOver, ".animate-arrow");
YAHOO.util.Event.delegate("doc", "mouseleave", animateArrowOut, ".animate-arrow");

function validate(frm) {
  var nodes = YAHOO.util.Selector.query('.required');
  var errors = "";
  for(i=0; i<nodes.length; i++) {
    if(nodes[i].value == '') {
      errors += "- " + nodes[i].title + "\n";
    }
  }
  if(errors != '') {
    alert('Please enter the following information:\n\n' + errors);
    return false;
  }
  return true;
}

function openPopupWindow(url, width, height, scrolling, name) {
  if (!width) width = 350;
  if (!height) height = 350;
  if (!scrolling) scrolling = "no";
  if (!name) name = "win"+Math.round(Math.random()*1000);

  features = "width="+width+","
           + "height="+height+","
           + "toolbar=no,"
           + "location=no,"
           + "status=no,"
           + "menubar=no,"
           + "scrollbars="+scrolling+","
           + "top="+(window.screen.height-height)/2+","
           + "left="+(window.screen.width-width)/2;
  win = window.open(url,name,features);
  win.focus();
  //return win;
}
