function isValid(type, str) {
  if (type.toLowerCase() == "email") {
    if ((str == null) || (str == "")) return false;
    var at="@";
    var dot=".";
    var lat=str.indexOf(at);
    var lstr=str.length;
    var ldot=str.indexOf(dot);
    if (str.indexOf(at)==-1) return false;
    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false;
    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false;
    if (str.indexOf(at,(lat+1))!=-1) return false;
    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false;
    if (str.indexOf(dot,(lat+2))==-1) return false;
    if (str.indexOf(" ")!=-1) return false;
    return true;
  }
};

(function($) {
  $(function() {
    $("input[type=text][title]").each(function() { $(this).val($(this).attr("title")); if($.trim($(this).val()) == "") $(this).val($(this).attr("title")); $(this).focus(function() { if($(this).val() == $(this).attr("title")) $(this).val(""); }).blur(function() { if($.trim($(this).val()) == "") $(this).val($(this).attr("title")); }); });
    $("a[href][rel*=external]").each(function() { $(this).attr("target", "_blank"); });
    $(".fade-hover").hoverIntent(function() { $(this).fadeTo("fast", 0.5); }, function() { $(this).fadeTo("fast", 1.0); });
    $(".lo").hoverIntent(function() { $(this).removeClass("lo").addClass("hi"); }, function() { $(this).removeClass("hi").addClass("lo"); });
    $("#page-heading").sifr({ path: "scripts/jquery/resources/", font: "vag rounded bt" });
    $("#email-marketing-form").submit(function() { return isValid("email", this.email.value); });
    $("#nav ul").fadeTo("fast", 0.9);
    Shadowbox.init();
  });
})(jQuery);