var urlroot = window.location.host.indexOf('idium.n') !== -1 ? window.location.pathname.substring(0,window.location.pathname.indexOf('/',2)) + "/" : "/";

function popUp(URL) {
 day = new Date();
 id = day.getTime();
 eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,location=0,statusbar=0,menubar=0,resizable=1,width=595,height=600,left = 342.5,top = 212');");
 setTimeout("checkPop('"+id+"', '"+URL+"')", 2000);
}

function checkPop(id, URL) {
 eval("obj = page"+id+";")
 if (obj==undefined) {
  document.location = URL;
 }
}

function printPage(){
 window.print();
}

function printSubmit() {
  el = document.getElementById('product_display');
  document.getElementById('print_html').value = el.innerHTML;
  document.getElementById('print_form').submit();
}

function goFigure(linkObj) {
 var attr = document.createAttribute('target');
 attr.value = '_blank';
 linkObj.setAttributeNode(attr);
}

function isValidEmail(str) {
  return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}
jQuery(document).ready(function($) {
  $("#newsletterForm").live("submit",function(e) {
    e.preventDefault();

  if(isValidEmail(jQuery("input[name='newuser_email']").val())) {
    $.post(urlroot,$(this).serialize(),function() {
      alert("Du er registrert!");
    });
  }
  else {
    alert("Vennligst skriv en gyldig e-postadresse.");
  }
  });  
});
var submitForm = function(form) {
//
}
