function CM_WEBCOMPONENT_CONTENT_SHARE(strName) {
	this.strName = strName;
	this.intWidth = 0;
	this.objUrl = null;
	this.objEmailHttpRequest = new DHL.NET.HTTPREQUEST();
	this.objErrorContainer = null;
	this.blnChanging = false;
	var me = this;
	this.objForm = null;
	this.intTimeoutId = null;
	this.intRewardAccountId = null;
	this.strShareImage = "";
	this.arrProhibitedParam = new Array();

	CM_WEBCOMPONENT_CONTENT_SHARE.prototype.setLink = function setLink(objUrl) {
		this.objUrl = objUrl;
	}

	CM_WEBCOMPONENT_CONTENT_SHARE.prototype.addProhibitedParam = function addProhibitedParam(strParam) {
		this.arrProhibitedParam.push(strParam);
	}
	
	CM_WEBCOMPONENT_CONTENT_SHARE.prototype.getRewardAccountId = function getRewardAccountId() {
		return this.intRewardAccountId;
	}

	CM_WEBCOMPONENT_CONTENT_SHARE.prototype.setRewardAccountId = function setRewardAccount(intRewardAccountId) {
		this.intRewardAccountId = intRewardAccountId;
	}

	CM_WEBCOMPONENT_CONTENT_SHARE.setShareImage = function setShareImage(strImage) {
		this.strShareImage = strImage;
	}

	CM_WEBCOMPONENT_CONTENT_SHARE.prototype.setErrorContainer = function setErrorContainer(objErrorContainer) {
		this.objErrorContainer = objErrorContainer;
	}

	CM_WEBCOMPONENT_CONTENT_SHARE.prototype.setWidth = function setWidth(intWidth) {
		this.intWidth = intWidth;
	}

	CM_WEBCOMPONENT_CONTENT_SHARE.prototype.render = function render() {
		if(this.objUrl) {
			
			if(this.intWidth > 0) {
				document.getElementById(this.strName + "header").style.width = (this.intWidth+30) + "px";
				document.getElementById(this.strName + "content").style.width = this.intWidth + "px";
			}
			objUrl = new DHL.NET.URL(this.objUrl);
			
			for(var intI = 0; intI < this.arrProhibitedParam.length; intI++) {
				objUrl.removeAttribute(this.arrProhibitedParam[intI]);
			}

			document.getElementById(this.strName + "directLink").value = objUrl.toString();
			//this.renderLink();
		}
	}

	CM_WEBCOMPONENT_CONTENT_SHARE.prototype.renderLink = function renderLink() {
		objMySpaceUrl = new DHL.NET.URL_MYSPACE();
		objMySpaceUrl.setTitle(document.title);
		objMySpaceUrl.setUrl(this.objUrl);
		objMySpaceUrl.setContent("<img src='http://static.camsters.com/shared/modelImage/3/4048/701699.jpg' border='0'>");

		document.getElementById(this.strName + "mySpaceLink").href = objMySpaceUrl.toString();
	}

	CM_WEBCOMPONENT_CONTENT_SHARE.prototype.onShareEmail = function onShareEmail(objForm) {
		if(!this.blnChanging	) {
			me.objErrorContainer.style.display = "none";
			//this.blnChanging = true;

			var blnError = false;
			var objUrlShareEmail = new DHL.NET.URL.getCurrent();

			//Validate Email Liste
			
			objForm["email"].value = objForm["email"].value.replace(/\r\n|\n|\t/gi, ",");
			var arrEmail = DHL.NET.EMAIL.parseMultiEmail(objForm["email"].value);
			if(
				arrEmail &&
				arrEmail.length
			) {
				//Re-Format the email field with valid email
				objForm["email"].value = "";
				for(var intI = 0; intI < arrEmail.length; intI++) {
					if(objForm["email"].value != "") {
						objForm["email"].value += ",";
					}
					objForm["email"].value += arrEmail[intI].toString();
				}

				strAttributes = 
					"frmName=" + this.strName + "&" + 
					"email=" + objForm["email"].value + "&" + 
					"message=" + objForm["message"].value + "&" +
					"sharedLink=" + objForm[this.strName + "directLink"].value;
					
				if (objForm['sharedContentClassId'] && objForm['sharedContentObjectId']) {
					strAttributes += "&sharedContentClassId=" + objForm['sharedContentClassId'].value + 
							"&sharedContentObjectId=" + objForm['sharedContentObjectId'].value;
				}

				this.objEmailHttpRequest.open('POST', objUrlShareEmail, true);
				this.objEmailHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				this.objEmailHttpRequest.setRequestHeader('Content-length', strAttributes.length);
				this.objEmailHttpRequest.setRequestHeader('Connection', 'close');
				this.objEmailHttpRequest.onreadystatechange(function() {
					me.onShareEmailStateChange();
				});
				this.objEmailHttpRequest.send(strAttributes);
				
				this.objForm = objForm;
				if(this.objForm["send"]) {
					this.objForm["send"].disabled = true;
				}
			}
			else {
				me.objErrorContainer.innerHTML = "Please enter a valid email.";
				me.objErrorContainer.style.display = "block";
			}
			
		}
	}

	CM_WEBCOMPONENT_CONTENT_SHARE.prototype.onSendCountDown = function onSendCountDown(intCurrentSecond) {
		if(intCurrentSecond <= 0) {
			me.objForm["send"].value = "Send";
			me.objForm["send"].disabled = false;
			document.getElementById(me.strName + "Success").style.display = "none";
			document.getElementById(me.strName + "Container").style.display = "block";
			
			clearInterval(me.intTimeoutId);
			me.intTimeoutId = null;
		}
		else {
			me.objForm["send"].value = "Send (" + intCurrentSecond + ")";
			setTimeout(function () {
				me.onSendCountDown(--intCurrentSecond);
			}, 1000);
		}
	}

	CM_WEBCOMPONENT_CONTENT_SHARE.prototype.onShareEmailStateChange = function onShareEmailStateChange() {
		objEmailHttpRequest = me.objEmailHttpRequest;

		if(objEmailHttpRequest.getReadyState() == 4	&& objEmailHttpRequest.getStatus() == 200) {
			if(objEmailHttpRequest.getResponseText()){
				me.blnChanging = false;
				if(objEmailHttpRequest.getResponseText() == 'ok') {
					//alert('Email(s) sent successfully!');
					document.getElementById(me.strName + "Success").innerHTML = 
						"<center>Your have shared this link with <br> " +
						me.objForm["email"].value +
						".<br> " +
						"Thank you " +
						"</center> ";
					
					document.getElementById(me.strName + "Success").style.display = "block";
					document.getElementById(me.strName + "Container").style.display = "none";
					
					me.intTimeoutId = setTimeout(function() {
						me.onSendCountDown(29)
					}, 1000);
					me.objForm["email"].value = "";
					me.objForm["message"].value = "";
				}
				else {
					switch(objEmailHttpRequest.getResponseText()) {
						case "DHL_EXP_CM_WEBCOMPONENT_SHARE_TOOMANYRECIPIENT":
							me.objErrorContainer.innerHTML = "Sorry, only 3 recipient at a time.";
						break;
						case "DHL_EXP_CM_WEBCOMPONENT_SHARE_REQUIREEMAIL":
							me.objErrorContainer.innerHTML = "Please enter a valid destination email.";
						break;
						case "DHL_EXP_CM_WEBCOMPONENT_SHARE_TOOMANYREQUEST":
							me.objErrorContainer.innerHTML = "Sorry, you need to wait some time between each email sharing.";
						break;
						case "DHL_EXP_CM_WEBCOMPONENT_SHARE_REQUIREUSER":
							me.objErrorContainer.innerHTML = "Sorry, you need to be logued to be able to send mail sharing.";
						break; 
					}
					me.objErrorContainer.style.display = "block";
					me.objForm["send"].disabled = false;
				}
			}
		}
	}
	
	CM_WEBCOMPONENT_CONTENT_SHARE.prototype.onShareEmailFromFlash = function onShareEmailFromFlash(objForm) {
		if(!this.blnChanging	) {
			//me.objErrorContainer.style.display = "none";
			//this.blnChanging = true;

			var blnError = false;
			var objUrlShareEmail = new DHL.NET.URL.getCurrent();

			//Validate Email Liste
			
			objForm["email"] = objForm["email"].replace(/\r\n|\n|\t/gi, ",");
			var arrEmail = DHL.NET.EMAIL.parseMultiEmail(objForm["email"]);
			if(
				arrEmail &&
				arrEmail.length
			) {
				//Re-Format the email field with valid email
				objForm["email"] = "";
				for(var intI = 0; intI < arrEmail.length; intI++) {
					if(objForm["email"] != "") {
						objForm["email"] += ",";
					}
					objForm["email"] += arrEmail[intI].toString();
				}

				strAttributes = 
					"frmName=" + this.strName + "&" + 
					"email=" + objForm["email"] + "&" + 
					"message=" + objForm["message"] + "&" +
					"sharedLink=" + objForm["directLink"];
				if (objForm['sharedContentClassId'] && objForm['sharedContentObjectId']) {
					strAttributes += "&sharedContentClassId=" + objForm['sharedContentClassId'] + 
							"&sharedContentObjectId=" + objForm['sharedContentObjectId'];
				}

				this.objEmailHttpRequest.open('POST', objUrlShareEmail, true);
				this.objEmailHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				this.objEmailHttpRequest.setRequestHeader('Content-length', strAttributes.length);
				this.objEmailHttpRequest.setRequestHeader('Connection', 'close');
				this.objEmailHttpRequest.send(strAttributes);
				blnReturn = true;
			}
			else {
				//me.objErrorContainer.innerHTML = "Please enter a valid email.";
				blnReturn = false;
			}
			return blnReturn;
		}
	}
}