//window.addEvent('domready',function() {
//	if($('pof')) {
		//new Fx.Tween($('pof-screenlock')).start('opacity',1);
		//new Fx.Tween($('pof')).start('top',800,50);
	//}
//});


$(window).load(function() {
	
	$.each($('#pof input'), function(index,value) {
		$(value).attr('defaultvalue',$(value).val());
		if($(value).hasClass('medium')) {
			$(value).click(function() {
				if($(this).val() == $(this).attr('defaultvalue')) {
					$(this).val('');
				}
			});
			$(value).blur(function() {
				if($(this).val().length == 0) {
					$(this).val($(this).attr('defaultvalue'));
				}
			});
		}
	});
	
	
	$('#gform_11').submit(function() {
		return validateForm();
	});
	

	if($('#pof')) {
		$('#pof-screenlock').animate({
			'opacity': 0.7
		},
		300, 
		function() {
			$('#pof').animate({
				'opacity': 1,
				'height': 460
			},
			500, 
			function() {
				$('#pof-screenlock').html('');
				$('#pof-matrix-box-left').animate({
					'opacity': 1
				},
				500, 
				function() {
					$('#pof-matrix-box-right').animate({
						'opacity': 1
					},
					500, function() {
						$('#pof-left-introducing').animate({
							'opacity': 1
						},
						300, function() {
							$('#pof-left-content').animate({
								'opacity': 1
							},
							800, function() {
								$('#pof-bubble').animate({
									'opacity': 1
								},300);
								$('#pof-matrix-topic').animate({
									'opacity': 1
								},300);
							});

						});
					});
				});
			});
		});
	}
});

function validateForm() {
	if($('#input_11_1').length == 0 || $('#input_11_1').val() == 'Name' || $('#input_11_2').length == 0 || $('#input_11_2').val() == 'Company' || $('#input_11_3').length == 0 || $('#input_11_3').val() == 'Phone') {
		alert('Please fill in your Name, Company and Phone.');
		$('#gform_ajax_spinner_11').remove();
		return false
	}
	else {
		return true
	}
}

function closePof() {
	$('#pof').remove();
	$('#pof-screenlock').remove();
}

function calculateServices(element) {
	if($(element).hasClass('active')) {
		$(element).removeClass('active');
		$('#pof-score').html(parseInt($('#pof-score').html())-1);
	}
	else {
		$('#pof-score').html(parseInt($('#pof-score').html())+1);
		$(element).addClass('active');
	}
}
