//Place the URL of the pop up page. You create this page like you
//would any other HTML page and upload it to your server.
//If you don't understand, you're on your own.

var url = "mailinglist/mailinglist.asp";

//How wide do you want your pop up window?
var wwidth = "350";
//The window Height.
var wheight = "250";
//How far left?
var wleft = "10";
//How far from the top?
var wtop = "5";

// Original JavaScript code by Duncan Crombie: dcrombie@chirp.com.au
// Please acknowledge use of this code by including this header.

  var bikky = document.cookie;

  function getCookie(name) { // use: getCookie("name");
    var index = bikky.indexOf(name + "=");
    if (index == -1) return null;
    index = bikky.indexOf("=", index) + 1;
    var endstr = bikky.indexOf(";", index);
    if (endstr == -1) endstr = bikky.length;
    return unescape(bikky.substring(index, endstr));
  }

  var today = new Date();
  var expiry = new Date(today.getTime() + 30 * 24 * 60 * 60 * 1000); // plus 28 days
  var expired = new Date(today.getTime() - 30 * 24 * 60 * 60 * 1000); // less 28 days

  function setCookie(name, value) { // use: setCookie("name", value);
    if (value != null && value != "")
      document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString();
    bikky = document.cookie; // update bikky
    return getCookie(name) != null; // return false if the cookie was refused
  }

  function deleteCookie(name) { // use: deleteCookie("name");
    document.cookie=name + "=null; expires=" + expired.toGMTString(); // delete cookie
    bikky = document.cookie; // update bikky
    formatCookie(); // display cookie content
  }

  function disableMailing() { // make sure the cookie is set
    var form = document.forms[0];
    while (!setCookie('displayMailing','false')) {
      if (!confirm('The cookie was not accepted by your browser\nYou must allow cookies to use this page')) {
        alert('By refusing our harmless cookie strings\nyou are preventing this page from operating correctly\n');
        //history.back(); // take them out of the page
        break;
      }
    }
    formatCookie(); // display cookie content
  }
  
  function enableMailing() { // make sure the cookie is set
    var form = document.forms[0];
    while (!setCookie('displayMailing','true')) {
      if (!confirm('The cookie was not accepted by your browser\nYou must allow cookies to be able to get a newsletter')) {
        alert('By refusing our harmless cookie strings\nyou are preventing this page from operating correctly\n');
        //history.back(); // take them out of the page
        break;
      }
    }
    formatCookie(); // display cookie content
  }
  
  function formatCookie() {
    var retValue = "";
    with (bikky) {
      for (var i=0; i < length; i++)
        retValue += (charAt(i) != " ") ? charAt(i) : "\n";
    }
    return retValue;
  }

// Mailing
//deleteCookie('displayMailing');
//enableMailing();
//disableMailing();
//alert(getCookie('displayMailing'));


if (!getCookie('displayMailing')) {
	//open(url,'HB',"toolbar=0,location=0,status=1,menubar=0,scrollbars=1,resizable=0, width=" + wwidth + ",height=" + wheight + ", left=" + wleft + ", top=" + wtop); 
}

function openNewsLetterSubscription(){
	open(url,'HB',"toolbar=0,location=0,status=1,menubar=0,scrollbars=1,resizable=0, width=" + wwidth + ",height=" + wheight + ", left=" + wleft + ", top=" + wtop); 
}


