if(typeof console == "undefined")
{
	console = {
		log:function(){}
	};
}

Cheddr = new function() {
  this.globals = {
    mode: 'development',
    page_data: {participant: null},
    getUpdates: function(){CheddrUtil.getUpdates()}
  };
  this.is_admin_user = function() {
    return false;
  }
  this.is_logged_in = function() {
    //console.log('called is_logged_in');
    //console.log('participant:');
    //console.dir($cheddr['page_data']['participant']);
    if ( ($cheddr) && ($cheddr['page_data']) && ($cheddr['page_data']['participant']) && ($cheddr['page_data']['participant']['id']) ) {
      //console.log('user is logged in!');
      return true;
    }
    else
      return false;
  }
  this.init = function() {
    // Define an object in the global scope (i.e. the window object)
    window.$cheddr = {
      // Initialize all the queries you want to use more than once
      head       : $('head'),
      globals : Cheddr.globals,
      is_production : (Cheddr.globals['mode'] == 'production'),
      is_logged_in  : this.is_logged_in
    };

    window.$cheddr = $.extend(Cheddr.globals, window.$cheddr);
    // Merb environment
    $cheddr['mode'] = 'production';

    // Overall parsing mode for application.
    $cheddr['server_side_parsing'] = false;

    // jQueries for re-use app-wide
    $cheddr['logoutLink'] = $(".logged-in a.logout");
    $cheddr['loginLink']  = $(".login-required a");
    $cheddr['entryForm']  = $("form#entry-form");

    // Create a namespace for our templates
    $cheddr['templates'] = $cheddr['templates'] || {};

    // Create a namespace for our misc data, that will be bound to the templates
    $cheddr['page_data'] = $cheddr['page_data'] || {};

    // Set up participant info, if available
    $cheddr['page_data']['module']                          = $cheddr['page_data']['module'] || {};
    $cheddr['page_data']['module']['id']                    = 481;
    $cheddr['page_data']['module']['label']                 = 'People';
    $cheddr['page_data']['module']['default_filter_id']     = 1310;
    $cheddr['page_data']['filter']                          = $cheddr['page_data']['filter'] || {};
    $cheddr['page_data']['filter']['id']                    = 1310;
    $cheddr['page_data']['filter']['label']                 = 'All';
    $cheddr['page_data']['filter']['slug']                  = 'all';
    $cheddr['page_data']['filter']['is_parent']             = true;
    $cheddr['page_data']['filter']['query']                 = '';
    $cheddr['page_data']['filter']['tweet_box_text']        = '';
    $cheddr['page_data']['filter']['children']              = ['social-media','entrepreneurs','celebrities','musicians','fashionistas','general','geeks'];
    $cheddr['page_data']['entries']                          = $cheddr['page_data']['entries'] || {};
    $cheddr['page_data']['entries']['page']                  = 1;

  };
}

function replaceEndPath(path, newpath)
{
  return (path == '/') ? path + newpath : location.pathname.replace(/\.html/i,'/' + newpath)
}

Cheddr.init();


