$(document).ready(function() {
	$('.navItem').hover(function() {
		$(this).children('.navSub').slideDown();
	}, function() {
		$(this).children('.navSub').slideUp();
	});
});









var $on = 0;
function _switch()
{
	$on += 1;
	if ($on > 2) { $on = 0; }
	$('#slidePicture').css('background-image', 'url(/static/img/slides/'+($on+1)+'.jpg)');
	$('#slidePicture').fadeIn(1000, function () {
		$('#slideShow').css('background-image', 'url(/static/img/slides/'+($on+1)+'.jpg)');
		$(this).hide();
		setTimeout("_switch()", 5000);
	});
}
$(document).ready(function() {
	if ((/msie 6.0/.test(navigator.userAgent.toLowerCase())) && (!/msie 7.0/.test(navigator.userAgent.toLowerCase())))
	{
		$('#header, #content, .opt').pngFix({blankgif: '/static/img/clear.gif'});
	}

	$('#optIn').children('input[name=fn]').focus(function () {
		if ($(this).val() == 'First Name')
		{
			$(this).val('').css('color', '#000000');
		}
	}).blur(function () {
		if ($(this).val() == '')
		{
			$(this).css('color', '#c0c0c0').val('First Name');
		}
	});
	$('#optIn').children('input[name=ln]').focus(function () {
		if ($(this).val() == 'Last Name')
		{
			$(this).val('').css('color', '#000000');
		}
	}).blur(function () {
		if ($(this).val() == '')
		{
			$(this).css('color', '#c0c0c0').val('Last Name');
		}
	});
	$('#optIn').children('input[name=ea]').focus(function () {
		if ($(this).val() == 'E-mail Address')
		{
			$(this).val('').css('color', '#000000');
		}
	}).blur(function () {
		if ($(this).val() == '')
		{
			$(this).css('color', '#c0c0c0').val('E-mail Address');
		}
	});

	$('#optIn').submit(function () {
		$(this).children('.error').slideUp();
		$bReturn = true;
		if (($(this).children('input[name=fn]').val() == 'First Name') || ($(this).children('input[name=fn]').val() == ''))
		{
			$(this).children('input[name=fn]').css('color', '#ff0000').val('First Name');
			$bReturn = false;
		}
		if (($(this).children('input[name=ln]').val() == 'Last Name') || ($(this).children('input[name=ln]').val() == ''))
		{
			$(this).children('input[name=ln]').css('color', '#ff0000').val('Last Name');
			$bReturn = false;
		}
		if (($(this).children('input[name=ea]').val() == 'E-mail Address') || ($(this).children('input[name=ea]').val() == ''))
		{
			$(this).children('input[name=ea]').css('color', '#ff0000').val('E-mail Address');
			$bReturn = false;
		}

		if (!$bReturn)
		{
			$(this).children('.error').html('All fields are required.').slideDown();
		}
		
		return $bReturn;
	});
	
	_switch();
});









var testimonial_count;
var testimonial_interval;
var current_testimonial = 0;
var old_testimonial = 0;

function testimonial_rotate() {
  current_testimonial = (old_testimonial + 1) % testimonial_count;
  $("div.testimonial:eq(" + old_testimonial + ")")
  	.fadeOut(1000);
	/*.animate({top: -300},"slow", function() {
	  $(this).css('top', '300px');
	});*/
  $("div.testimonial:eq(" + current_testimonial + ")")
  	.fadeIn(1000);
	/*.animate({top: 5},"slow");*/
  old_testimonial = current_testimonial;
}

$(document).ready(function(){
  testimonial_count = $("div.testimonial").size();
  //$("div.testimonial:eq("+current_testimonial+")").css('top', '5px');
  testimonial_interval = setInterval(testimonial_rotate,10000);
  $('#testimonials').hover(function() {
	clearInterval(testimonial_interval);
  }, function() {
	testimonial_interval = setInterval(testimonial_rotate,10000);
	//testimonial_rotate();
  });

  old_testimonial = -1;
  testimonial_rotate();
});
