var id = null;

function getID() {
	return id;
}

function sample(_id) {
	id = _id;
	var so = new SWFObject("/web/player.swf", "fso_sampler", "19", "19", "8", "#FFFFFF", true);
	so.write("SamplePlayer");
}

function overview()
{
	style = document.getElementById("overview").style;
	if (style.visibility != "inherit") {
		style.visibility = "inherit";
	} else {
		style.visibility = "hidden";
	}
}

function map()
{
	popup("/web/details.php?f=map", "overview", 340, 480);	
}

function tellafriend(id)
{
	popup("/web/tellafriend.php?id=" + id, "tell_a_friend", 414, 306);
}

function popup(u, n, w, h)
{
	w2 = w;
	h2 = h;

	window.open(u, n, "width=" + w + ",height=" + h + ",outerwidth=" + w2 + ",outerheight=" + h2 + ",top=50,left=50");
}

var showing = false;

function show_map() {
	showing = true;
	
	if (document.getElementById("map_image") && document.getElementById("map_image").style.display != "block") {
		document.getElementById("map").className = "mapOn";
		document.getElementById("map_image").style.display = "block";
	}
}

function hide_map() {
	showing = false;
	
	setTimeout(function(e) {
		if (!showing) {
			if (document.getElementById("map_image") && document.getElementById("map_image").style.display != "none") {
				document.getElementById("map").className = "mapOff";
				document.getElementById("map_image").style.display = "none";
			}
		}
	}, 100);
}

function init_over() {
	if (document.captureEvents) document.captureEvents(Event.MOUSEMOVE);
	
	var _body = document.getElementById("_body_");
	var _obj = document.getElementById("main_image");
	var _map = document.getElementById("map");
	
	_obj.onmouseover = function(e) {
		// _body.style.cursor = "pointer";
		show_map();
	}

	_obj.onmouseout = function(e) {
		// _body.style.cursor = "default";
		hide_map();
	}
	
	_map.onmouseover = _obj.onmouseover;
	_map.onmouseout = _obj.onmouseout;
	
	/*
	document.onmousemove = function (e) {
		logMousePosition(e);

		var _obj = document.getElementById("main_image");
		var _body = document.getElementById("_body_");

		if (_obj) {
			pos = findAbsolutePosition(_obj);
			_inside = Mouse.x >= pos.x && Mouse.x <= pos.x + _obj.width;
			_inside = _inside && Mouse.y >= pos.y && Mouse.y <= pos.y + _obj.height;
			if (_inside) {
				_body.style.cursor = "pointer";
				show_map();
			} else {
				_body.style.cursor = "default";
				hide_map();
			}
		}
	};
	*/
}

var Mouse = new Object();
var isIE = document.all ? true : false;

function logMousePosition(e) {
	e = e ? e : window.event;

	if (isIE) {
		Mouse.x = e.x;
		Mouse.y = e.y;
	} else {
		Mouse.x = e['clientX'];
		Mouse.y = e['clientY'];
	}
}

function findAbsolutePosition(obj) {
	var rv = new Object();
	rv.x = 0;
	rv.y = 0;

	if (obj.offsetParent) {
		rv.x = obj.offsetLeft;
		rv.y = obj.offsetTop;

		while (obj = obj.offsetParent) {
			rv.x += obj.offsetLeft;
			rv.y += obj.offsetTop;
		}
	}
	return rv;
}
