function initBehaviours() {
	
	putUserAgentInBodyClass();
	
	var globalrules = {
					"img.hasrollover" :		function (e) {
													e.onmouseover = function() {
														// Cache src of current image
														this.idlesrc = this.src;
														// Create new src by inserting "_active" before the file extension
														splitsrc = this.src.split(".");
															ult = splitsrc.pop();
															penult = splitsrc.pop();
														newsrc = splitsrc.join(".")+"."+penult+"_active."+ult;
														this.src = newsrc.replace(".http","http"); // For firefox's join function
													}
													e.onmouseout = function() {
														// Restore old src
														this.src = this.idlesrc;
													}
												},
					"a.submitlink" : 		function(e) {
												e.onclick = function() {
													submit_upward_form_node(this);
													replace_link_text_with_large_spinner(this);
													return false;
												}
											},
	"div.sidebarmodule a.submitlink" : 		function(e) {
												e.onclick = function() {
													submit_upward_form_node(this);
													return false;
												}
											}
	}
	
	// Apply global rules
	Behaviour.register(globalrules);
	Behaviour.apply();
}

function putUserAgentInBodyClass() {
	appver = navigator.appVersion;
	useragent = navigator.userAgent;
	vendor = navigator.vendor;
	tagnode = document.getElementsByTagName("body")[0];
	// Detect browser and add it as a class name to the BODY tag.
	// This lets us CSS hack with phrases like body.firefox div.needs_hacking { position: relative; }
	klass = "unknown";
	// Detect IE
	if (useragent.match(/\bMSIE\b/)) {
		klass = "ie";
	}
	// Detect Firefox/moz/camino/gecko
	else if (useragent.match(/\bFirefox\b/) || vendor.match(/\bCamino\b/) || useragent.match(/\bNetscape\b/)) {
		klass = "moz";
	}
	// Detect safari/webkit
	else if (vendor.match(/\bApple\b/) || vendor.match(/\bKDE\b/) || useragent.match(/\bOmniWeb\b/)) {
		klass = "webkit";
	}
	// Detect opera
	else if (window.opera) {
		klass = "opera";
	}
	tagnode.className = klass;
}

function submit_upward_form_node(fromlink) {
	// Find the parent form
	foundForm = false;
	curNode = fromlink;
	while(!foundForm) {
		if(curNode.parentNode.nodeName == "FORM") {
			foundForm = true;
			// Now if the form contains an onsubmit (meaning it probably has an associated AJAX action, emulate the cascade.)
			fNode = curNode.parentNode;
			if(fNode.onsubmit) {
				// Node has a defined onsubmit action. If it returns true when run, also do the traditional submit.
				if(fNode.onsubmit()) fNode.submit();
			} else {
				// Just submit the thing.
				fNode.submit();
			}
			break;
		} else {
			curNode = curNode.parentNode;
		}
	}
}

function replace_link_text_with_large_spinner(link) {
	link.innerHTML = '<img src="/images/progressbar_blue.gif" alt="Please wait" />';
}