// Business Catalyst 2008
function catSetSelectedCSSItem(menuid) {
    var _host = document.location.host;
	var _url = document.location.href.substring(document.location.href.indexOf(_host)+_host.length).toLowerCase();
	var _anchor;
    var _parent;
    var _class;
    var _image;
    var _anchors = document.getElementById(menuid).getElementsByTagName('a');

    for (var i=0;i<_anchors.length;i++) {
	    _anchor = _anchors[i].href.substring(document.location.href.indexOf(_host)+_host.length).toLowerCase();
	    if (_anchor == _url) {
            _image = _anchors[i].getAttribute('selimg'); // sel img is on anchor
			if (_image)
			    _anchors[i].style.background = "url("+_image+")";					
		    _parent = _anchors[i].parentNode; // get li node
		    while (_parent) {
			    if (_parent.id == menuid) break; // don't go up infinitely
			    if (_parent.tagName == "LI") {
				    _class = _parent.getAttribute('selcss'); // sel css is on li
				    if (_class)				
					    _parent.className = _class; 
				    else { // logic below as per partner req't
				        _class = _parent.getAttribute('class'); 
				        if (_class)
					        _parent.className = _class+" selected";	
				        else
					        _parent.className = "selected";	
					}
			    }
			    _parent = _parent.parentNode;
		    }
		    break;
	    }
	}
}
