$(function () {
$("#feature-control").jFlow({
slides: "#feature-block",
controller: ".control",
auto: true,
width: "960px",
height: "250px",
duration: 200,
prev: ".jFlowPrev",
next: ".jFlowNext"
});
});

$(function () {
$('.fade').hover(
function() {$(this).fadeTo("fast", 0.8);},
function() {$(this).fadeTo("fast", 1);
});
});

$(function () {
$('input[title], textarea[title]').each(function() {if($(this).val() === '') {$(this).val($(this).attr('title'));}
$(this).focus(function() {if($(this).val() == $(this).attr('title')) {$(this).val('').addClass('focused');	}
});
$(this).blur(function() {if($(this).val() === '') {$(this).val($(this).attr('title')).removeClass('focused');}
});
});
});

function showVideo(id) {
	document.write("<object width=\"425\" height=\"325\"><param name=\"movie\" value=\"http://www.youtube.com/v/"+id+">&amp;hl=en&amp;fs=1\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/"+id+"&amp;hl=en&amp;fs=1\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"425\" height=\"325\"></embed></object>");
}

$(document).ready(function() {
$('form#footercontact').submit(function() {
$('form#footercontact .error').remove();
var hasError = false;
$('.requiredField').each(function() {
if(jQuery.trim($(this).val()) == '') {
var labelText = $(this).prev('label').text();
$(this).parent().append('<span class="error">Something wrong with your information</span>');
hasError = true;
} else if($(this).hasClass('email')) {
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if(!emailReg.test(jQuery.trim($(this).val()))) {
var labelText = $(this).prev('label').text();
$(this).parent().append('<span class="error">Your email is incorrect format</span>');
hasError = true;
}
}
});
if(!hasError) {
$('form#footercontact button').fadeOut("fast", function() {
$(this).parent().append('Sending...');
});
var formInput = $(this).serialize();
$.post($(this).attr('action'),formInput, function(data){
$('form#footercontact').slideUp("fast", function() {				   
$(this).before('<p>Your email was sent. We will be in touch soon.</p>');
});
});
}
return false;
});
});