window.addEvent('domready', function()
{
	$('logo').store('original', $('logo').src);
	
	['home', 'products', 'quotes', 'contact'].each(function (Name)
	{
		new Asset.image('img/logo.' + Name + '.gif');
		$('nav_' + Name).addEvent('mouseover', function () { $('logo').src = 'img/logo.' + Name + '.gif'; });
		$('nav_' + Name).addEvent('mouseout', function () { $('logo').src = $('logo').retrieve('original'); });
	});
	
	$$('input', 'select', 'textarea').each(function (El)
	{
		El.addEvent('mouseover', function () { this.addClass('hover'); });
		El.addEvent('mouseout', function () { this.removeClass('hover'); });
		El.addEvent('focus', function () { if (this.type != 'reset' && this.type != 'submit') { this.addClass('focus'); }});
		El.addEvent('blur', function () { this.removeClass('focus'); });
	});
	
	if (Form = $('QuoteForm'))
	{
		Form.addEvent('submit', function ()
		{
			if (this.Company.value.length < 3)
			{
				alert('Please enter a valid company name.');
				this.Company.focus();
				return false;
			}
			if (this.Phone.value.length < 8)
			{
				alert('Please enter a valid phone number.');
				this.Phone.focus();
				return false;
			}
			if (this.email.value.length < 10 || this.email.value.indexOf('@') == -1 || this.email.value.indexOf('.') == -1)
			{
				alert('Please enter a valid email address. A copy of this order is sent to the address you supply. Enter "no\@email.com" if you have none.');
				this.email.focus();
				return false;
			}
			if (this.Job_Description.selectedIndex == 0)
			{
				alert('Please select a job description.');
				this.Job_Description.focus();
				return false;
			}
			if (this.Mainline.value.length < 1)
			{
				alert('Please enter a "Mainline On Order".');
				this.Mainline.focus();
				return false;
			}
			if (this.Process.selectedIndex == 0)
			{
				alert('Please select an ink process.');
				this.Process.focus();
				return false;
			}
			return true;
		});
	}
	
	if (Form = $('ContactForm'))
	{
		Form.addEvent('submit', function ()
		{
			if (this.Your_Name.value.length < 3)
			{
				alert('Please enter a valid name.');
				this.Your_Name.focus();
				return false;
			}
			if (this.Company.value.length < 3)
			{
				alert('Please enter a valid company name.');
				this.Company.focus();
				return false;
			}
			if (this.Address1.value.length < 3)
			{
				alert('Please enter a valid street address.');
				this.Address1.focus();
				return false;
			}
			if (this.City.value.length < 3)
			{
				alert('Please enter a valid city.');
				this.City.focus();
				return false;
			}
			if (this.State.value.length < 2)
			{
				alert('Please select a state.');
				this.State.focus();
				return false;
			}
			if (this.Zip_Code.value.length < 5)
			{
				alert('Please enter a valid zip code.');
				this.Zip_Code.focus();
				return false;
			}
			if (this.Phone.value.length < 8)
			{
				alert('Please enter a valid phone number.');
				this.Phone.focus();
				return false;
			}
			if (this.email.value.length < 10 || theForm.email.value.indexOf('@') == -1 || theForm.email.value.indexOf('.') == -1)
			{
				alert('Please enter a valid email address.');
				this.email.focus();
				return false;
			}
			return true;
		});
	}
});