function validateUrl(str)
{
	var v = new RegExp();
	v.compile("^(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&amp;%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&amp;%\$#\=~_\-]+))*$");

	if (!v.test(str)) {
		return false;
	}
	return true;
}
/**/
function isEmail(email)
{
  var email = email.toLowerCase();
  return (email.search(/^[a-zA-Z]+([_\.-]?[a-zA-Z0-9]+)*@[a-zA-Z0-9]+([\.-]?[a-zA-Z0-9]+)*(\.[a-zA-Z]{2,4})+$/) != -1);
}
/**/
function setFocusById(id)
{
	Event.observe(window, 'load', function() {
		$(id).focus();
	});
}
/**/
function addLoadEvent(newOnLoad, loadPosition) {
	// define a "global" variable - since we're not using a proper class
	if(! window.__addLoadEventGlobal){
		window.__addLoadEventGlobal = {
			'initComplete' : false,
			'loadEventCallstack' : {
				'prepend' : [],
				'append' : [],
				'early' : []
			}
		};
	}
	var __global = window.__addLoadEventGlobal;

	// register the new event handler as either an append, or a prepend
	if (loadPosition == 'early'){
		__global.loadEventCallstack.early.push(newOnLoad);
	} else if (loadPosition){
		__global.loadEventCallstack.prepend.push(newOnLoad);
	} else { // 'append'
		__global.loadEventCallstack.append.push(newOnLoad);
	}
	// wait for the document to load, and attach the new event handler to the onLoad event queue
	if (!__global.initComplete){ // run this part only once
		if(document.addEventListener) { // Moz, Opera
			document.addEventListener(
				'DOMContentLoaded', 
				function() {
					attachLoadEvents();
				}, 
				false
			);
		} else if(document.attachEvent) { // IE
			document.attachEvent(
				'onreadystatechange', 
				function() {
					if(document.readyState == 'complete') {
						attachLoadEvents();
					}
				}
			);
		}
		__global.initComplete = true; 
	}
}
/**/
function attachLoadEvents(){	
	var loadEventCallstack = window.__addLoadEventGlobal.loadEventCallstack;

	// first, execute any "early" handlers
	for(var i=0, l=loadEventCallstack['early'].length; i<l; ++i){ 
		loadEventCallstack['early'][i]();
	}	
	// now, add the rest either at the front, or the end of the onLoad callstack
	var callstack = loadEventCallstack['prepend'];
	var oldOnLoad = window.onload;
	if (typeof oldOnLoad == 'function'){
		callstack.push(oldOnLoad);
	}

	for(var i=0, l=loadEventCallstack['append'].length; i<l; ++i){ 
		callstack.push(loadEventCallstack['append'][i]); 
	} // i have no idea why i can't just push the whole damned array, but when i do that, it's no longer recognized as a function and throws an error.
	
	window.onload = function(){
		for (var i=0, l=callstack.length; i<l; ++i){
			callstack[i]();
		}
	}
}

