function $(id) { return document.getElementById(id); }

function setMenuHighlight() {
	//Determine special cases first
	if (window.location.href.indexOf("/tipsandadvice/") > -1) {
		var lnks = document.getElementById('menu').getElementsByTagName('a');
		for (var i=0; i < lnks.length; i++) {
			if (lnks[i].innerHTML == "Tips and Advice") {
				lnks[i].setAttribute('class', 'selected');
				lnks[i].setAttribute('className', 'selected');
				return;
			}
		}
	}
	
	//General rules
	var menu = document.getElementById('menu');
	var category = menu.firstChild;
	var links;
	while (category != null) {
		if (category.nodeName == 'LI') {
			links = category.getElementsByTagName('a');
			for (var i=0; i < links.length; i++) {
				if (window.location.href == links[i].href) {
					links[0].setAttribute('class', 'selected');
					links[0].setAttribute('className', 'selected');
					return;
				}
			}
		}
		category = category.nextSibling;
	}
}

function addSwf(filename, width, height, flashvars, id, wmode) {
	if (flashvars == null) flashvars = '';
	if (id == null) id = '';
	if (wmode == null) wmode = 'transparent';
	
	var output = '<object id="'+ id+ '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
						'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" '+
						'width="'+ width+ '" height="'+ height+ '" wmode="'+ wmode+ '" title="">'+
					'<param name="movie" value="'+ filename+ '" />'+
					'<param name="quality" value="high" />'+
					'<param name="wmode" value="'+ wmode+ '" />'+
					'<param name="FlashVars" value="'+ flashvars+ '" />'+
					'<param name="allowScriptAccess" value="always" />'+
					'<embed src="'+ filename+ '" quality="high" '+
						'pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" '+
						'type="application/x-shockwave-flash" wmode="'+ wmode+ '" '+
						'width="'+ width+ '" height="'+ height+ '" flashVars="'+ flashvars+ '"></embed>'+
				'</object>';
	document.write(output);
}

