/* actually generates my Ads / called by flipBoxes */
function generatedAds(thingArray, numOfBoxes, whatItIs){
  this.thingArray=thingArray;
	this.numOfBoxes=numOfBoxes;
	this.whatItIs=whatItIs;
  var container = new Array();
	for (var i=0; i<numOfBoxes; i++){
		container[i]=document.getElementById("box" + i);
		//alert("container["+i+"]:"+container[i]);
		this.body=document.createElement("div");
		container[i].appendChild(this.body);
		this.updateUI(i);
	}
}

generatedAds.prototype={			//how does this prototype work in this context
  updateUI:function(iteration){
    var loader=this;
    new net.ContentLoader(
      this.numOfBoxes,	//doesn't do anything
      "../"+this.thingArray[iteration],
      function(response){		//still don't understand where response is coming from
        loader.ajaxResponse(response, iteration);	//explain this closure to me again
      }
    );  
  },
  ajaxResponse:function(xhr, iteration){		
		if (this.whatItIs=="ad"){																			
			document.getElementById("box"+iteration).innerHTML=xhr.responseText;																		
		}else if((this.whatItIs=="testimony")&&iteration==0){
			document.getElementById("div"+iteration).innerHTML="<p><span class='diadtitle'>Student Testimony</span><br />"+xhr.responseText+"</p>";																				
		}else {
			document.getElementById("div"+iteration).innerHTML="<p><span class='diadtitle'>Another Testimony</span><br />"+xhr.responseText+"</p>";													
		}
  }
};

