// JavaScript Document
$(document).ready(function(){
						   
//	$('#header-nav').append('<li><a href="#" class="nav-bookmark"><span>Bookmark Us</span></a></li>');
//	$('.nav-bookmark').jFav();

//Form stuff
	var options = {
		beforeSubmit:	checkForm,
		success:	showResponse
	};
	$('#contactus').ajaxForm(options);
	function checkForm() {
		var email = $('#contact_email').fieldValue()[0];
		var phone = $('#contact_phone').fieldValue()[0];
		var stripped = phone.replace(/[\(\)\.\-\ ]/g, '');
		if (phone=="") {
			$.facebox('<h2>Oops!</h2> <p>Please include your phone number before sending the form.</p>');
			return false;
		} else if (isNaN(parseInt(stripped))) {
			$.facebox('<h2>Oops!</h2> <p>Please correct your phone number and resend.</p>');
			return false;
		} else if (!(stripped.length == 10)) {
			$.facebox('<h2>Oops!</h2> <p>Please make sure you included your complete phone number with area code and resend.</p>');
			return false;
		} else {
			return true;
		}
	}
	
	var commentOptions = {
		beforeSubmit:	checkCommentForm,
		success:	showResponse
	};
	$('#comments').ajaxForm(commentOptions);
	function checkCommentForm() {
		var email = $('#comments_email').fieldValue()[0];
		var phone = $('#comments_phone').fieldValue()[0];
		var stripped = phone.replace(/[\(\)\.\-\ ]/g, '');
		if (phone=="") {
			$.facebox('<h2>Oops!</h2> <p>Please include your phone number before sending the form.</p>');
			return false;
		} else if (isNaN(parseInt(stripped))) {
			$.facebox('<h2>Oops!</h2> <p>Please correct your phone number and resend.</p>');
			return false;
		} else if (!(stripped.length == 10)) {
			$.facebox('<h2>Oops!</h2> <p>Please make sure you included your complete phone number with area code and resend.</p>');
			return false;
		} else {
			return true;
		}
	}
	function showResponse(responseText) {
		$.facebox(responseText);
	}
	
//Misc fancy stuff	
	$('a[rel*=facebox]').facebox();
	
	$('#featured-testimonial').click(function(){
		window.location.href = "testimonials.php";
	});
	$('#sidebar-about').click(function(){
		window.location.href = "aboutus.php";
	});
	$('#sidebar-about, #featured-testimonial').hover(
		function(){
			$(this).css("border", "1px solid #c04800");
		}, 
		function(){
			$(this).css("border", "1px solid #DADADA");
		}
	);
	

});
