function Results_Widget (results, start, end, root) {
	this.results = results;
	this.start = start;
	this.end = end;
	this.root = root;
}

Results_Widget.prototype.containerHTML = function (id) {
	var results_html = "<div style=\"border-top: 1px solid #222\"><div id=\"" + id + "\" class=\"inset_content\">";
	results_html += "</div><div id=\"result_navigation\" style=\"height: 20px; border-top: 1px solid #666\"></div>";
	results_html += "</div>";
	return results_html;
}

Results_Widget.prototype.display = function () {
	hide('join_frame');
	
	_get(this.root).innerHTML = this.containerHTML('result_frame');
	_get('result_frame').innerHTML = this.member_html();
}

Results_Widget.prototype.member_html = function () {
	var first = "";
	var last = "";
	var serial = "";
	var type = "";
	var available = "";
	var date = "";
	var info = "";
	var name = "";
	
	var results_html = "<div style=\"padding: 3px;\">";
	for(var x=0;x<this.results.length;x++) {
		first = this.results[x]['first_name'];
		last = this.results[x]['last_name'];
		serial = this.results[x]['serial'];
		type = this.results[x]['type'];
		available = this.results[x]['status'];
		date = this.results[x]['date'];
		info = this.results[x]['info'];
		name = "No Name";
	
		if(!info) {
			info = "";
		}
	
		if(first) {
			name = first;
			if(last) {
				name += " " + last;
			}
		}
		
		if(!available || available == 'undefined') {
			available = 0;
		}
		
		results_html += "<a onClick='' href='index.php?u_id=" + topcode(serial) + "&t=" + topcode(type)  + "&av=" + topcode(available) + "' class=\""+link_class(type)+"\">";
			
		results_html += name;
		results_html += "</a> - <span class=\"small\"> Joined on " + raw_date(date)  + "</span>";
		results_html += "<br />";
		results_html += "<div style=\"color: #111\">";
		results_html += info;
		results_html += "</div>";
		results_html += "<hr style=\"border: 1px dotted #333\"/>";
	}
	results_html += "</div>";
	return results_html;
}

function hide (element_id, height) {

	if(!height) {
		var height = _get(element_id).style.height;
		if(!height) {
			height = "340px";
		}
		var h_array = height.split('px');
		height = h_array[0];
	}

	var rate = height/10;
	var end_rate = height/13;
	height = (height - rate) - end_rate ;
	_get(element_id).style.height = height + "px";
	
	if(height>=1) {
		setTimeout("hide('join_frame',"+height+")" , 10);
	} else {
		_get(element_id).style.visibility='hidden';
	}
}