function menu()
{
	var _nav = document.getElementById("top-nav");
	if (_nav)
	{
		var _a = _nav.getElementsByTagName("a");
		for (var i = 0; i < _a.length; i++)	{
			if(_a[i].parentNode.getElementsByTagName("ul")[0] && _a[i].parentNode.parentNode.id == "top-nav"){
				_a[i].onclick = function(){
					if (this.parentNode.className.indexOf("active") != -1){
						clearHover();
						this.parentNode.className = this.parentNode.className.replace(" active","");
					} else {
						clearHover();
						this.parentNode.className += " active";
					}
					return false;
				}
			}
		}
	}
	
	var _statPopup = document.getElementById("stats-popup");
	if (_statPopup) {
		var _a = _statPopup.getElementsByTagName("a");
		for (var i = 0; i < _a.length; i++)	{
			if(_a[i].className.indexOf("bt-block") != -1){
				_a[i].onclick = function(){
					if (_statPopup.className.indexOf("close") != -1){
						_statPopup.className = _statPopup.className.replace("close","");
					} else {
						_statPopup.className += " close";
					}
					return false;
				}
			}
		}
	}
}
function clearHover() {
	var _nav2 = document.getElementById("top-nav");
	if (_nav2)
	{
		_nav2li = _nav2.getElementsByTagName("li");
		for (var i = 0; i < _nav2li.length; i++) {
			_nav2li[i].className = _nav2li[i].className.replace("active","");
		}
	}
}
if (window.addEventListener)
	window.addEventListener("load", menu, false);
else if (window.attachEvent)
	window.attachEvent("onload", menu);

$(document).ready(function(){
	// Initialize Stats Popup				
	$("#stats-popup .stats-popup-holder > ul.popup-list").tabs(
			   defaults = {   
             navClass: 'popup-list',
 			 selectedClass: 'active',
             panelClass: 'stats-cont',
             hideClass: 'hide',
             fx: { opacity: 'toggle', duration: 'normal' }
         }
    );
    
    // Removes Search text on focus, changes text to #000 and back to #999 out of focus
    var inputs = document.getElementsByTagName("input");
	  for (var i = 0; i < inputs.length; i++) {
	     if (inputs[i].name == "search") {
	        inputs[i].style.color = "#666";
	        inputs[i].onfocus = function() {
	           if (this.value == "search...") {
	              this.value = "";
	           }
	           this.style.color = "#d9d9d9";
	        }
	        inputs[i].onblur = function() {
	           this.style.color = "#666";
	        }            
	     }
	  }
});
