// menubar animation
window.addEvent('domready', function(){
	new Accordion("div.mbdiv", "ul.mbexpand", {opacity:true, show:-1}, $('menubar'));
});

function nolink() {};

// this code is to get IE6 to accept the dropdown
if (document.all)
{
	$$("#menubar li").forEach(function(lnk) {
		if ($(lnk).lastChild.tagName == "DIV") {
			$(lnk).onmouseover = new Function("this.lastChild.style.display = 'block';");
			$(lnk).onmouseout = new Function("this.lastChild.style.display = 'none';")
		}
	});
}

Element.extend({
	SelectedValue: function() { 
		if (this.nodeName.toLowerCase() == "select") {
			return this.options[this.selectedIndex].value;
		} else {
			return false;	
		}; 
	},
	SelectedLabel: function() {
		if (this.nodeName.toLowerCase() == "select") {
			return this.options[this.selectedIndex].text;
		} else {
			return false;	
		}; 
	},
	cleanWhitespace: function() {
        $A(this.childNodes).each(function(node){
            if ($type(node) == 'whitespace') {
                this.removeChild(node);
            }
        }, this);
        return this;
    }
});

function scalar(obj, str) {return obj.getElementsByTagName(str)[0].firstChild.nodeValue;}

var DataSet = new Class({
	cell: function(iRows, sCol) {
		return this.rows[iRows].get(sCol);
	},
	transform: function() {
		var arrRows = new Array();
		var dt = this.source.getElementsByTagName("Table");
		for (i=0; i<dt.length; i++) // rows
		{
			var hash = new Hash();
			for (j=0; j<dt[i].childNodes.length; j++)
			{
				if (dt[i].childNodes[j].nodeType != 3) // avoid whitespace (MOZ/SAF)
				{
				    try {
					    hash.set(dt[i].childNodes[j].nodeName, dt[i].childNodes[j].childNodes[0].nodeValue);
					} catch(e) {
					    hash.set(dt[i].childNodes[j].nodeName, "");
					}
				}
			}
			arrRows.push(hash);
		}
		
		return arrRows;
	},
	rowcount: function() {
		return this.rows.length;
	},
	initialize: function(oXml) {
		this.source = oXml;
		this.rows = this.transform();
	}
});

