/**
 * Constants: cookie expiration days when user sees or submits modal
 */
var DEFAULT_COOKIE_EXPIRATION_DAYS_SEEN=1
var DEFAULT_COOKIE_EXPIRATION_DAYS_SUBMIT=7


/**
 * Checks if user has seen the modal popup recently.
 * This returns false once the cookie expires.
 * 
 * @author mafoley
 * @return true if the seen_modal cookie exists and value is true 
 */
function has_seen_shadowbox() {
    return YAHOO.util.Cookie.get("seen_modal");
}

/**
 * Sets seen_modal cookie expiration date. If expiration date is not given,
 * defaults to the respective HTML expiration days for viewing/submitting the form.
 * 
 * @author mafoley
 * @param date_to_expire Optional Date object. null for default.
 * @param is_form_submit Optional boolean. true when submitting form, else just viewing it.
 * @return N/A
 */
function set_shadowbox_expiration(date_to_expire, is_form_submit) {
    var options = {
        path: "/",
        domain: "ncl.com"
    };

    if (date_to_expire) {
      options.expires = date_to_expire;
    }
    else {
      var expDays = null;
      if(is_form_submit) {
    	  expDays = DEFAULT_COOKIE_EXPIRATION_DAYS_SUBMIT;
      }
      else {
    	  expDays = DEFAULT_COOKIE_EXPIRATION_DAYS_SEEN;
      }

      var expDate = new Date();
      expDate.setTime(expDate.getTime()+1000*86400 * expDays);
      options.expires = expDate;
    }
      
    YAHOO.util.Cookie.set("seen_modal", "true", options);
}
