$(document).ready(function(){
	$('#callAlert').hide();
	$('#callAlertConfirm').hide();
	$('#callAlertLoading').hide();
	$('.buttonCallLink').click(function(){
		$('#callAlert').toggle("slow");
	});
});


function callback(){

	if(!$("#name").val()) {
		$('#labelName').css({
			'color' : '#ff6600',
			'font-weight' : 'bold'
		});
		return false;
	}
	else {
		$('#labelName').css({
			'color' : '#666666',
			'font-weight' : 'normal'
		});
	}

	if(!$('#phone').val()) {
		$('#labelPhone').css({
			'color' : '#ff6600',
			'font-weight' : 'bold'
		});
		return false;
	}
	else {
		$('#labelPhone').css({
			'color' : '#666666',
			'font-weight' : 'normal'
		});
	}


	$.ajax({
		type: "POST",
		url: "/callback.php",
		data: 	"name=" + document.getElementById("name").value + 
				"&phone=" + document.getElementById("phone").value +
				"&time=" + document.getElementById("time").value,

		beforeSend: function(){
			$('#callAlertForm').hide();
			$('#callAlertLoading').show();
		},
 
		complete: function(){
			$('#callAlertLoading').hide();
		},

		success: function(html){
			$('#callAlertConfirm').show();
                	$("#callAlertConfirm").append(html);

			$(document).ready(function(){
				$('.buttonClose').click(function(){
				$('#callAlert').toggle("slow");
				});
			});
		}
	});

	return false;

}
