function formatText(index, panel) {
	return index + "";
}

$(document).ready( function() {
	
	contactForm();
// contact form - styling
	$("#contactWrapper").hide();
	$("#header #contactLink").css({cursor: "pointer"}).hover(function() {
		$(this).css({color: "#FFF"});
	}, function () {
		$(this).css({color: "#DDD"});
	});
	$("#header #contactLink").toggle(function() {
			$("#contactWrapper").slideDown("slow");
		}, function() {
			$("#contactWrapper").slideUp("slow");
		});

// anythingSlider
	if ($('#home').length>0){
		$('#slideShow').show().anythingSlider({
			easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
			autoPlay: true,                 // This turns off the entire FUNCTIONALY
			startStopped: false,            // If autoPlay is on, this can force it to start stopped
			delay: 6500,                    // How long between slide transitions in AutoPlay mode
			animationTime: 500,             // How long the slide transition takes
			hashTags: true,                 // Should links change the hashtag in the URL?
			buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
			pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
			startText: "Start",             // Start text
			stopText: "Stop",               // Stop text
			navigationFormatter: null       // Details at the top of the file on this use (advanced use)
		});
	}


	$('#sidebar h3').filter( function() {
    return $.trim($(this).html()) == '';
	}).remove();


// features list
	$('#features h3').css({cursor: 'pointer'}).hover(function() {
		$(this).addClass('hover');
	}, function() {
		$(this).removeClass('hover');
	})
	
	$('#features p').hide();
	$('#features h3').toggle(function() {
		$(this).addClass('open');
		$(this).next('p').slideDown();
	}, function() {
		$(this).removeClass('open');
		$(this).next('p').slideUp();
	})
	
}); // end DOC ready

Cufon.set("selector", jQuery);
Cufon.replace("h2#phoneNumber, #slideShow ul li h2, h3, #content h1", {separate: "none", hover: true });

function contactForm(){
	$('.error').hide();
	$(".button").click(function() {
		$('.error').hide();
		var name = $("input#name").val();
		if (name == "") {
			$("label#name_error").fadeIn();
			$("input#name").focus( function() {
				if ( $("label#name_error").is(":visible") ) {
					$("label#name_error").fadeOut();
				}
			});
			return false;
		}
		var email = $("input#email").val();
		var emailFilter = /^[^@]+@[^@]+.[a-z]{2,}$/i;
		if ( (email == "") || (!emailFilter.test(email)) ) {
			$("label#email_error").fadeIn();
			$("input#email").focus( function() {
				if ( $("label#email_error").is(":visible") ) {
					$("label#email_error").fadeOut();
				}
			});
			return false;
		}
		var phone = $("input#phone").val();
		if (phone == "") {
			$("label#phone_error").fadeIn();
			$("input#phone").focus( function() {
				if ( $("label#phone_error").is(":visible") ) {
					$("label#phone_error").fadeOut();
				}
			});
			return false;
		}
		var comments = $("textarea#comments").val();
				
		    var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&comments=' + comments;
  			//alert (dataString);return false;
  			$.ajax({
				type: "POST",
				url: "FormToEmail.php",
				data: dataString,
				success: function() {
					$('form#contactForm').fadeOut();
					$('#formOuter').html("<div id='message'></div>");
					$('#message')
					.append("<p>Your inquiry has been submitted.</p><p>I'll be in touch soon.</p>")
					.hide()
					.fadeIn(1500, function() {
						$('#message')
					});
    			}
			});
			return false;
	});
}
