var Menu = Class.create({
  initialize: function() {
	this.controlId = 'projectItem';
	this.menuId = 'projectNav';
	this.duration = 0.5;
    this.isShowing = false;
	this.isProjects = this._checkPath();
	if(this.isProjects) {
		this.makeActive(this.controlId);
		$(this.menuId).style.left = '0px';
	}
  },
  makeActive: function(id) {
	  $(id).className = 'active';
  },
  makeInactive: function(id) {
	   $(id).className = '';
  },
  showMenu: function(id) {
	this.makeActive(this.controlId);
	new Effect.Morph(id, 
		{
  			style: 'left:0px', 
			duration: this.duration
		}
	);
  },
  hideMenu: function(id) {
	 this.makeInactive(this.controlId);
	  new Effect.Morph(id, 
		{
  			style: 'left:-151px', 
			duration: this.duration
		}
	);
  },
  isShowing: function() {
	  return this.isShowing;
  },
  toggleMenu: function() {
	if( ! this.isProjects ) {
		if( this.isShowing ) {
			this.hideMenu(this.menuId);
			this.isShowing = false;
		} else {
			this.showMenu(this.menuId);
			this.isShowing = true;
		}
	}
  },
  _checkPath: function() {
	  if( document && document.location ) {
		  if( document.location.toString().indexOf('/projects') > -1 ) {
			return true;  
		  }
		  return false;
	  }
	  return false;
  }
});
var Project = Class.create({
	initialize: function()
	{
		this.photos = $("projectPhotos");
		this.buttons = $("projectItems");
		this.current = 0;
		
		for(var i = 0; i < this.photos.childElements().length; i++)
		{
			if(i > 0)
			{
				this.photos.childElements()[i].hide();	
			}
			var a = new Element('a', { 'class': 'projectNavItem floatLeft', href: 'Javascript:project.change('+i+');' }).update('');
			this.buttons.insert(a);
		}
	},
	change: function(i)
	{
		this.photos.childElements()[this.current].hide();
		this.photos.childElements()[i].show();
		this.current = i;
	}
});
var menu = new Menu();