// JavaScript Document

var method = '';
var open_id = '';

function showItem(id) {
	if($('item_' + id).style.display == 'none') {
		if(open_id != '')
		{
			Effect.BlindUp('item_' + open_id, { duration: 1.0 })
			open_id = '';
		}
		new Ajax.Request('request.php', { method:'post', postBody: 'inverkoop=' + id });
		Effect.BlindDown('item_' + id, { duration: 1.0 })
		open_id = id;
	}
	else {
		Effect.BlindUp('item_' + id, { duration: 1.0 })
	}
}


var reageer = function() {
	
	this.object = null;
	this.action = true;
	
	this.set = function(id, bg) {
		if(!this.object) {
			this.object = id;
			this.request(this.object, bg);
		}
		else if(this.object != id) {
			old = this.object;
			Effect.BlindUp('reageer_' + this.object, { duration: 1.0, 
				afterFinish: function() {
					document.getElementById('reageer_' + old).innerHTML = '';
					this.object = id; 
					reageer.request(this.object, bg);
				} 
			})
		}
	}
	
	this.request = function(obj, bg) {
		
		var ID = obj;
		this.object = obj; 
		new Ajax.Request('request.php', { method: 'post', postBody: 'binnenkortinverkoop=' + this.object + '&bg='+bg,
			onSuccess: 
			function(response) {
				document.getElementById('reageer_' + ID).innerHTML = response.responseText;
				Effect.BlindDown('reageer_' + ID, { duration: 1.0 })
			}
			
		});
	}
	
}