$(document).ready(function()
{
	$(".avaa_popup").live("click", function(e)
	{
		e.preventDefault();
		
		var href = $(this).attr("href");
		var tmp = href.lastIndexOf("/");
		var id = href.substring(tmp+1, href.length);
		
		$("#page").append("<div id='leivontatietoa_popup' class='baking_info' style='display: none;'></div>");
		var p = $("#leivontatietoa_popup");
		p.css(
		{
			"width": "980px",
			"background": "#fff",
			"border": "1px solid #92052e",
			"border-top": "none",
			"padding": " 20px 20px 60px",
			"margin-bottom": "20px",
			"position": "absolute",
			"top": "70px",
			"left": (parseInt($("#page").width()) / 2) - (980 / 2)+"px"
		});
		
		
		p.load("/ajax_leivontatietoa.php", { id: id }, function(d)
		{
			if($.browser.msie)
			{
				p.show();
				p.append("<input type='button' name='leivontatietoa_popup_sulje' value='Takaisin' style='width: 100px; display: none; position: absolute; top: 10px; right: 10px;' />");
				p.append("<input type='button' name='leivontatietoa_popup_sulje' value='Takaisin' style='width: 100px; display: none; position: absolute; bottom: 10px; right: 10px;' />");
				$("input[name=leivontatietoa_popup_sulje]").show();
			}
			else
			{
				p.fadeIn(500, function()
				{
					p.append("<input type='button' name='leivontatietoa_popup_sulje' value='Takaisin' style='display: none; position: absolute; top: 10px; right: 10px;' />");
					p.append("<input type='button' name='leivontatietoa_popup_sulje' value='Takaisin' style='display: none; position: absolute; bottom: 10px; right: 10px;' />");
					$("input[name=leivontatietoa_popup_sulje]").fadeIn(500);
				});
			}
		});
		
	});
	
	
	$("input[name=leivontatietoa_popup_sulje]").live("click", function()
	{	
		if($.browser.msie)
		{
			$("#leivontatietoa_popup").hide();
			$("#leivontatietoa_popup").remove();
		}
		else
		{
			$("#leivontatietoa_popup").fadeOut("500", function()
			{
				$("#leivontatietoa_popup").remove();
			});
		}
	});
});

