<!--
function checkform(of) {
/* 06/20/2007 -	added "document.appendChild" check for Opera 6
/* 06/14/2007 -	removed code related to IMG elements,
		added "password" input type
Taken from
http://www.onlinetools.org/articles/unobtrusivejavascript/chapter5.html */

	// test if DOM is available and there is an element called required
	if(!document.getElementById || !document.createTextNode || !document.appendChild){return;}
	if(!$("required")){return;}

	// define error messages
	var errorID="errormsg";
	var errorClass="error"
	var errorMsg="There is a problem with your input. Please fill out or correct the highlighted field(s).";
	// other definitions
	var captchaLength = 5;

	// cleanup: if there is an old errormessage field, delete it
	var em=$(errorID);
	if(em){em.parentNode.removeChild(em);}

	// split the required fields and loop throught them
	var reqfields=$F("required").split(",");
	for (var i=0; i<reqfields.length; i++) {
		// get a required field
		var f=$(reqfields[i]);
		if(!f){continue;}
		// cleanup: remove old classes from the required fields
		f.parentNode.className="";
		// completely strip whitespace and place field value into v
		var v=f.value.replace(/ /g,"");
		// test if the required field has an error, according to its type
		switch(f.type.toLowerCase()) {
		case "text":
			// email is a special field and needs checking
			// AN UGLY TECHNIQUE USED HERE: we only check email
			// field when it is NOT empty. This is ugly because
			// I did not implement a way to tell this function
			// that email is a required field in case we want
			// it to be required.
			switch(f.id.toLowerCase()) {
			case "email":
				if(v != "" && !cf_isEmailAddr(v)) {cf_adderr(f);}
				break;
			case "security_code":
				if(v.length != captchaLength) {cf_adderr(f);}
				break;
			default:
				if(v == "") {cf_adderr(f);}
			}
			break;
		case "textarea":
		case "password":
			if(v==""){cf_adderr(f);}
			break;
		/* case "checkbox":
			if(!f.checked){cf_adderr(f);}
			break;
		case "select-one":
			if(!f.selectedIndex && f.selectedIndex==0){cf_adderr(f);}
			break; */
		}
	}
	return !$(errorID);

	/* tool methods */
	function cf_adderr(o) {
		// colourise the error fields
		o.parentNode.className=errorClass;
		// check if there is no error message
		if(!$(errorID)) {
			// create errormessage and insert before submit button
			var em=document.createElement("div");
			em.id=errorID;
			var newp=document.createElement("p");
			newp.appendChild(document.createTextNode(errorMsg))
			em.appendChild(newp);
			// find the submit button
			for(var i=0;i<of.getElementsByTagName("input").length;i++) {
				if(/submit/i.test(of.getElementsByTagName("input")[i].type)) {
					var sb=of.getElementsByTagName("input")[i];
					break;
				}
			}
			if(sb) {
				sb.parentNode.insertBefore(em,sb);
			}
		}
	}
	function cf_isEmailAddr(str) {
		return str.match(/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/);
	}
}
function toggle_with_icon(el, icon) {
	if (Element.visible(el)) {
		Element.hide(el);
		icon.update("+");
	} else {
		Element.show(el);
		icon.update("-");
		//window.location="#" + "cont";
	}
	//return false; // for "onclick" hook
}

function loadAllImages() {
// This function cycles through all the images on a page
// and reloads the ones that did not get loaded fully.
//
	if (!document.getElementsByTagName)
		return;

	var loaded = false;

	var els = document.getElementsByTagName("img");
	for (var i = 0; i < els.length; i++) {
		var el = els[i];
		loaded = assertImageLoaded(el);
		if (!loaded) refreshImage(el);
		//if (!loaded) alert(anchor.src);
	}

	/* tool methods */
	function assertImageLoaded(img) {
	//
	// http://www.fleegix.org/articles/2007/09/30/test-for-broken-images-works-in-safari
	//
	// This is a diagnostic function for the annoying Safari bug where certain
	// images on a page that contains multiple images do not load
	//
		var complete = img.complete;
		var ret = null; // Return value
		// Workaround for Safari - it only supports the
		// complete attrib on script-created images
		if (typeof complete == "undefined") {
			var test = new Image();
			// If the original image was successfully loaded,
			// src for new one should be pulled from cache
			test.src = img.src;
			complete = test.complete;
		}
		// Check the complete attrib. Use strict equality
		// check - don't want undefined, null, etc.
		//
		// False - Img failed to load in IE/Safari, or is
		// still trying to load in FF
		if (complete === false) {
			ret = false;
		}
		// True, but image has no size - image failed to
		// load in FF
		else if (complete === true && img.naturalWidth == 0) {
			ret = false;
		} else {
		// Otherwise all we can do is assume image loaded
			ret = true;
		}
		return ret;
	}
	function refreshImage(img) {
	// This function reloads an image ("getTime()" affixes a rendom number to the source URI
	// to make sure the image gets reloaded from the server and not from the local cache).
	// This tip was taken from:
	// http://www.neowin.net/forum/lofiversion/index.php/t349112.html
	//
	// This combats the annoying Safari/Tiger bug that can be exmplified by visiting
	// a page with a large number of images, e.g. http://www.alfa60.com/lina/
	//
		img.src = img.src + "?" + (new Date()).getTime();
	}
}
function externalLinks() {
// Sets all href anchors with rel="external" to open in a new window
// http://www.sitepoint.com/article/standards-compliant-world/
	if (!document.getElementsByTagName)
		return;

	var els = document.getElementsByTagName("a");
	for (var i = 0; i < els.length; i++) {
		var el = els[i];
		if (el.getAttribute("href") && el.getAttribute("rel") === "external")
			el.target = "_blank";
	}
}
function obfuscate(input, key, forward) {
	var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	var alphabet_len = alphabet.length;
	var input_len = input.length;
	var key_len = key.length;
	var i;
	var output = "";
	var key_index = 0;

	for (i = 0; i < input_len; i++) {
		var input_char = input.charAt(i);
		var input_char_value = alphabet.indexOf(input_char);
		if (input_char_value < 0) {
			output += input_char;
			continue;
		}
		var lowercase = (input_char_value >= alphabet_len) ? true : false;
		if (forward)
			input_char_value += alphabet.indexOf(key.charAt(key_index));
		else
			input_char_value -= alphabet.indexOf(key.charAt(key_index));
		input_char_value += alphabet_len;
		if (lowercase)
			input_char_value = input_char_value % alphabet_len + alphabet_len;
		else
			input_char_value %= alphabet_len;
		output += alphabet.charAt(input_char_value);
		key_index = (key_index + 1) % key_len;
	}
	return output;
}
function deobfuscate(key) {
// This function cycles through all "a" links on the page
// and deobfuscates the obfuscated email links.
//
	if (!document.getElementsByTagName)
		return;

	var mailto = obfuscate("mailto:", key, true);
	var content = "";
	var mailto_length = mailto.length;

	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
                var re = new RegExp('^' + mailto, 'i');
                if (anchor.getAttribute("href") && anchor.href.match(re)) {
			content = obfuscate(anchor.href, key, false);
			anchor.href = content;
			anchor.innerHTML = content.substring(mailto_length);
		}
	}
}
//-->