// Get cookie
function getCookie(cookieName) {
    var cookieStart = -1;
    var cookieEnd = -1;
    var cookieValue = "";
	if(document.cookie.length > 0) {
	  cookieStart = document.cookie.indexOf(cookieName.concat("="));
	  if(cookieStart!=-1) {
	    cookieStart = cookieStart + cookieName.length + 1;
	    cookieEnd = document.cookie.indexOf(";", cookieStart);
	    if(cookieEnd == -1)
	       cookieEnd = document.cookie.length;
	    cookieValue = unescape(document.cookie.substring(cookieStart, cookieEnd));
	    }
	  }
	return cookieValue;
}
// Set cookie
function setCookie(cookieName, value, expireDays) {
	var expirationDate = new Date();
	expirationDate.setDate(expirationDate.getDate() + expireDays);
	document.cookie = cookieName.concat("=").concat(escape(value)).concat(
	   (expireDays == null ? "" : ";expires=".concat(expirationDate.toGMTString())));
}
// Create a popup window by the name specified for the url
function popupWindow(windowName, url) {
    window.open(url, windowName,'width=400,height=400,resizable=yes,scrollbars=yes');
    return false;
}
// Add a cookie to prevent repeat displays of the landing page
function addCookie(path, promo, ncid, cookie) {
    var url = path;
    if(promo != null)
        url = url.concat('?promo=').concat(promo);
    if(ncid != null)
        url = url.concat(url.lastIndexOf('?', path.length) >= path.length ? "&" : "?").concat('ncid=').concat(ncid);
    if(new Boolean(getCookie(cookie)) == false)
        setCookie(cookie, true, 365);
    document.location.replace(url);
    return false;
}