	/**
	* Method for displaying page overlay.
	* @param body{String|HTMLElement} the overlay iFrame HTML page location
	* @param width{int} (optional) the overlay width
	* @param height{int} (optional) the overlay height	
	*/
	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: false,		  // 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)		
			WR.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)		
				WR.util.showSelectBoxes();
			
			//HD.util.Analytics.track(this.analyticsCloseString());
			this.getObservable().notifyObservers("overlayClose");
		}
	};
	
	
	HD.CategoriesWidget.prototype.update = function(eventName, eventData) {
		// Update the selector if necessary.
		if (eventName == 'categories_Set') {							
			
			// Grab relevant data.
			var eventDataString = eventData.join(';');
			var nodes = [];
			var classes = HD.CSS_CLASSES;
			if (this.config.renderMode == 'list') {
				nodes = this.getParent().getElementsByTagName('a');
			}
			else if (this.config.renderMode == 'select') {
				nodes = this.getParent().getElementsByTagName('select');
			}
			
			// Update the selector.
			for (var i = 0; i < this.config.items.length; i++) {
				if (this.config.renderMode == 'list') {
					HD.removeClass(nodes[i].parentNode, classes.ACTIVE);
				}
				// Found matching categories, updating as active.
				if (this.config.items[i].categories.join(';') == eventDataString) {
					if (this.config.renderMode == 'list') {
						HD.addClass(nodes[i].parentNode, classes.ACTIVE);
					}
					else if (this.config.renderMode == 'select') {
						nodes[0].selectedIndex = i;
						break;
					}
				}// end if
			}// end for			
		}// end outer if
    };   	
	
    
    // 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>)';
	};
	
	// test override blog
	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.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";	
		
	},
	
	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);	
		}	
	};
	
	/**
	* Method for displaying page overlay.
	* @param body{String} the overlay source HTML as a string 
	* @param title {String} the overlay title string (used in iframe)
	* @param width{int} (optional) the overlay width
	* @param height{int} (optional) the overlay height	
	* @param iframe{Boolean} sets overlay to iframe instead of DOM display
	*/
	HDSocial.showOverlay = function(body, title, width, height,iframe) {
		var overlayEl = YAHOO.util.Dom.get("hdwcOverlay");		
		
		// hide overlay instance if one already exists
		if(overlayEl){this.hideOverlay();}			
			
		// 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;				
		}		
			
		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									
			};  
			
			if(iframe == true){
			//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);
			//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 closeClickCb = function(){			
				HDSocial.hideOverlay();
			};
			
			// use our hideOverlay method for when use clicks close on overlay
			// this allows for different events to fire when closing was user initiated
			var closeEls = YAHOO.util.Dom.getElementsByClassName("container-close", "a", overlayEl);
			closeEls.push(document.getElementById("hdSocial-closebtn"));
			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 = YAHOO.util.Dom.get("hdwcBody");
					var scrollableDivEl = YAHOO.util.Dom.get("scrollableDiv");				
					
					if(hdwcBodyEl) {
						hdwcBodyEl.style.height = (parseInt(height,10) - 65) + "px";
					}
					if(scrollableDivEl) {
						scrollableDivEl.style.height = (parseInt(height,10) - 90) + "px";					
					}
				}); 
				
			}
			
			this.overlay = overlay;

			return overlayEl;
		};		
		
		
		//share Digg
		HDSocial.hdDiggShare = function ( shareUrl, title, description, hbxContent, swfId, media ) {   
			// test url on wip with url from production
			//shareUrl = "http://www.harley-davidson.com/wcm/Content/Pages/women_riders/women_riders_stories.jsp?locale=en_US#loc=detail/photo/5259841/2";
		
			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);
			}		
		};
		
		function escapeHTMLEncode(str){
			var div = document.createElement('div');
			var text = document.createTextNode(str);
			div.appendChild(text);
			return div.innerHTML;
		}
		
		if(YAHOO.env.ua.ie == 6){
			document.execCommand("BackgroundImageCache", false, true);
		}
		
		HD.Login.Content.REGISTER.templates.optInLabel = 'Yes, I would like to receive additional email periodically regarding Harley-Davidson&#174; products and services. ';
		HD.Login.Content.REGISTER.templates.optInText = 'By checking the above box, I agree that I have read the <a onclick="javascript:window.open(\'http://www.harley-davidson.com/wcm/Content/Pages/Utility/privacy_policy.jsp?locale=en_US\', \'\', \'width=598,height=540,scrollbars=yes,resizable=yes,toolbar=no,location=no,menubar=no,directories=no,status=no\')" href="javascript:void(0)">Privacy Policy</a> and that I want to receive email from Harley-Davidson.';

