function testimonials (ident, array, mode){
    
    this.ident = ident;
    this.testimonials = array;
    this.mode = mode;
    
    this.target = document.getElementById(this.ident + "content");
    
    this.currentArray;
    this.displayed;
    
    this.init = function () {
        
        this.currentArray = this.testimonials;
        
        this.displayNew();
        
        var a = document.getElementById(this.ident).getElementsByTagName("a")[0];
        
        a.jObject = this;
        
		a.onclick = function () { this.jObject.displayNew(); return false; }
        
    }
    
    
    this.displayNew = function () {
        
        this.clearElement(this.ident+"content");
        
        var display = this.twoRandomSamples(this.currentArray);
        
        for (var x = 0; x < display.length; x++) {
            
            h1 = document.createElement('h1');
            h2 = document.createElement('h2');
            
            h1.innerHTML = '"' + display[x].quote + '"';
            h2.innerHTML = '- ' + display[x].author;
            
            this.target.appendChild(h1);
            this.target.appendChild(h2);
            
        }
        
    }
    
    this.clearElement = function (element) {
	content = document.getElementById(element);

        if ( content.hasChildNodes() )
        {
  	    while ( content.childNodes.length >= 1 )
            {
    			content.removeChild( content.firstChild );       
    	    } 
		}
	
        
    }
    this.chooseFromArray = function (array) {
       
        return Math.floor(Math.random() * array.length);
        
    }
    
    this.removeIdFromArray = function(id, array) {

        
        var result = Array();
        
        for (var x = 0; x < array.length; x++) {

            if (x != id) result[result.length] = array[x];
           
            
        }
        return result;
    }
    
    this.twoRandomSamples = function (array) {
        
        var result = Array();
        
        var random1 = this.chooseFromArray(array);
        var smallerArray = this.removeIdFromArray(random1, array);
        var random2 = this.chooseFromArray(smallerArray);
        
        result[0] = array[random1];
        result[1] = smallerArray[random2];
        if (this.displayed) {
            
            this.currentArray = this.removeIdFromArray(random2, smallerArray);
            this.currentArray[this.currentArray.length] = this.displayed[0];
            this.currentArray[this.currentArray.length] = this.displayed[1];
            
        }
        else this.currentArray = this.removeIdFromArray(random2, smallerArray);
        
        this.displayed = result;
        
        return result;
    }
}