function trimString(str)
{
	str = this != window? this : str;
	return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
};

function popup(o)
{
	var top_h = $(document).scrollTop();
	var window_h = $(window).height();
	var path = o.attr("href");
	$("#popup_main").stop().fadeIn(200);
	var popup_h = $("#popup").height();
	var test_h = window_h + top_h;
	if (popup_h > test_h) {
		$("#popup").css('top', '10px');
	} else{
		var real_top_h = top_h + (window_h - popup_h)/2;
		$("#popup").css('top', real_top_h);
	}
	return false;
};

$(document).ready(function()
{
	$("#send_request").click(function() {
		popup($(this));
		return false;
	});

	$("#popup_close").click(function() {
		$("#popup_main").hide();
	});
});
