var VoyeurViewManager = {
	viewedObjects : [],
	currentTimeout : null,
	maxAutoStarts : 5,
	autoStartIndex: 1,
	createObject : function(cFormat , cSource, cCounter , cURL){
		document.getElementById('trProfileImage_'  + cSource + "_" + cCounter).style.display = 'none';
		document.getElementById('videoPlaceHolderParent_'+ cSource + "_" + cCounter).style.display = '';
		if(this.viewedObjects.length > 0){
			this.stopVideo();
		}
		if(cFormat.match(/easycam/gi)){
			var so = new SWFObject(cURL, "player_" + cSource + "_" + cCounter, "40", "30", "8", "#FFFFFF");
			so.width = 40;
			so.height = 30;
			so.addParam("wmode", "transparent");
			so.addParam("allowScriptAccess", "always");
			so.write("videoPlaceHolder_"  + cSource + "_" + cCounter);
		}else{
			document.getElementById('videoPlaceHolder_'+ cSource + "_" + cCounter).innerHTML = document.getElementById('textareaIFCam_' + cSource + "_" + cCounter).value;
		}
		clearTimeout(this.currentTimeout);
		this.viewedObjects.push(cSource + "_" + cCounter);
		var obj = this;
		this.currentTimeout = setTimeout(function(){obj.stopVideo(true);},"20000")
	},
	stopVideo : function(bIsAutoStop){
		this.showProfileImage();
		this.disposeObject();
		this.viewedObjects=[];
		if(bIsAutoStop){
			if(this.autoStartIndex < this.maxAutoStarts){
				this.autoStartIndex++;
				if(document.getElementById('anchor_ModuleLeftRail_'+this.autoStartIndex)){
					var oAnchor = document.getElementById('anchor_ModuleLeftRail_'+this.autoStartIndex);
					setTimeout(function(){oAnchor.onclick();},'500');
				}
			}
		 }else{
			this.maxAutoStarts = 0;
		 }
	},
	showProfileImage : function(){
		document.getElementById('trProfileImage_'  + this.viewedObjects[this.viewedObjects.length-1]).style.display = '';
		document.getElementById('anchor_'  + this.viewedObjects[this.viewedObjects.length-1]).style.display = 'none';
	},
	disposeObject : function(){
		var oElement = document.getElementById('videoPlaceHolderParent_' + this.viewedObjects[this.viewedObjects.length-1]);
		if(oElement != null){
			var oParent = oElement.parentNode;
			oParent.removeChild(oElement);
		}
		clearTimeout(this.currentTimeout);
	}
}