function dropdownmenu(){

}

// 
function menuOver(e) {
	if (this.className.search(/\bopen\b/g) == -1) { this.className += ' open'; }
}
//
function menuOut(e) {
	this.className = this.className.replace(/\s*\bopen\b/g, '');
}

//
function menuItemOver(e) {
	if (this.className.search(/\bhover\b/g) == -1) { this.className += ' hover'; }
}
//
function menuItemOut(e) {
	this.className = this.className.replace(/\s*\bhover\b/g, '');
}

//
function sidebarBoxSwitch(boxId, itemIndex) {
	var box = document.getElementById(boxId);
	if (box) {
		var ul = box.getElementsByTagName('ul').item(0);
		if (ul) {
			var index = 0;
			for (var i = 0; i < ul.childNodes.length; i++) {
				var li = ul.childNodes[i];
				if (li.nodeType == 1 && li.nodeName.toLowerCase() == 'li') {
					if (index == itemIndex) {
						li.className = li.className.replace(/\bbox-item-inactive\b/, '');
						if (li.className.search(/\bbox-item-active\b/) == -1) {
							li.className += ' box-item-active';
						}
					} else {
						li.className = li.className.replace(/\bbox-item-inactive\b/, '');
						if (li.className.search(/\bbox-item-inactive\b/) == -1) {
							li.className += ' box-item-inactive';
						}
					}
					index++;
				}
				li = null;
			}
			ul = null;
		}
		box = null;
	}
}

function sidebarBoxButtonOnClick(e) {
	e = e || window.event;

	var li = this.parentNode.parentNode;
	var index = 0;
	var itemIndex = 0;
	for (var i = 0; i < li.parentNode.childNodes.length; i++) {
		var item = li.parentNode.childNodes[i];
		if (item.nodeType == 1 && item.nodeName.toLowerCase() == 'li') {
			if (item == li) { itemIndex = index; break; }
			index++;
		}
	}
	var boxId = this.parentNode.parentNode.parentNode.parentNode.id;
	sidebarBoxSwitch(boxId, itemIndex);

	return false;
}

//
// Adds hover behavior to menu list elements
function enhanceMenu()
{
	if (document.all) { // IE only
		var menu = document.getElementById('menu');
		if (menu) {
			var ul = menu.getElementsByTagName('ul').item(0);
			if (ul) {
				ul.onmouseover = menuOver;
				ul.onmouseout = menuOut;
				ul = null;
			}

			var lis = menu.getElementsByTagName('li');
			if (lis) {
				for (var i = 0; i < lis.length; i++) {
					var node = lis[i];
					// Add hover behavior
					node.onmouseover = menuItemOver;
					node.onmouseout  = menuItemOut;
					//
					node = null;
				}
				lis = null;
			}
			menu = null;
		}
	}
}


function enhanceSidebarBox(id, initItemIndex)
{
	id = id || false;
	initItemIndex = initItemIndex || 0;

	var box = document.getElementById(id);
	if (box) {
		var ul = box.getElementsByTagName('ul').item(0);
		if (ul) {
			var index = 0;
			for (var i = 0; i < ul.childNodes.length; i++) {
				var li = ul.childNodes[i];
				if (li.nodeType == 1 && li.nodeName.toLowerCase() == 'li') {
					var a = li.getElementsByTagName('a').item(0);
					if (a) {
						a.onclick = sidebarBoxButtonOnClick;
					}
					//
					if (index == initItemIndex) {
						li.className = li.className.replace(/\bbox-item-inactive\b/, '');
						if (li.className.search(/\bbox-item-active\b/) == -1) {
							li.className += ' box-item-active';
						}
					} else {
						li.className = li.className.replace(/\bbox-item-inactive\b/, '');
						if (li.className.search(/\bbox-item-inactive\b/) == -1) {
							li.className += ' box-item-inactive';
						}
					}
					index++;
				}
				li = null;
			}
			ul = null;
		}
		box = null;
		return true;
	}
	return false;
}


function enhanceHeaders()
{
	if (typeof sIFR == "function"){
		sIFR.replaceElement("#menu>ul>li>a", named({sFlashSrc: "aller.swf", sColor: "#ffffff", sHoverColor: "#ffffff", sCase: "upper", sWmode: "transparent", nPaddingTop: "12", nPaddingRight: "12", nPaddingBottom: "12", nPaddingLeft: "12"}));
		//sIFR.replaceElement("#menu li ul li>a", named({sFlashSrc: "aller.swf", sColor: "#ffffff", sHoverColor: "#ffffff", sCase: "upper", sWmode: "transparent", nPaddingTop: "10", nPaddingRight: "14", nPaddingBottom: "5", nPaddingLeft: "14"}));
		sIFR.replaceElement("#content-sidebar h3", named({sFlashSrc: "alleritalic.swf", sColor: "#003773", sWmode: "transparent"}));
	}
}


function initPage(e)
{
	e = e || window.event;

	enhanceMenu();
	enhanceSidebarBox('content-sidebar-recent');
	//enhanceHeaders();
}


//
//
if (document.getElementById && document.getElementsByTagName) {
	window.onload = initPage;
}



