function popUp(URL) {
    popUpSize(URL, 410, 700);
}
function popUpSize(URL, ww, hh) {
 day = new Date();
// id = day.getTime();
 id = "popMe_" + day.getTime();
 eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,location=0,statusbar=0,menubar=0,resizable=1,width="+ww+",height="+700+",left = 342.5,top = 212');");
 setTimeout("checkPop('"+id+"', '"+URL+"')", 2000);
}
function popPage(URL) {
    popPageSize(URL, 1024, 768);
}
function popPageSize(URL, ww, hh) {
 day = new Date();
// id = day.getTime();
 id = "popPage_" + day.getTime();
 eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,location=0,statusbar=0,menubar=0,resizable=1,width=" + ww + ",height=" + hh + ",left = 0,top = 0');");
 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('content');
    document.getElementById('print_html').value = el.innerHTML;
    el = document.getElementById('print_form');
    el.target = "_blank";
    el.submit();
}
function checkPageSize() {
    if (window.name.substring(0,5)=='popMe') {
        setPageSize(410, 600);
    }
}
function checkPageSize2() {
    if (window.name.substring(0,5)=='popMe') {
        ol_setPageSize(410, 600);
    }
}
function ol_setPageSize(old_width, old_height) {
    el = document.getElementById('popcontent');
    new_height = old_height;
    new_width = old_width;
    if (el.offsetHeight) {
        new_height = el.offsetHeight + 58;
        new_width = el.offsetWidth + 10;
  } else if (el.style.pixelHeight) {
        new_height = el.style.pixelHeight + 58;
        new_width = el.style.pixelWidth + 10;
  }
    window.resizeTo(new_width, new_height);
}
function setPageSize(old_width, old_height) {
    el = document.getElementById('popcontent');
    img =document.getElementById('prodImg');
    new_width = old_width;
    new_height = old_height;
    if (img.offsetHeight) {
        new_width = img.offsetWidth + 28;
    } else if (img.style.pixelWidth) {
        new_width = img.style.pixelWidth + 28;
    }
    window.resizeTo(new_width, new_height);

    new_height = old_height;
    if (el.offsetHeight) {
        new_height = el.offsetHeight + 58;
  } else if (el.style.pixelHeight) {
        new_height = el.style.pixelHeight + 58;
  }
    window.resizeTo(new_width, new_height);
}
function isEmail (sEmail) {
var regEmail = 
 /^([\w-]+\.?)*\w+@([\da-zA-z-]+\.)+[a-zA-z]{2,3}$/
 if (sEmail==null || sEmail == "") { 
  if (isEmail.arguments.length == 1) return true;
 else {return (isEmail.arguments[1] == true);}
 } else {
   return regEmail.test(sEmail)
 }
}
function isElEmail(el) {
    if (el.value.length < 6) {
        alert("'" + el.value + "' er ikke en gyldig e-postadresse");
        el.focus();
        return false;
    } else if (!isEmail(el.value)) {
        alert("'" + el.value + "' er ikke en gyldig e-postadresse");
        el.focus();
        return false;
    } else {
        return true;
    }
}
function validateTip() {
    if (!isElEmail(document.getElementById('recipientEmail'))) {
        return false;
    } else if (!isElEmail(document.getElementById('senderEmail'))) {
        return false;
    } else {
        return true;
    }
}

function goFigure(url) {
  /*  psfile://    */
  if (url.indexOf('psfile://') != -1) {
    url = url.replace('psfile://','./?module=Files;action=File.getFile;ID=');
  }

  /*  psm://    */
  if (url.indexOf('psm://') != -1) {
    url = url.replace('psm://','mailto:');
  }

  /*  psf://    */
  if (url.indexOf('psf://') != -1) {
    url = url.replace('psf://','./?module=Articles;action=ArticleFolder.publicOpenFolder;ID=');
  }

  /*  ps://    */
  if (url.indexOf('ps://') != -1) {
    url = url.replace('ps://','');
    if (url.indexOf(';')) {
      url = url.substring(url.indexOf(';')+1,url.length);
    }
    url = './?module=Articles;action=Article.publicShow;ID=' + url;
  }

  /*  psff://    */
  if (url.indexOf('psff://') != -1) {
    url = url.replace('psff://','./?module=Files;action=FileFolder.publicDisplay;ID=');
  }
  window.open(url);
}
function goTarget(url) {
  window.open(url);
}