// DASH.js
jQuery(document).ready(function($){
  $("a.externalLink").attr("target", "_blank");
  var emailpattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 
  // Add class for styles that need JS to be activated
  jQuery("body").addClass("jsloaded");
  // Searchform label is placed above searchfield, and need to be removed on field focus
  var $searchField = jQuery("input.query"); // Cache
  var $label = $searchField.parent().find("label"); // Cache
  $searchField.focus(function(){
    $label.hide();
  });
  $label.click(function(){
    $searchField.focus();
  });
  // CHECK IF SEARCHFIELD IS EMPTY AFTER LOAD
  if($searchField.val() !== "") {
    $searchField.focus();
  }
  jQuery("#newsletterForm").submit(function(e){
    e.preventDefault();
    var $this = jQuery(this); //cache
    var $email = $this.find("input.text"); //cache
    if(!$this.find(".response").get()[0]) {
      jQuery("<div class='response' />").prependTo($this);
    }
    var $response = $this.find(".response"); // Cache
    if (emailpattern.test($email.val())) {
      $response.text("Sender...");
      $.ajax({
        url: "?template=newsletter-no;ajax=true;",
        data: $this.serialize(),
        error: function() {
          $response.text("Feil / Error");
        },
        success: function(data) {
          $response.text($(data, ".response").text());
          $email.removeClass("error").val("");
        }
      });
    } else {
      $email.addClass("error");
      $response.text("E-post er ikke utfyllt korrekt!");
    }
  });
   
    $("a[rel]").lightBox();
});
// FROM functions.js
function newTarget(B){var A=document.createAttribute("target");A.value="_blank";B.setAttributeNode(A)}function popUp(B,C,A){window.open(B,"popup","toolbar=0,location=0,statusbar=0,menubar=0,resizable=1,scrollbars=yes,width="+C+",height="+A+",left = 100,top = 50")}function validateEmail(A){return A.value.match(/^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-z]{2,6}$/)};