HD.util.Common.showOverlay = function(body, title, width, height, isSkipDestroy) {
		var overlayEl = HD.get("hdwcOverlay");
		//hide overlay instance if one already exists
		if(overlayEl){this.hideOverlay(isSkipDestroy);}		
		//HD.util.Analytics.track(this.analyticsOpenString(body));
		this.getObservable().notifyObservers("overlayOpen");
		
		// get viewport height			
		var isResizeViewPort = 540 > YAHOO.util.Dom.getViewportHeight() && parseInt(height, 10) > 450;
	
		// if the viewport it too small for the overlay we will resize the overlay
		if(isResizeViewPort){			
			height = YAHOO.util.Dom.getViewportHeight() - 40;				
		}			
		
		// check if number if not convert
		if(!(typeof width == 'number'))
			width = parseInt(width.replace(/px/g, ""));				
		// check if number if not convert	
		if(!(typeof height == 'number'))
			height = parseInt(height.replace(/px/g, ""));			
		
		// find center of the viewport
		var posX = (YAHOO.util.Dom.getViewportWidth() / 2) - (width / 2);			
		var sfs = YAHOO.util.Dom.getDocumentScrollTop();		
		var posY = ((YAHOO.util.Dom.getViewportHeight() + sfs) / 2) - (height / 2);		
		
		posX = Math.round(posX);
		posY = Math.round(posY);		
			
		// configure overlay		
		var overlayConfig = {					
			constraintoviewport: true,
			close: true,		  // show close button
			draggable: true,	  // draggable
			zindex:100000,		  // z index
			modal: true,		  // overlays other elements
			visible: false,		  // visible right away
			iframe: true,		  // useful in overlay certain elements
			underlay : "shadow",   // show shadow,
			x : posX,
			y : posY,
			// set width and height if passed, append "px" if integers
			height: typeof height == 'number' ? height + 'px' : height || null,	
			width: typeof width == 'number' ? width + 'px' : width || null						
		};  

		//set iframe to import page body as overlay body. passes width, height and src string.
		//body = "<iframe class='hdwcOverlayIframe' src='" + body + "' frameBorder='0' height='" + height + "' width='" + width + "' scrolling='no' allowTransparency='true'></iframe>";
				
		var overlay = new YAHOO.widget.Panel("hdwcOverlay", overlayConfig);
		
		//overlay.setHeader(header);
		overlay.setBody(body);
		overlay.render(document.body);
		//Centers the overlay with scrolling Fix 19770
		overlay.center();
		//show the overlay
		overlay.show();
		
		//IF IE check to position overlay in the middle of the screen
		if (YAHOO.env.ua.ie > 0) {			
			YAHOO.util.Dom.setStyle("hdwcOverlay_c", 'top', posY);
			YAHOO.util.Dom.setStyle("hdwcOverlay_c", 'left', posX);			
		} 		
		
		var cb = this;
		var closeClickCb = function(){
			var observable = cb.getObservable.call(cb);
			observable.notifyObservers("overlayClose_Click");
			HD.util.Common.hideOverlay(isSkipDestroy);
			
		};
		
		var overlayEl = HD.get("hdwcOverlay");
		
		var closeEls = HD.getByClass("hdClose", "div", overlayEl);
		if(closeEls.length > 0) {
			closeEls[0].onclick = closeClickCb;
		}
		
		// use our hideOverlay method for when use clicks close on overlay
		// this allows for different events to fire when closing was user initiated
		closeEls = HD.getByClass("container-close", "a", overlayEl);
		for(var i = 0, len = closeEls.length; i < len; i++) {
			(function() {
				closeEls[i].onclick = closeClickCb;
			})();
		}
		
		// if the viewport it too small for the overlay we will resize overlay content
		if(isResizeViewPort){
			YAHOO.util.Event.onContentReady("hdwcBody", function(){				
				var hdwcBodyEl = HD.get("hdwcBody");
				var scrollableDivEl = HD.get("scrollableDiv");				
				
				if(hdwcBodyEl) {
					hdwcBodyEl.style.height = (parseInt(height,10) - 65) + "px";
				}
				if(scrollableDivEl) {
					scrollableDivEl.style.height = (parseInt(height,10) - 90) + "px";					
				}
			}); 
			
			YAHOO.util.Event.onContentReady("suggestions", function(){	
				var suggestionsContentWrapperEL = YAHOO.util.Dom.getElementsByClassName("suggestionsContentWrapper","div");
				if(suggestionsContentWrapperEL[0]){	
					for(var x=0; x<suggestionsContentWrapperEL.length; x++){						
						suggestionsContentWrapperEL[x].style.height = (parseInt(height,10) - 65) + "px";
					}
				}			
			}); 			
		}		
		
		// if IE6 hide select boxes
		if (YAHOO.env.ua.ie == 6)		
			HS.util.hideSelectBoxes();
		
		this.overlay = overlay;
		return overlayEl;
	};	
	
	/**
	* Method for hiding page overlay.
	*/
	HD.util.Common.hideOverlay = function(isSkipDestroy) {
		
		//if there is an existent overlay, hide it			
		if(this.overlay != null) {
			
			this.overlay.hide();
			if(!isSkipDestroy) {
				this.overlay.destroy();
			}
			
			// if IE6 show select boxes
			if (YAHOO.env.ua.ie == 6)		
				HS.util.showSelectBoxes();
			
			//HD.util.Analytics.track(this.analyticsCloseString());
			this.getObservable().notifyObservers("overlayClose");
			
			
		}
		
		// play the player
		if(landingVideoEl){
			landingVideoEl.sendEvent("PLAY", true);
		}
	};
	
	
	// override the T&C copy for posting a comment
    HD.CommentsWidget.templates.termsConditionsText = "By submitting this content, I consent that all videos, photographs, my name, my story and any other reproductions of my information and likeness (the &#8220;Materials&#8221;) may be used by Harley-Davidson, its affiliates (collectively referred to as &#8220;Harley-Davidson&#8221;) and/or others with its consent, for the purpose of illustration, advertising, promotions, duplication or publication or for any other purpose in any manner and in any media without further consideration. I represent and warrant that I am the owner of the Materials and have the rights to dispose of my ownership rights as I see fit. I hereby assign to Harley-Davidson all rights, title and interest in the Material and any other tangible medium of expression of my image and information including all copyrights therein that I provide to Harley-Davidson.";
    
 // override the video # of comment
    HD.community.Video.templates.getCommentsText = function(numOfComments) {
		return 'Comments (<u>' + numOfComments + '</u>)';
	};
	
	// override for IE 6 back button issue
	HDSocial.hideOverlay = function() {	
		//if there is an existent overlay, hide it			
		if(this.overlay != null) {
			this.overlay.hide();
			this.overlay.destroy();			
		}				
		
		if (YAHOO.env.ua.ie != 0 && hideOverlayFirstRun == "true"){			
			hideSocialOverlay = "true";			
		}			
		else 
			hideSocialOverlay = "false";	
		
		hideOverlayFirstRun = "false";	
		
	};
	
	
	// override message on myspace
	HDSocial.hdMSShare = function ( shareUrl, title, description, thumbUrl, hbxContent, swfId, media ) {
		var bor ='0';
		var ref = shareUrl;
		var tar ='_blank';
		var s = '8';
		var alt = title;
		var a = 'left';
		var p = thumbUrl;
		var i = '<a href='+ref+'  target='+tar+'><img src='+p+' align='+a+' alt='+alt+' hspace='+s+' border='+bor+'/></a>';
		var T =  title;
		var C =  i + description + "<br/>Read the full story: <a href='" + ref + "' target='" + tar + "'>" + T + "</a>";
		var U = '';
		var finalURL = 'http://www.myspace.com/index.cfm?fuseaction=postto&' + 't=' + encodeURIComponent(T) + '&c=' + encodeURIComponent(C) + '&u=' + encodeURIComponent(U) ;
		var properties = 'width=1024,height=768,scrollbars=yes,resizable=yes,toolbar=no,location=no,menubar=no,directories=no,status=no';		
		HDSocial.pageLink (finalURL, 'MySpace', properties, swfId);
		
		//hbx
		if (this.hasAnalytics()) {
			HD.util.Analytics.track(this.analyticsMyspaceString(media));			
		}
		else {
			_hbPageView('MySpace', hbxContent);	
		}	
	};
	
	
	//override message on blogger/wordpress
	HDSocial.hdBlogShare = function ( shareUrl, title, description, thumbUrl, hbxContent, swfId, target, media ) {
		var bor ='0';
		var ref = shareUrl;
		var tar ='_blank';
		var s = '8';
		var alt = title.replace(/['"]/g,'');
		var a = 'left';
		var p = thumbUrl;
		var U = '';
		var T =  title;

		var i = '<div id="HDSocialBlogPost">';
		i += '<div class="dblRuleBtm">';
		i += '  <div class="head">POST TO YOUR BLOG</div>';
		i += '</div>';
		i += '<div class="hdwcMedPadBtm">';
		i += '<div id="hdwcInstructions">Copy and paste the embed code below and post it to your blog:</div>';
		i += '</div>';
		i += '<div id="hdwcBody" class="wrap">';
		i += '<div class="htmlEmbedCode hdwcSmlPadBtm">';
		i += '	<h2>Embed Code</h2>';
		i += '  <textarea name="copyText" id="copyText" >';
		i += '<a href="'+ref+'  target='+tar+'"><img src="'+p+'" align="'+a+'" alt="'+alt+'" hspace="'+s+'" border="'+bor+'"/></a>';
		i += description + '<br/>Read the full story: <a href="' + ref + '" target="' + tar + '">' + T + '</a>';
		i += '</textarea>';
		i += '</div>';
		i += '<div class="btnOrange"><a href="javascript: void(0);" id="hdSocial-closebtn">Close</a></div>';
		i += '</div>';
		i += '</div>';		

		HDSocial.showOverlay( i, T, 586, 254, false);
		
		//hbx
		if (this.hasAnalytics()) {
			if (target == 'wordpress') {
				HD.util.Analytics.track(this.analyticsWordpressString(media));
			}
			else if (target == 'blogger') {
				HD.util.Analytics.track(this.analyticsBloggerString(media));
			}	
		}
		else {
			_hbPageView(target || 'Blog', hbxContent);
		}
	};
	
	HDSocial.hdDiggShare = function ( shareUrl, title, description, hbxContent, swfId, media ) {        
		
		// test url on wip using url from prod
		//shareUrl = "http://www.harley-davidson.com/wcm/Content/Pages/harlistas/harlistas_UGC.jsp?locale=en_US#loc=detail/photo/5266859";
		
		
		shareUrl = encodeURIComponent(shareUrl);
		var finalURL = 'http://digg.com/submit/?url=' + shareUrl + '&title=' + title + '&bodytext=' + description;
		//console.log(finalURL);
		var properties = 'width=1024,height=768,scrollbars=yes,resizable=yes,toolbar=no,location=no,menubar=no,directories=no,status=no';		
		HDSocial.pageLink (finalURL, 'Digg', properties, swfId);
	
		//hbx
		if (this.hasAnalytics()) {
			HD.util.Analytics.track(this.analyticsDiggString(media));			
		}
		else {
			_hbPageView('Digg', hbxContent);
		}		
	}
	
	// override the STAF overlay copy
		HD.SendFriendWidget.templates.sendFriendInstructionalText = "<p>Send your friend a link to this page so they can become involved in the Harlista community.</p><br/><p>Enter the name and email address of your friend below. We will not use this information for any other purposes. Review our <a onclick=\"javascript:window.open('http://www.harley-davidson.com/wcm/Content/Pages/Utility/privacy_policy.jsp?locale=en_US', '', 'width=598px,height=540px,scrollbars=yes,resizable=yes,toolbar=no,location=no,menubar=no,directories=no,status=no')\" href=\"javascript:void(0)\">Privacy Policy</a> for more details.</p><br/><p>* Indicates required fields</p>";
		HD.SendFriendWidget.templates.errorFriendEmailText        = "- Friend's Email Address";
		HD.SendFriendWidget.templates.errorFriendEmailInvalidText = "- Please enter a valid email address, in the format: yourname@provider.com.";
		HD.SendFriendWidget.templates.errorYourEmailText          = "- Your Email Address";
		HD.SendFriendWidget.templates.errorYourEmailInvalidText   = "- Please enter a valid email address, in the format: yourname@provider.com.";
		HD.SendFriendWidget.templates.errorUserNameText           = "- Your Name";
		HD.SendFriendWidget.templates.errorFriendNameText         = "- Friend's Name";
		
		// change width and height for STAF overlay
		HD.SendFriendWidget.prototype.setListeners = function(media) {
					if (!media) {
						return;
					}
					
					var self = this;
					
									
					// Add click events.
					var sendFriendEl = HD.getByClass(this.config.hooks.SENDBUTTON, '*', this.getParent())[0];
					
					if(sendFriendEl){
						var tooltipEl = HD.getByClass(this.config.hooks.SENDBUTTON_TOOLTIP, '*', this.getParent())[0];
						if (tooltipEl){
							sendFriendEl.onmouseover = function() {
								HD.addClass(tooltipEl, HD.CSS_CLASSES.SHARE+'Hover');
							};
							sendFriendEl.onmouseout = function() {
								HD.removeClass(tooltipEl, HD.CSS_CLASSES.SHARE+'Hover');
							};
						}
					}

					sendFriendEl.onclick = function() {
						
						self.config.callback(media);HD.util.Analytics.track(self.analyticsSendFriendString(media));
						HD.util.Common.requestContent(comSvcBaseUrl + '/hd/hd_send_friend/assets/sendToFriend.jsp?siteName=' + comSiteName, function(responseText) {
							var overlayEl = HD.util.Common.showOverlay(responseText, HD.SendFriendWidget.templates.getSendFriendLabel().toUpperCase(), "584px", "305px", false);
							// re-set the height of the overlay
							YAHOO.util.Dom.setStyle('hdwcBody','height','247px');
							// Add instructional text
							var instructionalEl = HD.util.Common.get('sendFriendInstructions');
							if (instructionalEl){
								instructionalEl.innerHTML = HD.SendFriendWidget.templates.getInstructionalText();
							}
							
							var formEl = overlayEl.getElementsByTagName("form")[0];
						
							formEl.onsubmit = function() {					
								self.handleSubmit(formEl, media);				
								return false;
							};
							
							//add hit enter events
							var inpEl = overlayEl.getElementsByTagName("input");
							for(var x=0; x<4; x++){
								inpEl[x].onkeypress = function(){
									if(YAHOO.env.ua.ie != 0){
										if(window.event.keyCode == 13){
											var sfbtn = document.getElementById("sendFriendButton");
											sfbtn.click();
										}							
									}
								}	
							}
							// stop the player
							if(landingVideoEl){
								landingVideoEl.sendEvent("PLAY", true);
								landingVideoEl.sendEvent("PLAY", false);
							}
						});
						
					};
					
					
		};
		
		HD.SendFriendWidget.prototype.handleSubmit = function (form, media) {
			var errorText = '';
			var emailValidate = /.+@.+\..+/;
			var userName = form.userName.value;
			userName = escapeHTMLEncode(userName);
			var userEmail = form.userEmail.value;
			var friendName = form.friendName.value;
			friendName = escapeHTMLEncode(friendName);
			var friendEmail = form.friendEmail.value;	
			var templates = HD.SendFriendWidget.templates;
			var reqEl;
			var emailValText = '';
			
			HD.removeClass(HD.get(HD.CSS_CLASSES.SEND_FRIEND+'-UserName'), 'hdwcValidationError');
			HD.removeClass(HD.get(HD.CSS_CLASSES.SEND_FRIEND+'-FriendName'), 'hdwcValidationError');
			HD.removeClass(HD.get(HD.CSS_CLASSES.SEND_FRIEND+'-UserEmail'), 'hdwcValidationError');
			HD.removeClass(HD.get(HD.CSS_CLASSES.SEND_FRIEND+'-FriendEmail'), 'hdwcValidationError');
			var errorsEl = HD.get('hdValidationErrors');
			
			
			
			if (!friendName) {
				errorText += '<div class="hdwcErrorOverlayLarge" id="hdwcNotEmailValidation">' + templates.getErrorFriendNameText() + '</div>';
				HD.addClass(HD.get(HD.CSS_CLASSES.SEND_FRIEND+'-FriendName'), 'hdwcValidationError');
			}
			
			if (!userName) {
				errorText += '<div class="hdwcErrorOverlayLarge" id="hdwcNotEmailValidation">' + templates.getErrorUserNameText() + '</div>';
				HD.addClass(HD.get(HD.CSS_CLASSES.SEND_FRIEND+'-UserName'), 'hdwcValidationError');
			}
			
			if (!friendEmail) {
				errorText += '<div class="hdwcErrorOverlayLarge" id="hdwcNotEmailValidation">' + templates.getErrorFriendEmailText() + '</div>';
				HD.addClass(HD.get(HD.CSS_CLASSES.SEND_FRIEND+'-FriendEmail'), 'hdwcValidationError');
			}
			
			if (!userEmail) {
				errorText += '<div class="hdwcErrorOverlayLarge" id="hdwcNotEmailValidation">' + templates.getErrorYourEmailText() + '</div>';
				HD.addClass(HD.get(HD.CSS_CLASSES.SEND_FRIEND+'-UserEmail'), 'hdwcValidationError');
			}
			
			if (friendEmail && !friendEmail.match(emailValidate)) {
				emailValText += '<div class="hdwcErrorOverlayLarge" id="hdwcFriendEmailValidation">' + templates.getErrorFriendEmailInvalidText() + '</div>';
				HD.addClass(HD.get(HD.CSS_CLASSES.SEND_FRIEND+'-FriendEmail'), 'hdwcValidationError');
			}
			
			if (userEmail && !userEmail.match(emailValidate)) {
				emailValText += '<div class="hdwcErrorOverlayLarge" id="hdwcUserEmailValidation">' + templates.getErrorYourEmailInvalidText() + '</div>';
				HD.addClass(HD.get(HD.CSS_CLASSES.SEND_FRIEND+'-UserEmail'), 'hdwcValidationError');
			}
			
			
			// Inject errors.
			if (errorText || emailValText) {
				if (!errorsEl) {
					reqEl = document.createElement('div');
					reqEl.id = 'hdRequiredFields';
					reqEl.innerHTML = 'Fields in bold with an asterisk (*) are required.';
					var instructionsEl = HD.get('submissionInstructions');
					instructionsEl.parentNode.insertBefore(reqEl, instructionsEl.nextSibling);
					errorsEl = document.createElement('div');
					errorsEl.id = 'hdValidationErrors';
					reqEl.parentNode.insertBefore(errorsEl, instructionsEl.nextSibling);
					// re-set the height and width
					YAHOO.util.Dom.setStyle('hdwcOverlay','height','370px');
					YAHOO.util.Dom.setStyle('hdwcBody','height','312px');
				}
				
				errorsEl.innerHTML = errorText + "<br/>" + emailValText;
				
				// remove "Fields in bold..." if only email validate error that occurs
				if(!(document.getElementById("hdwcNotEmailValidation"))){
					document.getElementById("hdRequiredFields").style.display = "none";
				}else{
					document.getElementById("hdRequiredFields").style.display = "block";
				}
				
				
			}
			// Submit the form.
			else {
				if (errorsEl) {
					var pn = errorsEl.parentNode;
					if(pn != null){
						while(pn.childNodes.length >=1){
							pn.removeChild(pn.firstChild);
						}
					}
					// re-set the height and width
					YAHOO.util.Dom.setStyle('hdwcOverlay','height','305px');
					YAHOO.util.Dom.setStyle('hdwcBody','height','247px');
				}
				
				// Retrieve context parameters.
				this.config.submission.media = media.mediaId;
				var params = this.config.getParams(this.config.submission) || this.config.submission;
				var url = [
					params.url,
					'?_ID_=', encodeURIComponent(params.id || ''),
					'&YOURNAME=', encodeURIComponent(userName),
					'&YOUREMAIL=', encodeURIComponent(userEmail),
					'&FRIENDNAME=', encodeURIComponent(friendName),
					'&FRIENDEMAIL=', encodeURIComponent(friendEmail),
					'&communityID=', encodeURIComponent(params.community || ''),
					'&mediaID=', encodeURIComponent(params.media || ''),
					'&viewID=', encodeURIComponent(params.view || '')
				];
				for (var prop in params) {
					if (!prop.match(/^(id|community|media|view|url)$/)) {
						url.push('&', prop, '=', encodeURIComponent(params[prop]));
					}
				}
				
				// Send the request to the friend.
			HD.util.Analytics.track(this.analyticsSendFriendConfirmationString(media));
			HD.util.Common.requestContent(comSvcBaseUrl + '/hd/hd_send_friend/assets/sendToFriend.jsp?siteName=' + comSiteName + '&url='+escape(url.join('')), function(responseText) {
				var overlayEl = HD.util.Common.showOverlay(responseText, HD.SendFriendWidget.templates.getSendFriendLabel().toUpperCase(), "360px", "160px");
			});

			}
		};
		
		
		function escapeHTMLEncode(str){
			var div = document.createElement('div');
			var text = document.createTextNode(str);
			div.appendChild(text);
			return div.innerHTML;
		}
