application.core.extend({
  public: {  
    Website: function(config) {
	  this.storeConfig(config);		
		
	  return this.init();
    }
  }
});

application.core.extend(
  application.public.Website.prototype, 
  application.base.Base.prototype, 
  {  
  	init: function() {
	  this.ready(function() {
		this.execUtils();
		this.menu();
	  });

	  return this;	
	},

	execUtils: function() {
	  application.ui.util.hide('.hide');
	  application.ui.util.toggle('.toggle');
      application.ui.clearText('input.cleartext, textarea.cleartext');			
	  application.ui.tooltip.associate('.tooltip', { extraClass: 'mini' });			
	},
	
	escapeSelector: function(s) {
	  return s.replace(/(#|;|&|,|\.|\+|\*|~|'|:|"|\!|\^|\$|\[|\]|\(|\)|=|>|\||\/)/g, '\\\\$1');
	},
	
	menu: function() {
	  var root = application.core.getGlobal('root').replace(/^\/|\/$/g, '').split('/');
	  var pos = !root[0].length ? 0 : root.length;
	  var path = window.location.pathname.substring(1).split('/').slice(pos);
	  var s = '', e = '';

	  if (!path[path.length - 1].length) {
		e = path[path.length - 2] == undefined ? 'index.htm' : path[path.length - 2] + '/';
	  } else {
		s = path[path.length - 1];
		e = s;
	  }
	 
	  if (path.length > 1) {
		s = path[0] + '/';
	  } else {
		s = e;  
	  }

	  if (s.length && e.length) {
		$('#nav a[href$="' + s + '"], div.side-menu a[href$="' + e + '"]').addClass('current');
	  }
	}
  }  
);   
