function downloadFormValidate(theForm) {
	var form = theForm; 
	var noval = ''
	$(form).find('select').removeClass('fail');
	$(form).find('input').removeClass('fail');
	$(form).find('.prompt').text('');
	
  if (!form.Name.value) {
		noval = 'something missing';
		$('#yourname').addClass('fail').siblings('.prompt').text('Please enter your name.').addClass('fail'); 
		form.Name.focus();
	}
	if (!form.Company.value) {
		noval = 'something missing';
		$('#yourcompany').addClass('fail').siblings('.prompt').text('Please enter your Company name.').addClass('fail'); 
		form.Company.focus();
	}
	if (!form.Telephone.value ) { 
		noval = 'something missing';
        $('#telephone').addClass('fail').siblings('.prompt').text('Please enter your telephone.').addClass('fail');
		form.Telephone.focus();
	}
	if (!form.Email.value ) { 
		noval = 'something missing';
        $('#emailaddress').addClass('fail').siblings('.prompt').text('Please enter your email.').addClass('fail');
		form.Email.focus();
	}
	var pcnumber = $(form).find('#pcnumber option:selected').text();
	if (pcnumber == '--Select--' ) { 
		noval = 'something missing';
        $('#pcnumber').addClass('fail').siblings('.prompt').text('Please choose network size.').addClass('fail');
		form.PCs.focus();
    }
	if (noval == 'something missing') {
		return false;
	}
	return (true);
}



function addHoverAnimation() {
	$(this).hover(
		function() {
			$(this).children('.boxtext').animate({
				"opacity": 0.8}, {
				duration: 300 }
				);
		},
		function() {
			$(this).children('.boxtext').animate({
				"opacity": 1}, {
				duration: 300 }
				);
		}
	);
}

function initCarousel() {
	if ($(this).hasClass('current') == false) {
		$(this).animate({ 
			height: 226,
			width: 214,
			backgroundPosition: "100% 0px",
			opacity: 0.5
		});
	}
	if ($(this).hasClass('out') == true) {
		$(this).animate({ 
			opacity: 0
		});
	
	}
	
	$(this).hover(
		function() {
			if (($(this).hasClass('next')) || ($(this).hasClass('prev'))) {
			$(this).animate({
				"opacity": 1.0}, {
				duration: 400 }
				);
			}
		},
		function() {
			if (($(this).hasClass('next')) || ($(this).hasClass('prev'))) {
			$(this).animate({
				"opacity": 0.5}, {
				duration: 200 }
				);
			}
		}
	);
	
	
	$(this).bind('click', swishCarousel);
	
	function swishCarousel() {
		
		$(".box").queue("fx", []);

		if ($(this).hasClass('prev')) {

				$('.box').unbind('click', swishCarousel);
						
				var thelist = $(this).parents('li').parents('ul');
				var thefeature = $(thelist).find('.current');
				var theprev = $(this);
				var thenext = $(thelist).find('.next');
				var lastChild = $(thelist).find('li:last');
			
			$(thenext).animate({
				left: "1000px"},
				1200,
				function(){$(this).css({left: "-250px"}).removeClass('next');}
			);
			
			$(thefeature).animate({
				opacity: 0.5,
				height: 226,
				width: 209,
				left: 680,
				top: 15
				}, 
				1200,
				function(){$(thefeature).addClass('next').removeClass('current').css({backgroundPosition: "top right"});}
			);
			
			$(theprev).css({left: "20px"}).removeClass('prev').animate({
				opacity: 1.0,
				height: 260,
				width: 433,
				left: 238,
				top: 0,
				backgroundPosition: "100% 100%"
				}, 
				1200,
				function(){$(theprev).addClass('current');}
			);
			
			$(lastChild).children('.box').animate( {
				opacity: 0.5,
				height: 226,
				width: 209,
				left: 20,
				top: 15,
				backgroundPosition: "100% 0px"
				}, 
				1300,
				function(){
					$(lastChild).children('.box').addClass('prev').removeClass('out');
					$('.box').bind('click', swishCarousel);
				}
			);
			
			$(lastChild).prependTo($(thelist));
			
		}
		
		else if ($(this).hasClass('next')) {
		
				$('.box').unbind('click', swishCarousel);
				
				var thelist = $(this).parents('li').parents('ul');
				var thefeature = $(thelist).find('.current');
				var theprev = $(thelist).find('.prev');
				var thenext = $(this);
				var fourthChild = $(thelist).find('li:nth-child(4)');
			
			$(theprev).animate({
				left: "-250px"},
				1200,
				function(){$(this).addClass('out').removeClass('prev');}
			);
			
			$(thefeature).animate( {
				opacity: 0.5,
				height: 226,
				width: 209,
				left: 20,
				top: 15,
				backgroundPosition: "100% 100%"
				}, 
				1200,
				function(){$(thefeature).addClass('prev').removeClass('current').css({backgroundPosition: "top right"});;}
			);
			
			$(thenext).css({left: "680px"}).removeClass('next').animate({
				opacity: 1.0,
				height: 260,
				width: 433,
				left: 238,
				top: 0,
				backgroundPosition: "100% 100%"
				}, 
				1200,
				function(){$(thenext).addClass('current');}
			);
			
			$(fourthChild).children('.box').css({left: "1000px"}).animate({
				opacity: 0.5,
				height: 226,
				width: 209,
				left: 680,
				top: 15
				}, 
				1300,
				function(){
					$(fourthChild).children('.box').addClass('next').removeClass('out').css({backgroundPosition: "top right"});
					$('.box').bind('click', swishCarousel);
				}
			);
			
			$(theprev).parents('li').appendTo($(thelist));
			
		}
		
	};
	
	setTimeout(function(){$('.carousel .prev').click();},1000)
	
}

$(document).ready(function() {
	$('.features .box').each(addHoverAnimation);
	$('.carousel .box').each(initCarousel);	
  
});