function GetEventSrc (e) {
	if (! e)
		e = event;
	return e.target || e.srcElement;
}
/**************************************/
var atHeight=0;
function InitAree () {
	atHeight=$('atList').getHeight();
	$('atList').style.height='0px';	
	//$('atList').show();

	/*$('left').firstDescendant().onmouseover = function () {
		this.addClassName('box_close');
	}
	$('left').firstDescendant().onmouseout = function () {
		this.removeClassName('box_close');
	}*/
	$('left').firstDescendant().onclick = function () {
		if ($('atList').getHeight()<atHeight) {
			//$('atList').style.padding='10px 10px 10px 0px';
			$('atList').morph('height: '+atHeight+'px;',{duration: 0.3});
			$('atList').show();
			$('left').down('div').removeClassName('box_open');
			$('left').down('div').addClassName('box_close');
		} else {
			$('atList').morph('height: 0px;',{duration: 0.3, afterFinish: function () {					
				//$('atList').style.padding='0px 10px 0px 0px';
				$('atList').hide();
				$('left').down('div').removeClassName('box_close');
			$('left').down('div').addClassName('box_open');
			}});
		}
	}
}
/*************************************************************/
function InitRiviste () {
	$$('#rList li.ulTop').each(function (s) {
			s.observe('mouseover', function(event){				
				this.down('ul').show();				
				this.style.background='#f0f0f0';
				this.style.borderBottomColor='#f0f0f0';
			});
			s.observe('mouseout', function(event){
				this.down('ul').hide();				
				this.style.background='#ffffff';
				this.style.borderBottomColor='#ffffff';
			});
		});
}
/*************************************************************/
function InitLibri (_autL,_titL) {
	//init autori
	var strSubmit='action=AI&autL='+_autL;
	new Ajax.Request('/libri/getData.php', {
		method: 'post',
		parameters: strSubmit, 
		onSuccess: function(transport) {
			if (transport.responseText[0]=="#")
				alert (transport.responseText);
			else {
				$$('#alList div.leftLetters')[0].innerHTML=transport.responseText;
				LoadAutori (null,_autL);
				$$('#alList div.leftLetters')[0].show();
			}			
		},
		onFailure: function () {					
			alert ('Aut init error');
		}
	});
	//init libri
	var strSubmit='action=LI&titL='+_titL;
	new Ajax.Request('/libri/getData.php', {
		method: 'post',
		parameters: strSubmit, 
		onSuccess: function(transport) {
			if (transport.responseText[0]=="#")
				alert (transport.responseText);
			else {
				$$('#tlList div.leftLetters')[0].innerHTML=transport.responseText;
				LoadTitoli (null,_titL);
				$$('#tlList div.leftLetters')[0].show();
			}			
		},
		onFailure: function () {					
			alert ('Aut init error');
		}
	});
}

function LoadAutori (e,_lt) {	
	var strSubmit='';
	if (_lt==undefined) {
		$$('#alList a.act')[0].removeClassName('act');
		//var ac=$(window.event.target);
		var ac=GetEventSrc(e);		
		//ac.addClassName('act'); IE problem
		ac.className='act';
		strSubmit='action=AL&autL='+ac.innerHTML;		
	} else {
		strSubmit='action=AL&autL='+_lt;
		$('alt_'+_lt).addClassName('act');
	}	
	$$('#alList ul')[0].innerHTML='<li><img src="/images/loader.gif" width="16" height="16" border="0" /></li>';
	//	
	new Ajax.Request('/libri/getData.php', {
		method: 'post',
		parameters: strSubmit, 
		onSuccess: function(transport) {
			if (transport.responseText[0]=="#")
				alert (transport.responseText);
			else {							
				$$('#alList ul')[0].innerHTML=transport.responseText;
			}			
		},
		onFailure: function () {					
			alert ('Get Author error');
		}
	});
}

function LoadTitoli (e,_lt) {
	if (_lt==undefined) {
		$$('#tlList a.act')[0].removeClassName('act');
		//var ac=$(window.event.target);
		var ac=GetEventSrc(e);
		//ac.addClassName('act'); IE problem
		ac.className='act';
		var strSubmit='action=TL&titL='+ac.innerHTML;
	} else {
		var strSubmit='action=TL&titL='+_lt;
		if (_lt=='*')
			_lt=0;
		$('tlt_'+_lt).addClassName('act');
	}
	$$('#tlList ul')[0].innerHTML='<li><img src="/images/loader.gif" width="16" height="16" border="0" /></li>';
	//	
	new Ajax.Request('/libri/getData.php', {
		method: 'post',
		parameters: strSubmit, 
		onSuccess: function(transport) {
			if (transport.responseText[0]=="#")
				alert (transport.responseText);
			else {							
				$$('#tlList ul')[0].innerHTML=transport.responseText;
			}			
		},
		onFailure: function () {					
			alert ('Get Title error');
		}
	});
}
