function RelatedSitesControl(){ // The root element. var _rootElement = null; var _data = null; var _properties = null; // Public RelatedSitesControl.data; RelatedSitesControl.properties; // Gets the root element. function CreateRootElement(tag, id, sibling){ if (tag == null) { return null; } if (id == null) { return; } var instanceNum = 0; var element = document.getElementById(id); while (element != null) { instanceNum++; element = document.getElementById(id + instanceNum.toString()); if (element == null) { id = id + instanceNum.toString(); break; } } element = document.createElement(tag); element.id = id; var parent = sibling.parentNode; if ( !sibling.nextSibling ) { parent.appendChild(element); } else{ parent.insertBefore(element,sibling.nextSibling); } parent.insertBefore(element,sibling.nextSibling); return element; } function SetHover(target, popup){ try { target.onmouseover = function(){ popup.style.display = ''; popup.style.visibility = 'visible'; }; target.onmouseout = function(){ popup.style.display = 'none'; popup.style.visibility = 'hidden'; }; popup.onmouseover = function(){ this.style.display = ''; this.style.visibility = 'visible'; }; popup.onmouseout = function(){ this.style.display = 'none'; this.style.visibility = 'hidden'; }; } catch (a) { } } function Render() { var parent = _rootElement; var targetPanel = null; var popupPanel = null; var contentsDiv = null; var mainPanel = null; var maxTextLen = 80; var linkIndex = 0; var titleCount = 0; var currentTitle; contentsDiv = $CElem('div','RelatedLinksContent','contents'); parent.appendChild(contentsDiv); child = $CElem('div','RelatedLinksTag','RelatedLinksTag'); contentsDiv.appendChild(child); parent = child; currentTitle = _data[0].Title; titleCount += currentTitle ? currentTitle.length : 0; child = $CElem('div','RelatedLinkTag'); child.appendChild(document.createTextNode(currentTitle)); parent.appendChild(child); linkIndex++; while ( linkIndex < _data.length && titleCount < maxTextLen ) { child = $CElem('div','RelatedLink' + linkIndex.toString(),'RelatedLink'); contentsDiv.appendChild(child); parent = child; currentTitle = _data[linkIndex].Title; titleCount += currentTitle.length; child = CreateAnchor(currentTitle,_data[linkIndex].Uri,null,null); if ( /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) ) { var data = {Title:currentTitle,Url:_data[linkIndex].Uri}; child.setAttribute('onmousedown',function() { TrackEvent('RelatedLinkClick',data); return true;} ); } else { child.setAttribute('onmousedown',"TrackEvent('RelatedLinkClick',{Title:'" + currentTitle + "',Url:'" + _data[linkIndex].Uri + "'}); return true;"); } parent.appendChild(child); linkIndex++; } if ( linkIndex < _data.length ) { child = $CElem('div','RelatedViewMore','RelatedLink'); contentsDiv.appendChild(child); parent = child; targetPanel = child; child = CreateAnchor(_properties['relatedSitesText'],"javascript:void(0);"); parent.appendChild(child); parent = child; child = $CElem('img',null,'DropDownArrow',null,{src:_properties['arrowImage']}); parent.appendChild(child); child = $CElem('div','RelatedLinkMore','ContextMenuPanel','visibility: hidden; display: none;'); targetPanel.appendChild(child); parent = child; popupPanel = child; targetPanel.appendChild(document.createElement('br')); while ( linkIndex < _data.length ) { child = $CElem('div','RelatedLink' + linkIndex.toString(),null); popupPanel.appendChild(child); parent=child; currentTitle = _data[linkIndex].Title; child = CreateAnchor(currentTitle,_data[linkIndex].Uri,'ContextMenuItem',null); if ( /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) ) { var data = {Title:currentTitle,Url:_data[linkIndex].Uri}; child.setAttribute('onmousedown',function() { TrackEvent('RelatedLinkClick',data); return true;} ); } else { child.setAttribute('onmousedown',"TrackEvent('RelatedLinkClick',{Title:'" + currentTitle + "',Url:'" + _data[linkIndex].Uri + "'}); return true;"); } parent.appendChild(child); linkIndex++; } SetHover(targetPanel,popupPanel); } parent = _rootElement; parent.appendChild($CElem('div',null,'Clear')); child = $CElem('div',null,'rlBottom'); child.appendChild($CElem('div',null,'blc')); child.appendChild($CElem('div',null,'brc')); parent.appendChild(child); } function CreateAnchor(title,url,cssClass,style) { var anchor = document.createElement('a'); anchor.setAttribute('href',url); anchor.appendChild(document.createTextNode(title)); if ( cssClass != null ) { anchor.setAttribute(window.ActiveXObject ? 'className' : 'class',cssClass);} if ( style != null ) { anchor.setAttribute('style',style);} return anchor; } function $CElem ( tag, id, cssClass,style, data ) { var elem = document.createElement(tag); if ( id ) { elem.setAttribute('id',id); } if ( cssClass ) { elem.setAttribute(window.ActiveXObject ? 'className' : 'class',cssClass); } if ( style ) {elem.setAttribute('style',style); } if ( data ) { for ( var key in data ) { elem[key] = data[key]; } } return elem; } RelatedSitesControl.prototype.Init = function(root,sData) { if ( root == null ) { return; } _data = !sData ? RelatedSitesControl.data : sData; _properties = RelatedSitesControl.properties; if ( !_data || _data.length < 1 || !_properties || _properties.length < 1) { return; } _rootElement = CreateRootElement('div', 'RelatedLinks',root); Render(); } } RelatedSitesControl.data = [{"Title":"Microsoft TechNet","Uri":null,"Brand":"TechNet","LCID":1033},{"Title":"Home","Uri":"http://technet.microsoft.com/en-us/default.aspx","Brand":"TechNet","LCID":1033},{"Title":"Library","Uri":"http://technet.microsoft.com/en-us/library/aa991542.aspx","Brand":"TechNet","LCID":1033},{"Title":"Learn","Uri":"http://technet.microsoft.com/en-us/bb291022.aspx","Brand":"TechNet","LCID":1033},{"Title":"Downloads","Uri":"http://technet.microsoft.com/en-us/bb403698.aspx","Brand":"TechNet","LCID":1033},{"Title":"Support","Uri":"http://technet.microsoft.com/en-us/ms772425.aspx","Brand":"TechNet","LCID":1033},{"Title":"Community","Uri":"http://technet.microsoft.com/en-us/bb291006.aspx","Brand":"TechNet","LCID":1033}];RelatedSitesControl.properties = {"relatedSitesText":"More","arrowImage":"http://i1.social.microsoft.com/WebResource.axd?d=aCAxpgxGhetaNjvgrXjoNDWvG-UWNcNHZng94iOP4HAYjJP485Cu4w-U1Nvp84DCuSpoUMSA-_sygW-FmwMvIc9djCaxpKsNsH7nqcP642H6GQOreCHq_eWSNXBI4qcZQDoK1H6_c4uMUg3SbAR76lV34vdbiPRmtwjtGewguMpX4JVYn4xxatFV8nOFrG8T0&t=633646038652132942"};