var objPhotoGallery = null; 

document.addEvent('domready', function(){

  objPhotoGallery = new cfShowPics();

  if (gbPagDef.title) {
    if (gbPagDef.title != '') $('idSiteBodyTitle').set( 'html', gbPagDef.title );
  }  
  
  $('idSiteBody').set( 'morph', { 'duration':'long' } );
  $('idSiteGrayUnderForm').set( 'morph', { 'duration':'500' } );  
  $('idSiteForm').set( 'morph', { 'duration':'500' } ); 
  
  $('idSiteBody').morph( {'opacity': [0,1]} );  
});

/* -------------------------------------------------------------------------- */
/*   gestione Forms area riservata                                            */ 
/* -------------------------------------------------------------------------- */

function usbLogin() {    
  
  new cfForm( $('frmLogin'), './bin/adm_q.php?act=login', {    
    elRetMsg:$('frmLogin_msgs'),    
    elDefs: [              
      { id:'iUsr', w:200, l:45 },
      { id:'iPsw', w:200, l:45 },        
      { id:'frmAbort', w:100 },
      { id:'frmSubmit', w:100 }    
    ],      
    'fnValidate': function( o ) { 
      var msg = '';      
      if (o.elForm.iUsr.value == '' )   msg = "La UserID non pu&oacute; essere vuota";
      if (o.elForm.iPsw.value == '' )   msg = "La Password non pu&oacute; essere vuota";
      if (msg != '') { o.showMsg( msg ); return(false); }        
      return( true );     
    },    
    'onReturn': function( o, a ) { o.elForm.reset(); window.location = './admin.php'; },      
    'onQueryabort': function( o ) { o.elForm.reset(); window.location = './index.php'; }
  });          
}

/* -------------------------------------------------------------------------- */
/*   Visualizzazione gallery                                                  */ 
/* -------------------------------------------------------------------------- */
function showGallery( id ) {
  new Request.JSON({ 
    url: './bin/usb_pic.php?act=gal_imgs&id=' + id,
    encoding: 'utf-8', 
    onComplete: function( j ) {            
      //var bsz = $(document.body).getSize();
      objPhotoGallery.setGallery( j.ris );
      //objPhotoGallery.setPath( './bin/usb_pic.php?act=pic&w='+(bsz.x - 80)+'&h='+(bsz.y - 100)+'&id=' ); 
      objPhotoGallery.setPath( './bin/usb_pic.php?act=pic&id=' );
        
      objPhotoGallery.showPic( 0 );
    }  
  }).send();
}

/* -------------------------------------------------------------------------- */
/*   Visualizzazione squadre                                                  */ 
/* -------------------------------------------------------------------------- */
function showSquadre() {  
  //var accordion = new Fx.Accordion($$('.toggler'),$$('.element'), {
  var accordion = new Accordion($$('.sqcl_toggler'),$$('.sqcl_element'), {
    opacity: 0,
    onActive: function(toggler) { toggler.setStyle('color', '#f30'); },
    onBackground: function(toggler) { toggler.setStyle('color', '#000'); }
  });    
}

