
function goTo(url) {
	document.location = url;
}

function initMenu(subOn) {
	$("#menu_"+ subOn).show();
	
	$("#menu li a").bind("mouseover", function(e) {
		var target = $(this).attr("rel");
		
		if (document.getElementById("menu_"+ target) != null) {
			var subMenu = $("#menu_"+ target);
			var parent = $(this).parent();
			var menus = $(".subMenu:visible").length;
			
			if (!parent.hasClass("active")) {
				$("#menu li").removeClass("hover");
				parent.addClass("hover");
			}
			
			if (subMenu.is(":hidden") || menus > 1) {
				$(".subMenu").hide();
				subMenu.fadeIn();
			}
		}
	});
}

function techTree(start) {
	$("#techTree .techTree").hide();
	$("#techTree #tech"+ start).show();

	$("#techTree h3 a").click(function() {
		var target = $(this).attr("rel");
		
		$("#techTree .techTree").slideUp("slow");
		$("#"+ target).slideDown("slow");
		
		return false;
	});
}

function fixColumns() {
	var left = $("#left").outerHeight();
	var right = $("#right").outerHeight();

	if (right > left) {
		var main = $("#mainBot").outerHeight();
		var newHeight = main + ((right - left) + 25);	
		$("#mainBot").height(newHeight);
	}
}

function updateExchange(field, target) {
	var amount = $(field).val();
	var newAmount = Math.round(amount / 2);
	
	if (isNaN(amount)) {
		alert('Please enter a numerical value!');
		$("#"+ target).val('');
		$(field).val('');
	} else {
		$("#"+ target).val(newAmount);
	}
}

function toggleCheckboxes(current, form, field) {
	$("#"+ form +"AddForm :checkbox[name='data["+ form +"]["+ field +"][]']").attr("checked", current.checked);
}

function quickReply() {
	$("#quickReply").slideToggle();
	return false;
}
