var accord = null;
var currentAccoridionIndex = 0;
$(document).ready(function () {

    //$('.column').equalHeights();
    accord = $("#stepForm").accordion();

    $('.main_menu').supersubs({
        minWidth: 16,   // minimum width of sub-menus in em units 
        maxWidth: 50,
        extraWidth: 1     // extra width can ensure lines don't sometimes turn over 
    }).superfish({ autoArrows: false });

    $('.li_level_2').hover(function () {
        if ($(this).children().length == 1) {
            $(this).addClass('sfHover_single');
        }
        else {
            $(this).addClass('sfHover');
        }
    },
      function () {
          if ($(this).children().length == 1) {
              $(this).removeClass("sfHover_single");
          }
          else {
              $(this).removeClass("sfHover");
          }
      });
});

(function ($) {
    $.fn.equalHeights = function (options) {
        if (!this.length) return this;

        var maxHeight = tallest = 0;

        $(this).each(function () {
            var $this = $(this);
            if ($this.height() > tallest) {
                tallest = $this.height();
            }
        });

        maxHeight = tallest;

        return this.each(function () {
            $(this).css({ 'min-height': maxHeight });

            if ($.browser.msie && $.browser.version == 6.0) {
                $(this).css({ 'height': maxHeight });
            }
        });
    };
})(jQuery);

function clearErrors() {
  $('.req_input').removeClass("warning");
}

function processInputItems(formClassName) {
    var errorCount=0;
  clearErrors();
  $('.' + formClassName + ' .req_input').each(function (i) {
    var item = $(this);
    if (item.val() == "") {
            errorCount++;
      item.addClass("warning");
      attachKeyUp($(this));
    }
  });
    return errorCount;
}

function validateForm(formID) {
    var errorCount = processInputItems(formID);
    if(errorCount == 0) {
        return true;
    } 
    else {
        return false;
    }
}

function attachKeyUp(item) {
  item.keyup(function () {
    if ($(this).val() != "")
      $(this).removeClass("warning");
  });
}
