	var Classes = {
		DropDown: {
			initiate: function() {
				if (Detect.IE6()) {
					if (this.getElementsByTagName('ul').length>0) 
					{
						links = this.getElementsByTagName('ul')[0].getElementsByTagName('a');
						maxLength = 50;
						for(c=0;c<links.length;c++) {
							testLength = links[c].innerHTML.replace("&amp;","&").replace("&#39;","'").length * 7;
							if (testLength>maxLength) maxLength=testLength;
						}
						for(c=0;c<links.length;c++) links[c].style.width = maxLength + "px";
						this.getElementsByTagName('ul')[0].style.width = maxLength + "px";
						linkHeight = 32;
						this.innerHTML = "<iframe frameborder='0' style='width: "+((maxLength)+18)+"px; height: "+(linkHeight*links.length+1)+"px;'></iframe>" + this.innerHTML;
					}
				}
			},
			onmouseover: function() {
				this.addClassName('hover');
			},
			onmouseout: function() {
				this.removeClassName('hover');
			}
		},
		CrawledPopUp: {
			initiate: function() {
				this.href = "javascript:;";
			}
		},
		Input: {
			valid: false,
			fieldType: null,
			fieldName: null,
			errorString: null,
			initiate: function() {
				if (this.fieldType == null) this.fieldType = 'default';
				if (this.fieldName == null) this.fieldName = this.name;
			},
			makeError: function (explaination) {
				this.addClassName('invalid'); //invalid color class
				this.valid = false;
				this.errorString += explaination;
			},
			makeValid: function (){
				this.valid = true;
				this.removeClassName('invalid');
			},
			onfocus: function() {
				this.addClassName('focus');
			},
			onblur: function() {
				this.removeClassName('focus');
				this.validate();
			},
			onchange: function() {
				//this.validate();
			}
		},
		SelectInput: {
			selectedValue: null,
			extend: function() {
				Object.extend(this, Classes.Input);
				if (this.selectedValue) this.selectOption(this.selectedValue);
			},
			validate: function() {
				this.errorString = "";
				switch(this.fieldType) {
				case 'ignore':
					this.makeValid();
				break;
				case 'default':
					if (this.options[this.selectedIndex].value != "") this.makeValid();
					else {
						this.makeError("Please select a " + this.fieldName + ". ");
					}
				break;
				}
				return this.valid;
			},
			selectOption: function(value) {
				for(var c=0;c<this.options.length;c++) {
					if (this.options[c].value == value) this.selectedIndex = c;
				}
			}
		},
		TextArea: {
			extend: function() {
				Object.extend(this, Classes.Input);
			},
			validate: function() {
				this.errorString = "";
				switch(this.fieldType) {
				case 'default':
					if (this.value != "") this.makeValid();
					else {
						this.makeError("Please enter " + this.fieldName + ". ");
					}
				break;
				}
				return this.valid;
			}
		},
		TextInput: {
			extend: function() {
				Object.extend(this, Classes.Input);
			},
			validate: function() {
				this.errorString = "";
				switch(this.fieldType) {
				case 'default':
					if (this.value != '') this.makeValid();
					else {
						this.makeError("Please enter your " + this.fieldName + ". ");
					}
				break;
				case 'email':
					if (this.value.match(/^[\w\W]+@[\w\W]+\.[\w\W]+$/)) this.makeValid(); 
					else {
						this.makeError("Please check the formatting of your " + this.fieldName + ". ");
					}
				break;
				case 'date':
					if (this.value.match(/^\d{1,2}\D\d{1,2}\D\d{2,4}$/)) this.makeValid(); 
					else {
						this.makeError("Please check the formatting of your " + this.fieldName + ". It should follow the format: MM/DD/YYYY");
					}
				break;
				case 'zipcode':
					if (this.value.match(/^\d{5}$/)) this.makeValid(); //US, Germany (Germany may be DE-)
					else if(this.value.match(/^\d{5}\-\d{4}$/)) this.makeValid(); //US 10 digit and Brazil
					else if(this.value.match(/^\w{6}$/)) this.makeValid(); //Canada and England
					else if(this.value.match(/^\w{3}\s\w{3}$/)) this.makeValid(); //Canada and England again
					else if(this.value.match(/^\d{4}$/)) this.makeValid(); //Australia and new Zealand
					else if(this.value.match(/^\w{2}\-\d{3}\s\d{2}$/)) this.makeValid(); //Europe part 1
					else if(this.value.match(/^\w{1}\-\d{3}\s\d{2}$/)) this.makeValid(); //Europe part 2
					else if(this.value.match(/^\w{2}\-\d{5}$/)) this.makeValid(); //Europe part 3
					else if(this.value.match(/^\w{2}\-\d{4}$/)) this.makeValid(); //Europe part 4
					else if(this.value.match(/^\w{1}\-\d{4}$/)) this.makeValid(); //Europe part 5
					else if(this.value.match(/^\w{2}\-\d{5}$/)) this.makeValid(); //Europe part 6
					else if(this.value.match(/^\w{2}\-\d{6}$/)) this.makeValid(); //Europe part 7 (Russia pt1)
					else if(this.value.match(/^\w{2}\-\d{3}\s\d{3}$/)) this.makeValid(); //Europe part 4 (Russia pt2)
					else if(this.value.match(/^\w{2}\-\d{4}\s\w{2}$/)) this.makeValid(); //Netherlands
					else if(this.value.match(/^\d{3}\-\d{4}$/)) this.makeValid(); //Japan
					else {
						this.makeError("Please check the formatting of your " + this.fieldName + ". ");
					}
				break;
				case 'phone':
					if (this.value.length > 7 && !isNaN(this.value)) this.makeValid();
					else {
						this.value=this.value.replace(/\s|\(|\)|\-|\./gi,"");
						if (this.value.length > 7 && !isNaN(this.value)) this.makeValid();
						else {
							this.makeError("Please check the formatting of your " + this.fieldName + ". It should include area code, with no hyphens or dashes.");
						}
					}
				break;
				case 'ssn':
					if (this.value.match(/^\d{3}\D\d{2}\D\d{4}$/)) this.makeValid(); 
					else {
						this.makeError("Please check the formatting of your " + this.fieldName + ". It should follow the format: ###-##-####");
					}
				break;
				}
				return this.valid;
			}
		},
		Form: {
			inputValues: null,
			errorDiv: null,
			errorString: "",
			initiate: function() {
				this.inputValues = this.getElementsByClassName('TextInput');
				this.inputValues = this.inputValues.concat(this.getElementsByClassName('SelectInput'));
				this.inputValues = this.inputValues.concat(this.getElementsByClassName('TextArea'));
				this.errorDiv = this.name + "-error";
			},
			onsubmit: function() {
				return this.validate();
			},
			validate: function(submitAtEnd) {
				var valid = true;
				var errorString = "";
				for(var c=0;c<this.inputValues.length;c++) {
					if (!this.inputValues[c].validate()) {
						valid = false;
						errorString = errorString + this.inputValues[c].errorString + "<br />";
					}
				}
				if (submitAtEnd) {
					if (valid) this.submit();
					else {
						$(this.errorDiv).removeClassName('valid');
						$(this.errorDiv).innerHTML = errorString;
					}
				}
				else {
					if (valid) return true;
					else {
						$(this.errorDiv).removeClassName('valid');
						$(this.errorDiv).innerHTML = errorString;
						return false;
					}
				}
			}	
		}
	}
