$(document).ready(function(){
	$(document).pngFix();
	
	$('ul#home-links li')
		.click(
			function(){
				href = $(this).attr('id');
				
				window.location = (href+'.php');
			}
		);
	
	if ($('body').attr('id') != 'quotepage'){
		$('#contact-form')
			.submit(
				function(){
					name = $('input[name=name]').val();
					email = $('input[name=email]').val();
					phone = $('input[name=phone]').val();
					message = $('textarea[name=message]').val();
				
					$.ajax({
						url: ('ajax/contact.php'),
						data: {name:name, email:email, phone:phone, message:message},
						success: function(data){
							if (data != '0'){
								if ($('body').attr('id') == 'contactpage'){
									$('#contact-alert')
										.fadeIn()
										.animate({
											opacity: 1
											}, 15000, function(){
														$('#contact-alert').fadeOut();
													});
								} else {
									$('#footer-success')
										.fadeIn()
										.animate({
											opacity: 1
											}, 15000, function(){
														$('#footer-success').fadeOut();
													});
								}
							} else {
								$('#contact-alert')
									.html('We apolagize for the inconvenience, but the email form is currently not working. You may contact us at 281-590-7300. Thank you.')
									.fadeIn();
							}
						}
					});
					
					return false;
				}
			);
	}; // contact page form
	
	if ($('body').attr('id') == 'quotepage'){
		$('#quote-form')
			.submit(
				function(){
					first_name = $('input[name=first_name]').val();
					last_name = $('input[name=last_name]').val();
					email = $('input[name=email]').val();
					phone = $('input[name=phone]').val();
					city = $('input[name=city]').val();
					state = $('input[name=state]').val();
					zip = $('input[name=zip]').val();
					
					alerts = '';
					
					if (first_name == ''){
						alerts += 'Please fill in your first name.<br />';
					}
					if (last_name == ''){
						alerts += 'Please fill in your last name.<br />';
					}
					if (email == ''){
						alerts += 'Please fill in your email.<br />';
					}
					if (phone == ''){
						alerts += 'Please fill in your phone number.<br />';
					}
					if (city == ''){
						alerts += 'Please fill in your city.<br />';
					}
					if (state == ''){
						alerts += 'Please fill in your state.<br />';
					}
					if (zip == ''){
						alerts += 'Please fill in your zip.';
					}
					
					if (alerts !== ''){
						$('#quote-alert').html(alerts).fadeIn();
						return false;
					}
				}
			);
	}
	
	if ($('body').attr('class') == 'gallery'){
		$('ul.gallery-thumbs a').fancybox();
	}
});
