$(document).ready(function(){resizedivs();});
$(window).resize(function(){resizedivs();});
function resizedivs() {
	var height = $(window).height();
	if (height < 500) height = 500;
	$('#floater').height(height);
	height = $('#floater').height() - 100;
	if (height < 400) height = 400;
	$('#holder').height(height);
	var margintop = ($('#floater').height() - $('#holder').height()) / 2;
	$('#holder').css("margin-top",margintop+"px");
	var padleft = $('#holder').width() / 2 + 196;
	$('#content').css("padding-left",padleft+"px");
	var padtop = $('#holder').height() / 2 + 107;
	$('#content').css("padding-top",padtop+"px");
}
function makecall() {
	$('#phoneflash').text("Please fill in your Name and Phone Number below, and Google will connect your call for free.");
	$('#callbtn').show();
	$('#closebtn').show();
	$('#phonename').show();
	$('#phonenumber').show();
	$('#call').css("opacity",0);
	$('#call').show();
	var left = ($(window).width() / 2) - ($('#call').width() / 2);
	var top = ($(window).height() / 2) - ($('#call').height() / 2);
	$('#call').css("left",left+"px");
	$('#call').css("top",top+"px");
	$('#call').animate({opacity: 1}, 500);
	$('#floater').animate({opacity: 0.1}, 1000);
}
function closecall() {
	$('#call').animate({opacity: 0}, 500).hide().end();
	$('#floater').animate({opacity: 1}, 500);
}
function connectcall() {
	if (jQuery.trim($('#name').val()) == "" || jQuery.trim($('#number').val()) == "") {
		$('#phoneflash').text("Name and Number are required. Please check your values below.");
		return false;
	}
	$('#callbtn').hide();
	$('#closebtn').hide();
	$('#phonename').hide();
	$('#phonenumber').hide();
	$.ajax({
		type: "POST",
		url: "/",
		data: $("#callform").serialize(),
		success: function(msg){
			if (msg == "ok=true") {
				$('#phoneflash').text("Your call is being connected.");
				$('#closebtn').show();
			}
			else {
				$('#phoneflash').text("There seems to have been an error. Please check your phone number and name below, and try again.");
				$('#callbtn').show();
				$('#closebtn').show();
				$('#phonename').show();
				$('#phonenumber').show();
			}
		}
	});
	return false;
}