﻿function removeProtocol(b){
    b = b.replace("http://","");  // Strips out the http - lowercase - protocol from the HREF of the link
    b = b.replace("HTTP://","");  // Strips out the HTTP - uppercase - protocol from the HREF of the link
    b = b.replace("https://","");  // Strips out the https - lowercase - protocol from the HREF of the link
    b = b.replace("HTTPS://","");  // Strips out the HTTPS - uppercase - protocol from the HREF of the link
    return b;
}

function trackQuickLinks(QuickLinks){
    WebsiteEventTracker._trackEvent("NavigationTracking", "Navigation-Next", ("PageTitle=" + document.title.toLowerCase() + "&LinkText=" + QuickLinks + "&LinkDIVid=" + "null" + "&LinkDIVclass=" + "boxright"));
}

var o;
if(document.getElementById && document.createElement && (o = document.getElementById('quicklinks'))) {
	var f = document.createElement('form');
	var l = document.createElement('select');
	l.id = 'selQuicklinks';
	var x = document.createElement('option');
	x.value = '';
	x.appendChild(document.createTextNode(firstItem));
	l.appendChild(x);
	for(var i=0; i<o.childNodes.length; i++) {
		if(o.childNodes[i].tagName != 'LI') continue;
		var link = o.childNodes[i].firstChild;
		while(link && link.tagName != 'A') {
			link = link.nextSibling;
		}
		if(!link) continue;
		var opt = document.createElement('option');
		opt.value = link.getAttribute('href');
		opt.appendChild(link.firstChild);
		l.appendChild(opt);
	}
	var input = document.createElement('input');
	input.type = 'button';
	input.value = 'Go';
	input.id = 'butGoQuickLinks';
	input.onclick = function() {
		var ql = document.getElementById('selQuicklinks');
		if(!ql) return;
		var cur = ql.options[ql.selectedIndex];
		if(cur && cur.value) document.location = cur.value;
        trackQuickLinks(ql.options[ql.selectedIndex].text.toLowerCase() + "&FormAction=" + removeProtocol(cur.value).toLowerCase());

	}
	f.appendChild(l);
	f.appendChild(document.createTextNode(' '));
	f.appendChild(input);
	o.parentNode.replaceChild(f, o);
	if(o = document.getElementById('quicklinks_heading')) {
		l = document.createElement('label');
		l.setAttribute('for', 'selQuicklinks');
		l.appendChild(o.firstChild);
		o.appendChild(l);
	}
}
