function CM_WEBCOMPONENT_MODELCONTENTLIST(strName) {
	this.strName = strName;
	this.objVideoPosition = null;
	this.objModelVideo = null;
	this.objModelVideoImage = null;
	this.objModelVideoRatingResult = null;
	this.objModelVideoRatingEntry =  null;
	this.objModelVideoSet = null;

	this.objRsSnapshot = null;
	this.objRsBio = null;
	this.arrImagePosition = null;
	this.blnAll = false;
	this.blnSmall = true;
	this.arrCurrentContent = new Array();
	this.arrOnContent = new Array();
	this.arrOnNewContent = new Array();
	this.arrSmallImage = new Array(); //Array used to store the random small display image
	this.intNbContentCount = 20;
	this.blnMore = false;
	this.blnShowHtml = false;
	this.intMaxImg = 5;
	this.intCnt = 0;
	var me = this;

	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.setVideoPosition = function setVideoPosition(objVideoPosition) {
		this.objVideoPosition = objVideoPosition;
	}

	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.setModelVideo = function setModeVideo(objModelVideo) {
		this.objModelVideo = objModelVideo;
	}

	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.setModelVideoImage = function setModelVideoImage(objModelImage) {
		this.objModelVideoImage = objModelImage;
	}

	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.setModelVideoRatingResult = function setModelVideoRatingResult(objRating) {
		this.objModelVideoRatingResult = objRating;
	}

	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.setModelVideoRatingEntry = function setModelVideoRatingEntry(objEntry) {
		this.objModelVideoRatingEntry = objEntry;
	}

	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.setModelVideoSet = function setModelVideoSet(objVideoSet) {
		this.objModelVideoSet = objVideoSet;
	}

	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.setSnapshotRs = function setSnapshotRs(objRs) {
		this.objRsSnapshot = objRs;
	}

	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.setBioRs = function setBioRs(objRs) {
		this.objRsBio = objRs;
	}

	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.setBioRs = function setBioRs(objRs) {
		this.objRsBio = objRs;
	}

	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.setArrImagePosition = function setArrImagePosition(arrImagePosition) {
		this.arrImagePosition = arrImagePosition;
	}

	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.addOnContentEvent = function addOnContentEvent(ptFunction) {
		this.arrOnContent.push(ptFunction);
	}
	
	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.addOnNewContentEvent = function addOnNewContentEvent(ptFunction) {
		this.arrOnNewContent.push(ptFunction);
	}
	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.setNbContentCount = function setNbContentCount(intNbContentCount) {
		this.intNbContentCount = intNbContentCount;
	}

	/**
	 * This method will callback every listener on the selectcontent event
	 *
	 * @param (DHL.CONTENT.JSMODELIMAGE OR DHL.CONTENT.JSMODELVIDEO) $objContent 
	 * @param DHL.CONTENT.RATING_RESULT $objRatingResult 
	 * @param DHL.CONTENT.RATING_ENTRY $objRatingEntry
	 * @param (DHL.CONTENT.MODELIMAGE_SET OR DHL.CONTENT.MODELVIDEO_SET) $objSet
	 *
	 */
	CM_WEBCOMPONENT_MODELCONTENTLIST.onContentClick = function onContentClick(
		objContent, objRatingResult, objRatingEntry, objSet, objFavorite
	) {
		
		for(var intI =0; intI < me.arrOnContent.length; intI++) {
			me.arrOnContent[intI](
				objContent, 
				objRatingResult,
				objRatingEntry,
				objSet,
				objFavorite
			);
		}
	}
	
	

	/**
		Public
	**/
	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.isSmall = function isSmall(blnSmall) {
		this.blnSmall = blnSmall;
	}

	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.onNewContent = function onNewContent() {
		//notify every content display container
		for(var intI=0; intI < this.arrOnNewContent.length; intI++) {
			this.arrOnNewContent[intI](this.arrCurrentContent);
		}
	}

	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.onMoreContent = function onMoreContent() {
		if(!me.blnMoreContentDisplayed) {
			me.render(me.intNbContentCount);
			me.blnMoreContentDisplayed = true;
			me.blnMore = true;
		}
	}
	
	/**
	 * made this method to counter the javascript variable scope
	 * so the objModeImage won't be the last one in the for loop
	 *  
	 */
	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype._associateOnClick = function _associateOnClick(
		objHTMLImage, objContent, objRatingResult, objRatingEntry, objSet, objFavorite
	) {
		objHTMLImage.onclick = function() {
			CM_WEBCOMPONENT_MODELCONTENTLIST.onContentClick(objContent, objRatingResult, objRatingEntry, objSet, objFavorite);
		}
	} 

	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype._displayImage = function _displayImage(objContainer, arrData) {

		blnReturn = false;
		if(arrData) {
			objModelImage = DHL.CONTENT.JSMODELIMAGE.unmap('mi', arrData);
			objModelImageParent = DHL.CONTENT.JSMODELIMAGE.unmap('mip', arrData);
			objRatingEntry = DHL.CONTENT.RATING_ENTRY.unmap('re', arrData);
			objRatingResult = DHL.CONTENT.RATING_RESULT.unmap('rr', arrData);
			objModelImageSet = DHL.CONTENT.MODELIMAGE_SET.unmap('mis', arrData);
			objFavorite = DHL.CONTENT.FAVORITE_ENTRY.unmap('fe', arrData);
			objModel = DHL.SITE.MODEL.unmap('m', arrData);

			objToDisplaModelImage = objModelImage;
			
			if(objModelImageParent.getId()) {
				objToDisplaModelImage = objModelImageParent;
			}
			if ( (this.intCnt < this.intMaxImg) || this.blnShowHtml ) {
				objImageTemplate = document.getElementById(this.strName + "ImageTemplate");
				objImageDiv = objImageTemplate.cloneNode(true);
				
				objContainer.appendChild(objImageDiv);
	
				objImageDiv.className = this.strName + "floatLeft";
	
				arrImage = objImageDiv.getElementsByTagName('*');
				
				arrImage['pics'].src = objModelImage.getRelativePath();
				arrImage['pics'].className = "camsters_picStroke";//this.strName + "Image";
				
				objImageDiv.style.display = "block";
				
				this._associateOnClick(arrImage['pics'], objToDisplaModelImage, objRatingResult, objRatingEntry, objModelImageSet, objFavorite);
			}
			blnReturn = true;

			var arrContent = new Object();
			arrContent["content"] = objToDisplaModelImage;
			arrContent["result"] = objRatingResult;
			arrContent["entry"] = objRatingEntry;
			arrContent["set"] = objModelImageSet;
			arrContent["favorite"] = objFavorite;
			arrContent["child"] = objModelImage;
			arrContent["model"] = objModel;
			this.arrCurrentContent.push(arrContent);
			this.intCnt += 1;
		}
		return blnReturn;
	}
	
	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype._rand = function _rand( min, max ) {
	    // http://kevin.vanzonneveld.net
	    // +   original by: Leslie Hoare
	    // *     example 1: rand(1, 1);
	    // *     returns 1: 1
 
	    if( max ) {
	        return Math.floor(Math.random() * (max - min + 1)) + min;
	    } else {
	        return Math.floor(Math.random() * (min + 1));
	    }
	}
	
	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.render = function render(intMax) {
		
		this.intCnt = 0;
		this.arrCurrentContent.length = 0;
		this.blnMoreContentDisplayed = true;
		if(this.blnSmall) {
			this.renderSmall(intMax);
		}
		else {
			this.renderLarge(intMax);
		}
		this.onNewContent();
	}
	
	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.generateSmallContent = function generateSmallContent() {
		this.objRsSnapshot.seek(0);
		this.objRsBio.seek(0);
		this.arrSmallImage = new Array();

		var blnEnd = false;

		//Display Random between Bio and Snapshot, if one is empty then display only from the other

		var intIndex = 0;
		var intFailed = 0;
		var blnFreezeIndex = false;

		while(!blnEnd) {
			if(intIndex == 0) {
				var objRs = this.objRsSnapshot;
				if(!blnFreezeIndex) {
					intIndex = 1;
				}
			}
			else {
				var objRs = this.objRsBio;
				if(!blnFreezeIndex) {
					intIndex = 0;
				}
			}

			if(arrRow = objRs.fetch()) {
				this.arrSmallImage.push(arrRow);
				if(intFailed > 0) {
					intFailed--;
				}
			}
			else {
				intFailed++;
				blnFreezeIndex = true;
			}

			if(intFailed >= 2) {
				blnEnd = true;
			}
		}
	}
	
	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.renderSmall = function renderSmall(intMax) {
		if(intMax <= 0) {
			intMax = 5;
			if (!this.blnShowHtml) {
				intMax = 50;
			}
			this.blnMoreContentDisplayed = false;
		} else if (intMax == 6) {
			this.intMaxImg = 6;
			if (!this.blnShowHtml) {
				intMax = 50;
			}
		}

		intI = 1;
		objImageTemplate = document.getElementById(this.strName + "ImageTemplate");
		objVideoTemplate = document.getElementById(this.strName + "VideoTemplate");
		objImageContainer = document.getElementById(this.strName + "Container");
		if(objImageContainer) {
			objImageContainer.style.display = "block";
	
			while(objImageContainer.firstChild) {
				objImageContainer.removeChild(objImageContainer.firstChild);
			}
	
			//If there's a video add it, if not, display one more image
			if(this.objModelVideo) {
				objVideoDiv = objVideoTemplate.cloneNode(true);
				objImageContainer.appendChild(objVideoDiv);
				objVideoDiv.style.display = "block";
				
				var strImagePath = "/images/cs_74x99_default.gif";
				if(this.objModelVideoImage) {
					strImagePath = this.objModelVideoImage.getRelativePath();
				}
				
				objVideoDiv.style.background = "url(" + strImagePath + ")";
				objVideoDiv.style.cursor = "pointer";
				
				this._associateOnClick(
					objVideoDiv, this.objModelVideo, this.objModelVideoRatingResult, this.objModelVideoRatingEntry, this.objModelVideoSet
				);
				var arrContent = new Object();
				arrContent["content"] = this.objModelVideo;
				arrContent["result"] = this.objModelVideoRatingResult;
				arrContent["entry"] = this.objModelVideoRatingEntry;
				arrContent["set"] = this.objModelVideoSet;
				
				this.arrCurrentContent.push(arrContent);
				intMax--;
				this.intCnt++;
			}
	
			//////////////////////////////////
			if(this.arrSmallImage.length <= 0) {
				this.generateSmallContent(intMax);
			}
			for(intI = 0; intI <= this.arrSmallImage.length && intI < intMax; intI++) {
				this._displayImage(objImageContainer, this.arrSmallImage[intI]);
			}
	
			intTotal = this.arrSmallImage.length;
	
			var objDisplay = null;
			var totalItmCnt = this.objRsSnapshot.getRecordCount() + this.objRsBio.getRecordCount();
			if(
				(totalItmCnt >= this.intMaxImg && !this.blnShowHtml) || totalItmCnt > intMax 
			) {
				objDisplay = document.getElementById(this.strName + "more").cloneNode(true);
			}
			else if(this.objRsSnapshot.getRecordCount() > 5) {
				objDisplay = document.getElementById(this.strName + "all").cloneNode(true);
			}
	
			objMoreContainer = document.getElementById(this.strName + "MoreContainer");
			while(objMoreContainer.firstChild) {
				objMoreContainer.removeChild(objMoreContainer.firstChild);
			}
			if(objDisplay) {
				objMoreContainer.appendChild(objDisplay);
				objDisplay.style.display = "block";
			}
			if (!this.blnShowHtml) {
				this.blnShowHtml = true;
				this.blnMoreContentDisplayed = false;
			}
		}
	}

	CM_WEBCOMPONENT_MODELCONTENTLIST.prototype.renderLarge = function renderLarge(intMax) {
		this.blnShowHtml = true;
		intI = 1;
		objVideoBlock = document.getElementById(this.strName + "videoBlock");
		objPhotoAlbumBlock = document.getElementById(this.strName + "PhotoAlbumBlock");
		objLiveScreencapBlock = document.getElementById(this.strName + "LiveScreenCapsBlock");
		
		objImageTemplate = document.getElementById(this.strName + "ImageTemplate");
		objVideoTemplate = document.getElementById(this.strName + "VideoTemplate");
		objVideoImage = document.getElementById(this.strName + "modelImage");
		
		objVideoContainer = document.getElementById(this.strName + "VideoContainer");
		objBioContainer = document.getElementById(this.strName + "BioContainer");
		objSnapshotContainer = document.getElementById(this.strName + "SnapshotContainer");

		while(objVideoContainer.firstChild) {
			objVideoContainer.removeChild(objVideoContainer.firstChild);
		}
		while(objBioContainer.firstChild) {
			objBioContainer.removeChild(objBioContainer.firstChild);
		}
		while(objSnapshotContainer.firstChild) {
			objSnapshotContainer.removeChild(objSnapshotContainer.firstChild);
		}

		if(this.objModelVideo) {
			objVideoDiv = objVideoTemplate.cloneNode(true);
			objVideoContainer.appendChild(objVideoDiv);
			objVideoDiv.style.display = "block";
			objVideoDiv.style.cursor = "pointer";
			
			var strImagePath = "/images/cs_74x99_default.gif";
			if(this.objModelVideoImage) {
				strImagePath = this.objModelVideoImage.getRelativePath();
			}
			arrVideo = objVideoDiv.getElementsByTagName('*');
			arrVideo["modelImage"].src = strImagePath;
			me = this;
			this._associateOnClick(
				objVideoDiv, this.objModelVideo, this.objModelVideoRatingResult, this.objModelVideoRatingEntry, this.objModelVideoSet
			);
			intMax--;
			
			var arrContent = new Object();
			arrContent["content"] = this.objModelVideo;
			arrContent["result"] = this.objModelVideoRatingResult;
			arrContent["entry"] = this.objModelVideoRatingEntry;
			arrContent["set"] = this.objModelVideoSet;
			
			this.arrCurrentContent.push(arrContent);
		}
		else {
			objVideoBlock.style.display = "none";
		}

		this.objRsSnapshot.seek(0);
		this.objRsBio.seek(0);

		//Display Random between Bio and Snapshot, if one is empty then display only from the other
		if(this.objRsBio.getRecordCount()) {
			while(arrRow = this.objRsBio.fetch()) {
				this._displayImage(objBioContainer, arrRow);
			}
		}
		else {
			objPhotoAlbumBlock.style.display = "none";
		}

		if(this.objRsSnapshot.getRecordCount()) {
			while(arrRow = this.objRsSnapshot.fetch()) {
				this._displayImage(objSnapshotContainer, arrRow);
			}
		}
		else {
			objLiveScreencapBlock.style.display = "none";
		}
	}
}