// empty
// 127.0.0.1 for testing, .know-zone.org for production

var myDomain="127.0.0.1"
//var myDomain=".know-zone.org"

// autoplay switch
var autoSwitch=getCookie("playIntro");
// if no cookie...
if (autoSwitch==null) {var autoSwitch="true";}

function openPopup(thisURL)
{
	window.open(thisURL,"PopupWindow","menubar=1,resizable=1,scrollbars=yes,width=685,height=510");
}

function turnAutoplayOff() {
	set_cookie("playIntro", false, 30, "/", myDomain, true);
	return null;
}

// primary function to retrieve cookie by name
function getCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) {
            return getCookieVal(j);
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break; 
    }
    return null;
}

function set_cookie(cookie_name, cookie_value, cookie_expire, cookie_path, cookie_domain, cookie_secure) {

  // erase cookie
  // eraseCookie(cookie_name)
   
  // Begin the cookie parameter string
  var cookie_string = cookie_name + "=" + cookie_value
  
  // Add the expiration date, if it was specified
  if (cookie_expire) {
    var expire_date = new Date()
    var ms_from_now = cookie_expire * 24 * 60 * 60 * 1000
    expire_date.setTime(expire_date.getTime() + ms_from_now)
    var expire_string = expire_date.toGMTString()
    cookie_string += "; expires=" + expire_string
  }
  
  // Add the path, if it was specified
  if (cookie_path) {
    cookie_string += "; path=" + cookie_path
  }

  // Add the domain, if it was specified
  if (cookie_domain) {
    cookie_string += "; domain=" + cookie_domain
  }
  
  // Add the secure Boolean, if it's true
  if (cookie_secure) {
    cookie_string += "; true"
  }
  
  // Set the cookie
  document.cookie = cookie_string
}

