function CM_WEBCOMPONENT_VIDEOINTERFACE(strName) {
	this.strName = strName;
	this.arrOnRegisterEvent = new Array();
	this.arrOnSwitchSpeedEvent = new Array();
	this.arrOnConfirmRegistrationEvent = new Array();
	
	
	this.intUserId = null;
	this.objFavoriteHttpRequest = new DHL.NET.HTTPREQUEST();
	this.blnChanging = false;
	this.blnIsFavorite = false;
	this.blnDeleteFavorite = false;
	this.objCurrentObject = null;
	this.objShare = null;
	this.objModelVideoSet = null;
	this.isConfirmed = false;
	this.strHidden = '';
	this.objVideo = null;
	this.objShowRegister = null;
	var me = this;

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.setShareObj = function setShareObj(objShare) {
		this.objShare = objShare;
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.setObjVideo = function setObjVideo(objVideo) {
		this.objVideo = objVideo;
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.setShowRegister = function(objShowRegister) {
		this.objShowRegister = objShowRegister;
		var me = this;
		this.objShowRegister.addShowListener(function() {
			me.onHideVideo();
		});
		this.objShowRegister.addHideListener(function() {
			me.onShowVideo();
		});
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.setContent = function setContent(objContent) {
		this.objCurrentObject = objContent;
	}
	
	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.setIsConfirmed = function setIsConfirmed(blnIsConfirmed) {
		this.isConfirmed = blnIsConfirmed;
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.setIsFavorite = function setIsFavorite(blnFavorite) {
		this.blnIsFavorite = blnFavorite;
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.setFavoriteUrl = function setFavoriteUrl(objUrl) {
		this.objFavoriteUrl = objUrl;
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.onAddRegisterEvent = function onAddRegisterEvent(ptFunction) {
		this.arrOnRegisterEvent.push(ptFunction);
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.onAddSwitchSpeedEvent = function onAddSwitchSpeedEvent(ptFunction) {
		this.arrOnSwitchSpeedEvent.push(ptFunction);
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.onAddConfirmRegistrationEvent = function onAddConfirmRegistrationEvent(ptFunction) {
		this.arrOnConfirmRegistrationEvent.push(ptFunction);
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.onRegisterEvent = function onRegisterEvent(strUrl, strAccess, strFormName) {
		if(!strFormName) {
			strFormName = CM_WEBCOMPONENT_REGISTER.FORM_LOGIN;
		}
		for(var intI = 0; intI < this.arrOnRegisterEvent.length; intI++) {
			this.arrOnRegisterEvent[intI](strFormName, strUrl, strAccess);
		}
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.onSwitchSpeedEvent = function onSwitchSpeedEvent() {
		for(var intI = 0; intI < this.arrOnSwitchSpeedEvent.length; intI++) {
			this.arrOnSwitchSpeedEvent[intI]();
		}
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.onConfirmRegistrationEvent = function onConfirmRegistrationEvent(strUrl) {
		for(var intI = 0; intI < this.arrOnConfirmRegistrationEvent.length; intI++) {
			this.arrOnConfirmRegistrationEvent[intI](CM_WEBCOMPONENT_REGISTER.FORM_CONFIRM, strUrl);
		}
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.requestPrivateShow = function(intModelId, strShowType) {
		if(this.objShowRegister != null) {
			this.objShowRegister.goPrivate(intModelId, strShowType);
		}
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.changeSpeedText = function changeSpeedText(obj) {
		if(obj.innerHTML == "Click here to switch to broadband video") {
			obj.innerHTML = "Click here to switch to lowband video";
		} else {
			obj.innerHTML = "Click here to switch to broadband video";
		}
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.setUserId = function setUserId(intUserId) {
		this.intUserId = intUserId;
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype._hideOrDisplay = function _hideOrDisplay(objElement, blnForce) {
		if(objElement.style.display == 'block' && !blnForce) {
			objElement.style.display='none';
		} else {
			objElement.style.display = 'block';
		}
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype._hideOther = function _hideOther(strExtra) {
		if(strExtra != "vote") {
			document.getElementById(this.strName + "modelVote").style.display='none';
		}
		if(strExtra != "award") {
			document.getElementById(this.strName + "modelAward").style.display='none';
		}
		if(strExtra != "share") {
			document.getElementById(this.strName + "share").style.display='none';
		}
		if(strExtra != "report") {
			document.getElementById(this.strName + "report").style.display='none';
		}
		if(strExtra != "emailModel") {
			document.getElementById(this.strName + "emailModel").style.display='none';
		}
		if(strExtra != "schedule") {
			document.getElementById(this.strName + "modelSchedule").style.display='none';
		}
		if(strExtra != "favorite") {
			document.getElementById(this.strName + "favorite").style.display='none';
		}
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.displayExtra = function displayExtra(strExtra, blnForce) {
		switch(strExtra) {
			case 'vote' :
				if(this.intUserId && this.isConfirmed) {
					this._hideOrDisplay(document.getElementById(this.strName + "modelVote"), blnForce);
					this._hideOther(strExtra);
				} else if (this.intUserId) {
					this.onConfirmRegistrationEvent();
				} else {
					this.onRegisterEvent(null, 'vote');
				}
			break;
			case 'award' :
				this._hideOrDisplay(document.getElementById(this.strName + "modelAward"), blnForce);
				this._hideOther(strExtra);
			break;
			case 'share':	
				/////////////
				// Share link
				if(this.objShare) {
					//http://www.camsters.com/Cindy/profile/modelVideoId-12345/modelVideoPositionId-123456/shareId-123
					objUrl = new CM_URL.getCurrent();
					if(this.objCurrentObject.className == "DHL.SITE.MODEL") {
						objUrl.clearSpecialAttribute();
						objUrl.setNickname(this.objCurrentObject.getVariable('nickName'));
					}
					else {
						objVideoPosition = this.objCurrentObject.getVideoPosition();
						objUrl.setSpecialAttribute('modelVideoId', this.objCurrentObject.getId());
						objUrl.setSpecialAttribute('modelVideoPositionId', objVideoPosition.getId());
						if(
							this.objModelVideoSet &&
							this.objModelVideoSet.getTitle()
						) {
							objUrl.setSpecialAttribute('title', this.objModelVideoSet.getTitle());
						}
						if(!objUrl.getPath()) {
							objUrl.setPath('profile.htm');
						}
					}
					objUrl.removeAttribute('shareId');
					if(this.objShare.getRewardAccountId()) {
						objUrl.setAttribute('shareId', this.objShare.getRewardAccountId());
					}
					this.objShare.setLink(objUrl);
					this.objShare.render();
				}	
				this._hideOrDisplay(document.getElementById(this.strName + "share"), blnForce);
				this._hideOther(strExtra);
			break;
			case 'schedule':
				this._hideOrDisplay(document.getElementById(this.strName + "modelSchedule"), blnForce);
				this._hideOther(strExtra);
			break;
			case 'report':
				this._hideOrDisplay(document.getElementById(this.strName + "report"), blnForce);
				this._hideOther(strExtra);
			break;
			case 'emailModel':
				this._hideOrDisplay(document.getElementById(this.strName + "emailModel"), blnForce);
				this._hideOther(strExtra);
			break;
			case 'favorite':
				this._hideOrDisplay(document.getElementById(this.strName + "favorite"), blnForce);
				this._hideOther(strExtra);
			break;
		}
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.onHideVideo = function onHideVideo() {
		this.onHideRecordedVideo(false);
		
		if(document.getElementById("video" + this.strName)) {
			if (!this.oldVideoWidth && !this.oldVideoHeight) {
				this.oldVideoWidth = document.getElementById("video" + this.strName).style.width;
				this.oldVideoHeight = document.getElementById("video" + this.strName).style.height;
			}
			document.getElementById("video" + this.strName).style.width = "1px";
			document.getElementById("video" + this.strName).style.height = "1px";
		}
		
		if(this.objVideo) {
			this.objVideo.hideVideo();
		}
		
		if(document.getElementById("videoPlaceHolder" + this.strName)) {
			document.getElementById("videoPlaceHolder" + this.strName).style.display = "block";
		}
		
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.onShowVideo = function onShowVideo() {
		if(document.getElementById("video" + this.strName)) {
			document.getElementById("video" + this.strName).style.width = this.oldVideoWidth + (this.oldVideoWidth.indexOf('%')? '': "px");
			document.getElementById("video" + this.strName).style.height = this.oldVideoHeight + (this.oldVideoHeight.indexOf('%')? '': "px");
			this.oldVideoWidth = null;
			this.oldVideoHeight = null;
		}
		
		if(this.objVideo) {
			this.objVideo.showVideo();
		}
		
		if(document.getElementById("videoPlaceHolder" + this.strName)) {
			document.getElementById("videoPlaceHolder" + this.strName).style.display = "none";
		}
	}
	
	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.onDisplayVideo = function onDisplayVideo(
		objContent, objRatingResult, objRatingEntry, objSet, objFavoriteobjContent
	) {
		if(this.intUserId && this.isConfirmed) {
			switch(objContent.className) {
				case 'DHL.CONTENT.JSMODELVIDEO':
					var objUrl = DHL.NET.URL.getCurrent();
					objUrl.setPath(objContent.getRelativePath());
					
					var blnFlv = false;
					if(objContent.getFileName().indexOf(".flv") > 0) {
						strOutput = "<div id=\"flvPlayer\" style=\"margin-top:75px;margin-left:75px;\" >" +
							"<a " +
								 "href=\"" + objUrl.toString() + "\" " +
								 "style=\"display:block;width:320px;height:240px\" " +
								 "id=\"pl\" > " +
							"</a>" +
							"</div>";
						blnFlv = true;
					}
					else {
						switch(BrowserDetect.browser) {
							case 'Explorer':
								strOutput = '<object id="player_' + this.strName + '" type="application/x-oleobject" ' +
									'classid="clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95" width="320" height="287">' +
									'<param name="autostart" value="true"/>' +
									'<param name="TransparentAtStart" value="0"/>' +
									'<param name="AnimationAtStart" value="true"/>' +
									'<param name="ShowStatusBar" value="true"/>' +
									'<param name="filename" value="' + objUrl.toString() + '">' +
									'<param name="stretchToFit" value="true">' +
									'</object>';
							break;
							case 'Firefox':
								strOutput = '<embed	type="application/x-mplayer2"' +
									' name="player_' + this.strName + '" ' + 
									 ' id="player_' + this.strName + '" ' +
									 ' pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" '+
									 ' src="' + objUrl.toString() + '" ' +
									 ' align="middle" ' +
									 ' width="320" ' +
									 ' height="240"' +
									 ' defaultframe="rightFrame" ' +
									 ' showstatusbar="1"' +
									 ' showcontrols="0"' +
									 ' autostart="1"' +
									 ' PlayCount="1"' +
									 ' transparentAtStart="0"' +
									 ' strechtofit="1" ' +
									 '>'
							break;
						}
					}
					
					this.onHideVideo();
					if(document.getElementById("videoPlaceHolder" + this.strName)) {
						document.getElementById("videoPlaceHolder" + this.strName).style.display = "none";
					}
					if(document.getElementById("videoControl" + this.strName)) {
						document.getElementById("videoControl" + this.strName).style.display = "none";
					}
	
					if(document.getElementById("modelImagePlaceHolder" + this.strName)) {
						document.getElementById("modelImagePlaceHolder" + this.strName).style.display = "none";
					}
	
				   if(document.getElementById("recordedVideoPlaceHolder" + this.strName)) {
				   	document.getElementById("recordedVideoPlaceHolder" + this.strName).style.display = "block";
				   	document.getElementById("recordedVideoPlaceHolder" + this.strName).innerHTML = strOutput;
				   }
	
				   if(document.getElementById("privateUrl" + this.strName)) {
				   	this.strOldPrivateLink = document.getElementById("privateUrl" + this.strName).href;
				   	this.strOldPrivateHTML = document.getElementById("privateUrl" + this.strName).innerHTML;
	
				   	document.getElementById("privateUrl" + this.strName).href = "#";
				   	document.getElementById("privateUrl" + this.strName).onclick = function() {
				   		me.onHideRecordedVideo(true);
				   		return false;
				   	};
				   	document.getElementById("privateUrl" + this.strName).innerHTML = "Back to chat";
				   	if(document.getElementById("privateControl" + this.strName)) {
				   		switch(BrowserDetect.browser) {
								case 'Explorer':
									document.getElementById("privateControl" + this.strName).style.display = "block";
								break;
								case 'Firefox':
				   				document.getElementById("privateControl" + this.strName).style.display = "table-row";
				   			break;
				   		}	
				   	}
				   }
	
				   if(blnFlv) {
					   flowplayer("pl", "/lib/javascript/external/FlowPlayer/flowplayer-3.0.5.swf", {
							clip: {
								scaling: 'scale'
							},
							plugins: {
								controls: {
									display: 'none'
								}
							}
						});
					}
				   
				   ///////////
					// Favorite Link
					this.objOldObject = this.objCurrentObject;
					this.objCurrentObject = objContent;
					this.objModelVideoSet = objSet;
				break;
				default:
					this.onHideVideo();
			}
		} else if (this.intUserId) {
			this.onConfirmRegistrationEvent();
		} else {
			this.onRegisterEvent(null, 'vote');
		}
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.onHideRecordedVideo = function onHideRecordedVideo(blnShowVideo) {
		this.stopVideo();	
	   if(document.getElementById("recordedVideoPlaceHolder" + this.strName)) {
	   	document.getElementById("recordedVideoPlaceHolder" + this.strName).style.display = "none";
	   }

	   if(document.getElementById("videoControl" + this.strName)) {
			document.getElementById("videoControl" + this.strName).style.display = "block";
		}

		if(document.getElementById("privateUrl" + this.strName)) {
			if(this.strOldPrivateLink) {
	   		document.getElementById("privateUrl" + this.strName).href = this.strOldPrivateLink;
	   	}
	   	if(this.strOldPrivateHTML) {
	   		document.getElementById("privateUrl" + this.strName).innerHTML = this.strOldPrivateHTML;
	   	}
	   	document.getElementById("privateUrl" + this.strName).onclick = null;
	   }

	   if(document.getElementById("modelImagePlaceHolder" + this.strName)) {
			document.getElementById("modelImagePlaceHolder" + this.strName).style.display = "block";
		}

		if(document.getElementById("privateControl" + this.strName)) {
   		document.getElementById("privateControl" + this.strName).style.display = "none";
   	}
		this._hideOther("");
		if(this.objOldObject) {
	   	this.objCurrentObject = this.objOldObject;
	   }
	   if(blnShowVideo) {
	   	this.onShowVideo();
	   }
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.stopVideo = function() {
		
		if(objPlayer = document.getElementById("player_" + this.strName)) {
			switch(BrowserDetect.browser) {
				case 'Explorer':
					objPlayer.fileName = "";
				break;
				case 'Firefox':
					objPlayer.data = "";
				break;
				default:
					if(objPlayer.data)
						objPlayer.data = "";
					else
					{
						objPlayer.fileName = "";
						objPlayer.controls.stop();
					}
			}
		}
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.onFavorite = function onFavorite(blnDelete) {
		if(this.blnIsFavorite && !blnDelete) {
			this.displayExtra('favorite', true);
			var strFavType = "Model";
			if(this.objCurrentObject.className == "DHL.CONTENT.JSMODELVIDEO") {
				strFavType = "Video";
			}
			document.getElementById("favoriteText").innerHTML = "This " + strFavType + " has been added to your " + 
				"<a href=\"" + this.objFavoriteUrl.toString() + "\">favorites</a>";
			blnDeleteFavorite = false;
		}
		else {
			if(!this.blnChanging) {
				this.blnChanging = true;

				var blnError = false;
				var objUrlFavorite = new DHL.NET.URL.getCurrent();
				var intClassId = this.objCurrentObject.getClassId();
				var intObjectId = this.objCurrentObject.getId()
				var intMediaSectionId = 7

				if(this.objCurrentObject.className == "DHL.CONTENT.JSMODELVIDEO") {
					intClassId = 97;//VideoSet
					intObjectId = this.objCurrentObject.getVideoSetId();
					intMediaSectionId = 4;
				}

				objUrlFavorite.setPath('/shared/template/favorite_admin.php');
				strAttributes = "favClassId=" + intClassId +
					"&favObjectId=" + intObjectId +
					"&favMediaSectionId=" + intMediaSectionId;

				if(blnDelete) {
					strAttributes += "&delete=1";
					this.blnDeleteFavorite = true;
				}

				this.objFavoriteHttpRequest.open('POST', objUrlFavorite, true);

				this.objFavoriteHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				this.objFavoriteHttpRequest.setRequestHeader('Content-length', strAttributes.length);
				this.objFavoriteHttpRequest.setRequestHeader('Connection', 'close');

				this.objFavoriteHttpRequest.onreadystatechange(this.onFavoriteStateChange);
				this.objFavoriteHttpRequest.send(strAttributes);
			}
		}
	}

	CM_WEBCOMPONENT_VIDEOINTERFACE.prototype.onFavoriteStateChange = function onFavoriteStateChange() {
		if(me.objFavoriteHttpRequest.getReadyState() == 4	&& me.objFavoriteHttpRequest.getStatus() == 200) {
			if(me.objFavoriteHttpRequest.getResponseText()){
				me.blnChanging = false;
				var strFavType = "Model";
				if(me.objCurrentObject.className == "DHL.CONTENT.JSMODELVIDEO") {
					strFavType = "Video";
				}
				if(me.blnDeleteFavorite) {
					document.getElementById("favoriteText").innerHTML = "This " + strFavType + " has been removed from your " +
						"<a href=\"" + me.objFavoriteUrl.toString() + "\">favorites</a>";
					document.getElementById("removeFav").style.display = "none";
					me.blnIsFavorite = false;
					me.blnDeleteFavorite = false;
				} else {
					me.displayExtra('favorite', true);
					document.getElementById("favoriteText").innerHTML = "This " + strFavType + " has been added to your " + 
						"<a href=\"" + me.objFavoriteUrl.toString() + "\">favorites</a>";
					document.getElementById("removeFav").style.display = "block";
					me.blnIsFavorite = true;
				}
			}
		}
	}
}