	(function () {
		//immediately hide noscript content	   
		var interval = window.setInterval(function(){
			if (document.body) {
				addClassName(document.body, 'scriptLoaded');
				window.clearInterval(interval);
			}
		}, 50);
		
		function init() {
			buildForm();
			var form = document.getElementById('compliance');
			if (!form)
				return;
			form.onsubmit = showProductChoice;
			if (document.location.hash) {
				var select = document.getElementById('complianceproduct');
				if (!select)
					return;
				var targetIndex = getIndexForValue(select, document.location.hash);
				if (targetIndex != -1) {
					select.selectedIndex = targetIndex;
					showProductChoice();
				}
			}
		}
		
		function buildForm() {
			var node;
			var parent = document.getElementById('formParent');
			var root = document.getElementById('noScriptLinks');
			if (!root)
				return;
			var docLinks = root.getElementsByTagName('a');
			parent.appendChild(createElem('p', {}, 'To view available standards compliance documents, select a product:'));
			var form = createElem('form', {id : "compliance", name : "compliance", action : "#"});
			parent.appendChild(form);
			var formBody = form.appendChild(createElem('p', {}));
			var select = formBody.appendChild(createElem('select', {id : "complianceproduct", name :"complianceproduct"}));
			select.appendChild(createElem('option', {value : "", disabled : 'disabled', selected : 'selected'}, 'Select product support center'));
				
			var optionAttribs;
			var name;
			for (var i = 0; i < docLinks.length; i++) {
				optionAttribs = {value : docLinks[i].hash};
				name = docLinks[i].innerText || docLinks[i].textContent;
				select.appendChild(createElem('option', optionAttribs, name));	
			}
			formBody.appendChild(createElem('input', {'class' : 'button', 'name' : 'submit', 'type' : 'submit', 'value' : 'View'}));
		}
		
		function createElem(tagName, attributes, textContent) {
			var node = document.createElement(tagName);
			for (var member in attributes) {
				node.setAttribute(member, attributes[member]);	
			}
			if (textContent) {
				textContent = textContent.replace(/&reg;/g, "\u00AE");
				textContent = textContent.replace(/&trade;/g, "\u2122");
				node.appendChild(document.createTextNode(textContent));
			}
			return node;
		}
		
		function getIndexForValue(select, value) {
			if (!select ||!select.options)
				return;
				
			for (var i = 0; i < select.options.length; i++) {
				if (select.options[i].value == value)
					return i;
			}
			return -1;
		}
		
		function getElementsByClassName(root, clsName) {
			if (root.getElementsByClassName) {
				return root.getElementsByClassName(clsName);
			}
			var nodeArray = [], elem; 
			var elems = root.getElementsByTagName("*");
			for ( var cls, i = 0; ( elem = elems[i] ); i++ ) {
				if ( hasClassName(elem, clsName)){
					nodeArray.push(elem);
				}
			}
			return nodeArray;
		}
		
		 function hasClassName(e,c) {
			if (!e) {
				return false;
			}
			var classes = e.className;
			if (!classes) { 
				return false;
			}
			if (classes == c) {
				return true;
			}
			return e.className.search("\\b" + c + "\\b") != -1;
		}
	
		function addClassName(e,c) {
			if (hasClassName(e, c)) {
				return;
			}
			if (e.className !== undefined) {	
				e.className = e.className + " " + c;
			}
		}
		
		function removeClassName(e,c) {
			if (typeof e == "string") {
				e = $(e);
			}
			e.className = e.className.replace(new RegExp("\\b" + c + "\\b\\s*", "g"), "");
		}
			
		function showProductChoice(event) {
			var dropDown = document.getElementById('complianceproduct');
			var docList = document.getElementById('docList')
			if (!dropDown ||!docList)
				return false;
			var choice = dropDown.value;
			
			if (!choice || choice.indexOf("#") == -1)
				return false;
			var target = document.getElementById(choice.substr(1));
			
			if (target)
			{
				var nodes = getElementsByClassName(docList, 'visible');
				for (var i = 0; i < nodes.length; i++) {
					nodes[i].className = "";
				}
				target.className = "visible";
				document.location = "#" + target.id;
			}
				nodes = null;
				return false
		}
		window.onload = init;
	}());
