function selectSection() {
  var getsection = window.location.search.match(new RegExp("[?|&]?section=([^&]*)"));
  if(getsection)
    document.getElementById(getsection[1]).selected = "selected";
}

function handleField(elem, exp, txt, error) {
  var condition = !exp.test(elem.attr("value")), prevelem = elem.prev("label");

  if(condition) {
    prevelem.text(txt+" - "+error);
    if(!(/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)))
      elem.effect("pulsate", { times : 2 }, 200);
  } else {
    prevelem.text(txt);
  }
  
  prevelem.toggleClass("req", condition);
}

$(document).ready(function () {
  selectSection();
  $("#realname").change(function () { handleField($(this), /\S/, "Name", "This field is required."); });
  $("#email").change(function () { handleField($(this), /^[^@]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/, "Email", "Please enter a valid address."); });
});

var RecaptchaOptions = { theme : "clean", tabindex : 5 };
