// $Id: $

var curTab = 'tab1';


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=author_of';
			var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showAuthorOf} );
			break;
			
		case 'tab3':
			url = gWebRoot + 'api.php';
			pars = 'id=' + gObject_id + '&method=coauthors';
			var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showCoauthors} );
			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 showCoauthors (originalRequest) 
{
	var html = '';
	html += '<div>';
	html += '<div id="contact_index" style="float:right;padding:6px;text-align:center;"><\/div>';
	html += '<div id="contact_list" style="overflow:auto;height:400px;border:1px solid rgb(190,190,190);"><\/div>';
	html += '<\/div>';

	$('content').innerHTML = html;

	var newData = eval(originalRequest.responseText);

	$('load').style.display = 'none';
}

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

	var newData = eval(originalRequest.responseText);


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

