Method 1: JSON-style

The Code:

var object1 = {
	_target : null,
	init : function(id){
		this._target = document.getElementById(id);
	},

	update : function(){
		// An integer between 0 and the length of quotes - 1
		index = Math.floor(Math.random()*quotes.length); 
		this._target.innerHTML = quotes[index];
	},

	showAll : function(){
		quotestr = "";
		for(i=0; i < quotes.length; i++){
			quotestr += "<p>"+quotes[i]+"</p>";
		}
		this._target.innerHTML = quotestr; 
	}
}
		

The Div:

Update | Show All

Method 2: Anonymous Functions

var object2def = function(){
	 this._target = null;
	 this.init = function(id){
		 this._target = document.getElementById(id);
	}

	 this.update = function(){
		index = Math.floor(Math.random()*quotes.length); 
		 this._target.innerHTML = quotes[index]; 
	}

	 this.showAll = function(){
		quotestr = "";
		for(i=0;i<quotes.length;i++){
			quotestr += "<p>"+quotes[i]+"</p>";
		}
		 this._target.innerHTML = quotestr; 
	}
}


var object2 = new object2def;
		

The Div:

Update | Show All