var is_closable;

function popup(content) {
	if ($("head > link[href='/popup.css']").length==0) {
		$("head").append('<link rel="stylesheet" type="text/css" href="/popup.css" />');
	}
	if ($(".layover").size()) {
		if ((content==undefined) || (content=='') || (content==$("#layover_box").html())){
			$(".layover").remove("div");
			$("object").each(function() {
				list = $(this).attr("old").split("|");
				$(this).css("position",list[0]);
				$(this).css("top",list[1]);
			});
		} else {
			$("#layover_box").empty();
			$("#layover_box").append(content);
			$("#layover_box > *").mouseover(function (){
				is_closable = false;
			});
			$("#layover_box > *").mouseout(function (){
				is_closable = true;
			});
		}
	} else {
		$("object").each(function() {
				position = $(this).css("position");
				var top;
				try {
					top = $(this).css("top");
				} catch (e) {
					top = "auto";
				}
				$(this).attr("old",position+"|"+top);
		});
		$("object").css("position","absolute").css("top","-10000px");
		$("body").append("<div class=\"layover\"><div></div>" +
				"<div><div>" +
				"<div id=\"layover_box\" style=\"width: 100%;z-index: 50;position: relative;margin:auto;overflow: auto;max-height: 600px; text-align: center;\">" +
				content +
				"</div></div></div></div>");
		is_closable = true;
		$("#layover_box > *").mouseover(function (){
			is_closable = false;
		});
		$("#layover_box > *").mouseout(function (){
			is_closable = true;
		});
		$('.layover').click(function () {
			if ($(".layover").size()) {
				if (is_closable) {
					$(".layover").remove("div");
					$("object").each(function() {
						list = $(this).attr("old").split("|");
						$(this).css("position",list[0]);
						$(this).css("top",list[1]);
					});
				}
			}
		});
	}
	return false;
}



	function start_360(file) {
		return_a = '' +
		'<object id="view_360" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="360" height="260" codebase="http://www.apple.com/qtactivex/qtplugin.cab">' +
	'<param name="src" value="'+file+'" />' +
	'<param name="fov" value="76" /> ' +
	  '<param name="controller" value="true" />' + 
	  '<param name="cache" value="false" /> ' +
	  '<param name="scale" value="tofit" /> ' +
	'<embed src="'+file+'" TYPE="video/quicktime" pluginspace="http://www.apple.com/quicktime/download/" width="360" height="270" fov="76" controller="true" cache="false" scale="tofit"></embed>' + 
	'</object>' +
	''
	popup(return_a);
	}
