// $Id: $

var curTab = 'tab1';

function tags(obj) 
{
	d = document.getElementById('tags');
	d.innerHTML= '';

	var html = '';

	if (obj.results.length > 0)
	{
		html += '<ul class="tags">';
	 for(i=0;i<obj.results.length;i++)
	 {
			html += '<li><a href="' + gWebRoot + 'uri/' + obj.results[i].object_id + '">' + obj.results[i].name + '</li>';
	 }
		html += '</ul>';
	}
	
	d.innerHTML= html;
}

function getTabData(id) {

	$(curTab).removeClassName('active');
	$(id).addClassName('active');
	curTab = id;

	$('content').innerHTML = "";

	var url = 'process.php';
	var rand   = Math.random(9999);
	var pars   = 'id=' + id + '&rand=' + rand;
	
	switch (id)
	{
		case 'tab1':
			url = gWebRoot + 'api.php';
			pars = 'id=' + gObject_id + '&method=object_attributes';
			var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showAttributes} );
			break;

		case 'tab2':
			url = gWebRoot + 'api.php';
			pars = 'id=' + gObject_id + '&method=references';
			var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showSequences} );
			break;
			
			
		default:
			var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showResponse} );
			break;
	}
}

function showLoad () 
{
	$('load').style.display = 'block';
}

function showResponse (originalRequest) 
{
	var newData = ""; // originalRequest.responseText;
	$('load').style.display = 'none';
	$('content').innerHTML = newData;
}

function showAttributes (originalRequest) 
{
	var html = '<div id="attributes"><\/div>';
	$('content').innerHTML = html;

	var newData = eval(originalRequest.responseText);


	$('load').style.display = 'none';
	//$('content').innerHTML = newData;
}



function showSequences (originalRequest) 
{
	var html = '<div id="references"><\/div>';
	$('content').innerHTML = html;

	var newData = eval(originalRequest.responseText);


	$('load').style.display = 'none';
	//$('content').innerHTML = newData;
}

