/*
This function works in exactly the same way as the “prototype.js” $ function by accepting a comma-separated list of strings, but it also emulates CSS specificity in its matching.

It will first attempt to find an element with a matching id; 
If none are found, it will next look for matching class names (so replacing any of the existing getElementsByClassName functions currently in use); 
If none of those match, it will try for matching tags using the built-in document.getElementsByTagName method; 
Next, it gives up on CSS specificity and tries to match any other attribute (e.g. rel, type, title, etc.); 
Finally, if none of those attributes were matched it checks the actual values of element attributes. 
In summary, it is a complete replacement for:

getElementById 
getElementsByClassName 
getElementsByTagName 
Plus some extra bits thrown in. The function will only keep looking until it finds a match, so the more inefficient loops (checking every attribute value on the page!) are only run if none of the other checks matched.
*/

function $() {
	var elements = new Array();
	for (var i=0,len=arguments.length;i<len;i++) {
		var element = arguments[i];
		if (typeof element == 'string') {
			var matched = document.getElementById(element);
			if (matched) {
				elements.push(matched);
			} else {
				var allels = (document.all) ? document.all : document.getElementsByTagName('*');
				var regexp = new RegExp('(^| )'+element+'( |$)');
				for (var i=0,len=allels.length;i<len;i++) if (regexp.test(allels[i].className)) elements.push(allels[i]);
			}
			if (!elements.length) elements = document.getElementsByTagName(element);
			if (!elements.length) {
				elements = new Array();
				var allels = (document.all) ? document.all : document.getElementsByTagName('*');
				for (var i=0,len=allels.length;i<len;i++) if (allels[i].getAttribute(element)) elements.push(allels[i]);
			}
			if (!elements.length) {
				var allels = (document.all) ? document.all : document.getElementsByTagName('*');
				for (var i=0,len=allels.length;i<len;i++) if (allels[i].attributes) for (var j=0,lenn=allels[i].attributes.length;j<lenn;j++) if (allels[i].attributes[j].specified) if (allels[i].attributes[j].nodeValue == element) elements.push(allels[i]);
			}
		} else {
			elements.push(element);
		}
	}
	if (elements.length == 1) {
		return elements[0];
	} else {
		return elements;
	}
}


var ferret = {};

ferret.clearInput = function(x) {
	if($(x).value == 'Enter your email address') {
		$(x).value = '';
	}
	/*$('cityDropdown').style.display = 'block';
	$('addressAdd').style.display = 'block';*/
}