var fh_selection = new FH_Selection();
function getFH_Selection() {
	return fh_selection;
}

function FH_Selection() {
	var items = new Array();
	var ajax = new QW_AJAX;

	this.addVideo = function(id) {
		var resp = ajax.get('index.php5?module=selection_ajax&action=addVideo&id='+id, null, false);
		this.reload();
	}
	
	this.addSerie = function(id) {
		var resp = ajax.get('index.php5?module=selection_ajax&action=addSerie&id='+id, null, false);
		this.reload();
	}

	this.removeVideo = function(id) {
		var resp = ajax.get('index.php5?module=selection_ajax&action=removeVideo&id='+id, null, false);
		this.reload();
	}
	
	this.clear = function(id) {
		var resp = ajax.get('index.php5?module=selection_ajax&action=clear', null, false);
		this.reload();
	}
	
	this.reload = function() {
		this.hideIllustration();
		document.getElementById('selection').innerHTML = ajax.get('index.php5?module=selection_ajax&action=toHtml', null, false);
	}
	
	this.showIllustration = function(url, item) {
		var html = '<img src="'+url+'" width="150" height="113">';
		var div = document.getElementById('floatSelection');
		if ( div.innerHTML != html ) {
			this.hideIllustration();
			div.style.left = (getOffsetPosition(item, 'Left')-155)+'px';
			div.style.top  = (getOffsetPosition(item, 'Top')+5)+'px';
			div.innerHTML = html;
			div.style.display = 'block';
		}
	}
	
	this.hideIllustration = function() {
		var div = document.getElementById('floatSelection');
		if ( div != null )
			div.style.display = 'none';
	}
}

var mouse_x = 0;
var mouse_y = 0;
function trackMouse(e) {
	mouse_x = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+getOffsetPosition(document.getElementById('selection'), 'Left');
	mouse_y = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+getOffsetPosition(document.getElementById('selection'), 'Top');
}

QW_EVENT_addOnload( function() {
						var divSel = document.getElementById('selection');
						QW_EVENT_addOnmousemove(trackMouse, divSel);
					} );

					
					
function getOffsetPosition(obj, type)
{
	var val = 0;
	var type = 'obj.offset' + type;
	while (obj && obj.tagName != 'BODY') {
		val += eval(type);
		obj = obj.offsetParent;
	}
	return val;
}