// $Id: order.js 883 2009-08-26 22:22:18Z sdalu $


/* Highslide settings
 */
hs.graphicsDir             = '/highslide/graphics/';
hs.align                   = 'center';
hs.transitions             = ['expand', 'crossfade'];
hs.outlineType             = 'glossy-dark';
hs.captionEval             = 'this.thumb.alt';
hs.captionOverlay.position = 'above';
hs.wrapperClassName        = 'dark';
hs.fadeInOut               = true;
hs.dimmingOpacity          = 0.75;
hs.showCredits             = false;
hs.marginLeft              = 30;
hs.marginRight             = 30;
hs.marginTop               = 30;
hs.marginBottom            = 70;
hs.lang                     = {
    cssDirection   : 'ltr',
    loadingText    : 'Chargement...',
    loadingTitle   : 'Cliquer pour arreter',
    focusTitle     : 'Cliquer pour amener au premier plan',
    fullExpandTitle: 'Expand to actual size (f)',
    creditsText    : 'Powered by <i>Highslide JS</i>',
    creditsTitle   : 'Go to the Highslide JS homepage',
    previousText   : 'Precedent',
    nextText       : 'Suivant', 
    moveText       : 'Deplacer',
    closeText      : 'Fermer', 
    closeTitle     : 'Fermer (esc)', 
    resizeTitle    : 'Redimensionner',
    playText       : 'Play',
    playTitle      : 'Play slideshow (spacebar)',
    pauseText      : 'Pause',
    pauseTitle     : 'Pause slideshow (spacebar)',
    previousTitle  : 'Precedent (fleche gauche)',
    nextTitle      : 'Suivant (fleche droite)',
    moveTitle      : 'Deplacer',
    fullExpandText : '1:1',
    number         : 'Image %1 of %2',
    restoreTitle   : 'Cliquez pour fermer l\'image, cliquez et tirez pour deplacer. Utilisez les fleches pour suivant et precedent.'
};


/*
      hs.registerOverlay({
          html: '<div class="closebutton" onclick="return hs.close(this)" title="Fermer"></div>',
          position: 'top right',
          useOnHtml: true,
          fade: 2 // fading the semi-transparent overlay looks bad in IE
      });

      hs.Expander.prototype.onDoFullExpand = function() {
          window.location.href = this.custom.url;
      }
*/


if (hs.addSlideshow)
    hs.addSlideshow({
	interval      : 5000,
        repeat        : false,
	useControls   : true,
	fixedControls : 'fit',
	overlayOptions: { overlayId     : 'controlbar',
                          opacity       : .6,
		          position      : 'bottom center',
                          offsetX       : '0',
                          offsetY       : '-15',
			  hideOnMouseOut: true },
	thumbstrip    : { mode          : 'horizontal',
                          position      : 'bottom center',
                          relativeTo    : 'viewport' }
      }); 



Ext.onReady(function() {

/* Show information (ie: title) about thumbnail
 */
Ext.select('.gallery .thumbnail').each(function(elt) {
    var title = elt.child('.title');
    var info  = elt.child('.info');
    title.setVisibilityMode(Ext.Element.DISPLAY);
    var task  = new Ext.util.DelayedTask(function() {
	title.stopFx().syncFx()
	     .fadeIn (     { easing: 'easeIn', duration: 0.2 })
	     .slideIn('t', { easing: 'easeIn', duration: 0.2 });
	});
    info.hover(function() { 
	if (!title.isVisible()) task.delay(200);
      }, function(evt) {
	task.cancel();
	if (title.isVisible())
	    title.stopFx()
		 .ghost('t',{easing: 'easeOut', duration: 0.2}); 
	});
  });


/* Allow selection of a gallery subset
 */
if (Ext.fly('selection')) {
    Ext.select('.gallery .sc-item').setVisibilityMode(Ext.Element.DISPLAY);
    Ext.fly('selection').on('click', function(e, t) {
          if (Ext.fly(t).hasClass('selected')) return;
          Ext.fly(t).radioClass('selected');

          var set = null;
          var grp = t.id.match(/^sel-(.*)/);
          grp = (grp && grp[1] != 'all') ? grp[1] : null;
          if (grp) {
              Ext.select('.gallery .sc-item')
		 .hide().each(function(item) {
                  var ref = item.query('.frame .inner a')[0];
		  if (ref) { ref.onclick       = null;
		             ref.hsHasSetClick = false;
			     ref.removeAttribute('rel'); }
              });
              set = Ext.select('.gallery .sc-item[sc-photo-grp='+grp+']');
          } else { 
              set = Ext.select('.gallery .sc-item');
          }
          set.show().each(function(item) {
              var ref = item.query('.frame .inner a')[0];
	      if (ref) ref.rel = 'highslide';
          });
          hs.setClickEvents();
       }, null, { delegate: 'span' });
}  


});

