/*
 * WNCOutdoors.info Namespace

 * This script is free and unencumbered software released into the
 * public domain. It comes without any restrictions on what you may
 * do with it, and with no warranty whatsoever. Assume nothing works,
 * and you may be pleasantly surprised; and when it breaks, you get
 * to keep both pieces.
 * @requires: prototype.js
 * @requires: livePipe UI
*/
( function( WNCO, $, undefined ) {
  // Private Properties
  var locStr = window.location.toString();
  var domain = locStr.match( /hikewnc/i ) ? 'hikewnc.info' : 'mtbikewnc.com';
  var subdomain =  locStr.match( /test/i ) ? 'test' : 'www';
  var hostname  = window.location.hostname;
  var site = domain.match( /hikewnc/ ) ? 'hike' : 'bike';
  
  var COOKIE_DEFAULTS = {
    expiryDays: 7
  };
  
  // Private Methods
  /*
  function functionName( arg ) {
    this.foo = arg;
  }
  */

  // Public Properties
  WNCO.cfg = {
    domain: domain,
    subdomain: subdomain,
    hostname: hostname,
    site: site
  };
  
  // Public Methods  
  WNCO.setCookie = function( name, value, days ) {
    if (!days) {
      var days = COOKIE_DEFAULTS.expiryDays;
    }
 
    var date = new Date();
    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
    var expires = "; expires=" + date.toGMTString();
 
    document.cookie = name + "=" + value + expires + "; path=/";
 
    return {"name": name, "value": value};
  };
 
  WNCO.getCookie = function( name ) {
    var nameEQ = name + "=";
    var ca = $A(document.cookie.split(";"));
    for (var i=0; i<ca.length; i++) {
      c = ca[i];
      while (c.charAt(0) == " ") {
        c = c.substring(1, c.length);
      }
      if (c.indexOf(nameEQ) == 0) {
        return c.substring(nameEQ.length, c.length);
      }
    }
    return "";
  };
 
  WNCO.unsetCookie = function( name ) {
    this.setCookie(name, "", -1);
    return {"name": name, "value": null};
  };
  
  /*
  skillet.fry = function() {
      var oliveOil;
       
      addItem( "\t\n Butter \n\t" );
      addItem( oliveOil );
      console.log( "Frying " + skillet.ingredient );
  };
  */
}( window.WNCO = window.WNCO || {}, $ ) );

