function showhidebox(idbox){
	if ($(idbox).style.display == 'none') { 
		$(idbox).style.display = 'block';	
	}else{
		$(idbox).style.display = 'none';		
	}
}

function galleria(album,othervars){
	var pars = 'album=' + album + '&' + othervars;
    aggiornamento();
	new Ajax.Updater(
		'content', 
		'galleria.php', {
		 onComplete:function(){
		 initLightbox();
		 },
		parameters: pars,
		method: 'get',
		asynchronous:true, evalScripts:true
		}
	);
}	

function albums(othervars){
	var pars = othervars;
    aggiornamento();
	new Ajax.Updater(
		'content', 
		'galleria_albums.php', {
		parameters: pars,
		method: 'get',
		asynchronous:true, evalScripts:true
		}
	);
} 

function showhide(idbox,msg1,msg2){
	if ($('descr_'+idbox).style.display == 'none') { 
		new Effect.BlindDown('descr_'+idbox);
		$('showdescr_'+idbox).update(msg1);	
	}else{
		new Effect.BlindUp('descr_'+idbox);
		$('showdescr_'+idbox).update(msg2);	
	}
}
function showhideBox(idbox,spanbox,text1,text2,filtro){
	if ($(idbox).style.display == 'none') { 
		new Effect.BlindDown(idbox);
		$(spanbox).update(text1);	
		$F(filtro) = 'show';	
	}else{
		new Effect.BlindUp(idbox);
		$(spanbox).update(text2);		
		$F(filtro) = 'hide';	
	}
}
function aspetta(dove){
	$(dove).update('<p align="center"><img src="img/loading.gif" alt="attendere..." align="absmidle" /></p>');	
}
function aggiornamento(){	
	$('content').update('<div id="loading"></div>');	
}
function responso_pagina(originalRequest){
	$('content').update(originalRequest.responseText);
}
function updatebox(dove,cosa){
	$(dove).update(cosa);
}

/* finestra modale */
function showBox(box){
    $('overlay').show();
    center(box);
    return false;
}

function hideBox(box){
    $('box').hide();
    $('overlay').hide();
    return false;
}

function center(element){
    try{
        element = $(element);
    }catch(e){
        return;
    }

    var my_width  = 0;
    var my_height = 0;

    if ( typeof( window.innerWidth ) == 'number' ){
        my_width  = window.innerWidth;
        my_height = window.innerHeight;
    }else if ( document.documentElement && 
             ( document.documentElement.clientWidth ||
               document.documentElement.clientHeight ) ){
        my_width  = document.documentElement.clientWidth;
        my_height = document.documentElement.clientHeight;
    }
    else if ( document.body &&
            ( document.body.clientWidth || document.body.clientHeight ) ){
        my_width  = document.body.clientWidth;
        my_height = document.body.clientHeight;
    }

    element.style.position = 'absolute';
    element.style.zIndex   = 99;

    var scrollY = 0;

    if ( document.documentElement && document.documentElement.scrollTop ){
        scrollY = document.documentElement.scrollTop;
    }else if ( document.body && document.body.scrollTop ){
        scrollY = document.body.scrollTop;
    }else if ( window.pageYOffset ){
        scrollY = window.pageYOffset;
    }else if ( window.scrollY ){
        scrollY = window.scrollY;
    }

    var elementDimensions = Element.getDimensions(element);

    var setX = ( my_width  - elementDimensions.width  ) / 2;
    var setY = ( my_height - elementDimensions.height ) / 2 + scrollY;

    setX = ( setX < 0 ) ? 0 : setX;
    setY = ( setY < 0 ) ? 0 : setY;

    element.style.left = setX + "px";
    element.style.top  = setY + "px";

    /* element.style.display  = 'block'; */
 	Effect.Appear(element);    
}

/*
function openmenu(elementid){
	if ($(idpanel).style.display == 'none') {
		new Effect.Appear(elementid);
	}else{
		new Effect.Fade(elementid);
	}
}
*/