function photocatbrowse_select_topic(topic, url) {
  url += "?topic=" + encodeURIComponent(topic);
  var cb = {
    success: photocatbrowse_select_topic_success,
    failure: photocatbrowse_select_topic_failure,
    argument: [topic]
  };
  
  var resdata = document.getElementById("topics-results-data");
  if(resdata != null) {
    resdata.innerHTML = '<div class="wait-icon padbottom10px">Please Wait...</div>';
    YAHOO.util.Connect.resetFormState();
    YAHOO.util.Connect.asyncRequest("GET", url, cb, null);
    YAHOO.util.Connect.resetFormState();  
  }
}

function photocatbrowse_select_topic_success(o) {
  var res = document.getElementById("topics-results");
  var resdata = document.getElementById("topics-results-data");
  
  if(res != null && resdata != null) {
    resdata.innerHTML = o.responseText;
    toggleVisibilitySwap("topics-results", "topics-results", "topics-list");
  }
}

function photocatbrowse_select_topic_failure(o) {

}

function cb_SliderViewerImageSelect(o, oimg, ocont, imgPos) {
  car_photo_number = imgPos + 1;
  SliderViewerImageUpdate();
}

function cb_SliderViewerVideoSelect(o, oimg, ocont, imgPos) {
  msg = o.id+','+oimg.id+','+ocont+','+imgPos
  var vidlink = oimg.getAttribute('vidlink');
  //alert (vidlink );
  window.location.href=vidlink;
}

function cb_SliderViewerImageSelectOnTop(o, oimg, ocont, imgPos) {
  car_photo_number = imgPos + 1;
  // keep same order
  alt_photos = []
  for(var i=0;i<car_photos.length;i++) {
    if  (car_photos[i].v==null) {
      alt_photos[alt_photos.length] = car_photos[i];
    }
  }
  SliderViewerImageUpdate(alt_photos[car_photo_number - 1]);
}

function cb_SliderAnimate(anImg) {
  anImg.animate();
}

function cb_SliderViewerMouseOver(o, oimg, ocont, imgPos) {
  //var im = YAHOO.util.Dom.get(oimg);
  var c = YAHOO.util.Dom.get(ocont);
  YAHOO.util.Dom.addClass(c.id, "select");
}

function cb_SliderViewerMouseOut(o, oimg, ocont, imgPos) {
  //var im = YAHOO.util.Dom.get(oimg);
  var c = YAHOO.util.Dom.get(ocont);
  YAHOO.util.Dom.removeClass(c.id, "select");
}

function SliderViewerImageUpdate() {
  if(typeof(isModeNormal) == "undefined") isModeNormal=true;
  car_photo_switch++;
  if(car_photo_switch % 3 == 0 && typeof(abmsManager) != "undefined") abmsManager.refreshAllSlots();

  var photo = car_photos[car_photo_number - 1];
  if(photo != null) {
    var photo_number = document.getElementById("car-photo-number");
    var photo_elem = document.getElementById(isModeNormal?"car-photo-src":"img-full-size-photo-container");
    var photo_caption = document.getElementById("car-photo-caption");
    var photo_date = document.getElementById("car-photo-date");
    var photo_articles = document.getElementById("car-photo-articles");
    var photo_src_link = document.getElementById("car-photo-src-link");
    
    if(photo_src_link != null) {
      if(typeof(photo.picid) != "undefined" && typeof(XPRIMA.use_pic_ids) != "undefined" && XPRIMA.use_pic_ids) {
        window.location.href = "#" + photo.picid;
        photo_src_link.href = window.location.href;
      }
    }

    var raterid = document.getElementById("rateitrid");
    if(raterid != null) {
      raterid.value = photo.i;
    }
   
    if(typeof(photo_tags_cache[photo.i]) != "undefined") {
      photo_tag_update_success(photo_tags_cache[photo.i]);
      
    }
    else {
      // Begin AJAX request to update tags before we update the image...
      cb = {
        success: photo_tag_update_success,
        failure: photo_tag_update_failure,
        argument: [photo.i]
      };
      
      resource_tags_url = "/site/support/ajax_tagsforresource.spy?rid=" + photo.i.toString() + "&language=" + escape(js_auto123_language);
      YAHOO.util.Connect.resetFormState();
      YAHOO.util.Connect.asyncRequest("GET", resource_tags_url, cb, null);
      YAHOO.util.Connect.resetFormState();
    }
    
    if(photo_number != null && photo_elem != null) {
      photo_number.innerHTML = car_photo_number.toString();
      if(photo_caption != null) {
        photo_caption.innerHTML = photo.c;
        photo_caption.style.display = (photo.c != null && photo.c != "") ? "block" : "none";
      }
      
      if(photo.v != null) {
        // A handler was specified
        try {
          eval("var f = (" + photo.v + ")");
        }
        catch(e) {
          var f = null;
        }
        
        if(f != null && typeof(f) != "undefined") {
          f(photo);
          return;
        }
      }

      toggleVisibilitySwap('viewer-mode', 'viewer-photo', 'viewer-photo');
      YAHOO.util.Dom.setStyle(photo_elem, "opacity", 0);
      //photo_elem.src = "/site/img/spacer.gif";
        
      var large_photo = document.getElementById("photo-fullsize");
      if(large_photo != null) {
        large_photo.style.height = "";
        large_photo.style.width = "";
        large_photo.src = photo.p + "/scale-484x363";
      }
      
      if(photo_date != null) photo_date.innerHTML = photo.ed;
      photo_elem.src = photo.p + (isModeNormal?"/scale-484x363":"/scale-792x594");
      photo_elem.style.height = "";
      photo_elem.style.width = "";
      
      var an = new YAHOO.util.Anim(photo_elem.id, { opacity: { to: 1 } }, 0.2, YAHOO.util.Easing.easeNone);
      photo_elem.onload = function() { cb_SliderAnimate(an) };
      //YAHOO.util.Event.onContentReady(photo_elem.id,cb_SliderAnimate,an);
//      an.animate();

      if(photo_articles != null) {
        var HTML_Block = "";
        if(photo.a.length > 0 && typeof(car_photo_articles[photo.a[0]]) != "undefined") {
          for(var j = 0; j < photo.a.length; j++) {
            var articles = car_photo_articles[photo.a[j]];
            if(typeof(articles) != "undefined") {
              for(var i = 0; i < articles.length; i++) {
                HTML_Block += '<li><a href="' + articles[i].link + '">' + articles[i].title + '</a></li>';
              }
            }
          }
        }
        else {
          var deftext = photo_articles.getAttribute("defaulttext");
          if(deftext != null) {
            HTML_Block += "<li>" + deftext + "</li>";
          }
        }
        photo_articles.innerHTML = HTML_Block;
      }

      // Update percentage bar
      if(photo_main_slideshow_isrunning()) {
        var perc = document.getElementById("car-photo-percentagebar");
        if(perc != null && perc.parentNode.parentNode.style.display != "none") {
          var percent = parseInt(car_photo_number * 100 / car_photos.length);
          var parentWidth = parseInt(perc.parentNode.style.width || 434);
          perc.style.width = parseInt(parentWidth / 100.0 * percent) + "px";
        }
      }
    }
  }
}

// ML, FC, Created Oct 2, 2008
//
if(typeof(XPRIMA) == "undefined") XPRIMA = {}
if(typeof(XPRIMA.log) == "undefined") XPRIMA.log = function(s) { 
  if(typeof(console) != "undefined" && typeof(console.debug) != "undefined") { 
    console.debug(s); 
  }
};

if(typeof(XPRIMA.Multimemdia) == "undefined") XPRIMA.Multimedia = {};

XPRIMA.Multimedia.ImageLoaded = function(e) {
  var a = new YAHOO.util.Anim(e, { opacity: { from: 0, to: 1 }}, 0.4, YAHOO.util.Easing.easeNone);
  a.animate();
}

XPRIMA.Multimedia.Slider = function(idBase,groupingMode,conf) {
  this.idBase = idBase;
  if(groupingMode==null) {
    groupingMode = 0;
  }
  this.init(idBase,groupingMode,conf);
};

XPRIMA.Multimedia.Slider.prototype =  {
    // *** Preset Values ***
    aspectRatioW   : 4, // the 4 in 4:3  NEEDED OUTSIDE INIT
    aspectRatioH   : 3, // the 3 in 4:3  NEEDED OUTSIDE INIT
    moveSpeed      : 0.4,
    containerPad   : 2, // padding inside container, surrounds the img NEEDED OUTSIDE INIT
    minContainerMargin: 2, // Margin outside container.  is it needed outside init ?
    // *** Work Values ***
    oSliderLeft    : null,  // NEEDED OUTSIDE INIT
    oSliderRight   : null,  // NEEDED OUTSIDE INIT
    oSliderCentral : null,  // is it needed outside init ?
    oSliderMover   : null,  // NEEDED OUTSIDE INIT
    oSliderContainer: null,
    motionRight    : null,  // NEEDED OUTSIDE INIT
    motionLeft     : null,  // NEEDED OUTSIDE INIT
    motionSetPosition: null,
    vpHeight       : 0, // unassigned Viewport Height, in pix.  is it needed outside init ?
    vpWidth        : 0, // unassigned Viewport Width, in pix.    NEEDED OUTSIDE INIT
    realTopMargin  : 0, // unassigned Adjusted top padding, in pix, unassigned NEEDED OUTSIDE INIT
    thCount        : 0, // unassigned NEEDED OUTSIDE INIT
    realInterMargin: 0, // unassigned NEEDED OUTSIDE INIT
    realLeftMargin: 0, // NEEDED OUTSIDE INIT
    photoPosFrom: 0, //NEEDED OUTSIDE INIT
    limitRight: 0, //NEEDED OUTSIDE INIT
    w              : null,//NEEDED OUTSIDE INIT
    h              : null,//NEEDED OUTSIDE INIT
    cfg: null,
    imgList: null,
    opacity: null,
    fadeOpacityIn: false,
    fadeOpacitySpeed: 0.8,
    calcImgHeight : function(scrollerHeight,containerPad,containerMargin) {
      // *------------------------------------------------
      // |    2  SCROLLER (Central) 2px (ContainerMargin) 
      // |   **====== border(1px thick)=======**          
      // | 2 ||    CONTAINER (pad=2)          ||          
      // |   || 2 *-----------------------*   ||          
      // |   ||   |  IMAGE                | 2 ||          
      var result = scrollerHeight;
      result -= 2; // substract the border, 2 pixels
      result -= 2*containerPad;
      result -= 2*containerMargin;
      // Need the value to be smallest next multiple of the H ratio (e.g. 3)     
      // Ex.: Assumning the values in the drawing above, if we get a             
      // scrollerHeight of 39, we'd get 29.  Then 'result' == 27.                
      result = Math.floor(result / this.aspectRatioH) * this.aspectRatioH;
      // Build obj with result and projected container height (including border) 
      return {imgHeight:result,containerHeight:result + 2 + 2*containerPad};
    },
    calcContainerWidth : function(imgHeight,containerPad) {
      // Assumes that imgHeight is the smallest next multiple of the H ratio (e.g. 3)
      var imageWidth = (imgHeight * this.aspectRatioW) / this.aspectRatioH ;
      var result = imageWidth;
      result += 2; // Add the border, 2 pixels
      result += 2*containerPad;
      return {containerWidth:result,imgWidth:imageWidth};  // excludes the intra margin between containers.
    },
    imgMouseClick : function(e) {
      var o = null;
      if(YAHOO.env.ua.ie > 0)
        o = e.srcElement;
      else
        o = e.target;
      
      if( this.cfg!=null && this.cfg.imgMouseClickCB!=null && typeof(this.cfg.imgMouseClickCB)=="function") {
        var contId = document.getElementById(o.id).getAttribute('imgparentcontainer');
        var imgPos = parseInt(document.getElementById(o.id).getAttribute('imgposition'));
        this.cfg.imgMouseClickCB(this,o,contId,imgPos);
      }
    },
    imgMouseOver : function(e) {
      var o = null;
      if(YAHOO.env.ua.ie > 0)
        o = e.srcElement;
      else
        o = e.target;
      
      if( this.cfg!=null && this.cfg.imgMouseOverCB!=null && typeof(this.cfg.imgMouseOverCB)=="function") {
        var contId = document.getElementById(o.id).getAttribute('imgparentcontainer');
        var imgPos = parseInt(document.getElementById(o.id).getAttribute('imgposition'));
        this.cfg.imgMouseOverCB(this,o,contId,imgPos);
      }
    },
    imgMouseOut : function(e) {
      var o = null;
      if(YAHOO.env.ua.ie > 0)
        o = e.srcElement;
      else
        o = e.target;
      if( this.cfg!=null && this.cfg.imgMouseOutCB && typeof(this.cfg.imgMouseOutCB)=="function") {
        var contId = document.getElementById(o.id).getAttribute('imgparentcontainer');
        var imgPos = parseInt(document.getElementById(o.id).getAttribute('imgposition'));
        this.cfg.imgMouseOutCB(this,o,contId,imgPos);
      }
    },
    generateImgId  : function(n) {
      return this.idBase+'-img-'+n;
    },
    buildContainer : function(leftMargin,pos,nm,buildContainer,attrib) {
      res='';
      
      if( this.realTopMargin!=null && leftMargin!=null) {
        var kit = this.imgList[Math.floor(pos / this.thCount)];
        var vpkit = kit.vpKit[Math.floor(pos % this.thCount)];
        var imgId = vpkit.id;
        var contId = this.idBase+'-container-'+pos;
        if(typeof(attrib)!="undefined" && attrib!=null){
          var attr= '';
          for (var idxAttrObj in attrib) {
            var attrObj=attrib[idxAttrObj];
            if(typeof(attrObj.attrName) != "undefined" && attrObj.attrName != null
            && typeof(attrObj.attrVal ) != "undefined" && attrObj.attrVal  != null) {
              attr += ' '+attrObj.attrName+'="'+attrObj.attrVal+'" ';
            } else {
              attr += '<!--Err:'+'-->';
            }
          }
          //alert(attr);
        }
        res =  '<div';
        res += ' id="'+contId+'" ';
        res += ' class="xslider-img-container"';
        res += ' style="';
        res += 'margin-top:'+this.realTopMargin+'px;';
        res += 'margin-left:'+leftMargin+'px;';
        res += 'width:'+this.w.imgWidth+'px;';
        res += 'height:'+this.h.imgHeight+'px;';
        res += 'padding:'+this.containerPad+'px;';
        res += '"';
        res += '>';
        res += '<div style="text-align:center;overflow:hidden;width:'+this.w.imgWidth+'px;height:'+this.h.imgHeight+'px;" ';
        res += ' class="xwait-icon"';
        res += '>';
        res +=   '<img id="'+imgId+'"';
        res += ' imgparentcontainer="'+contId+'" ';
        res += ' imgposition="'+pos+'" ';
        res += attr;
        res += ' src="/site/img/spacer.gif" ';
        res +=   '/>';
        res += '</div>';
        res += '</div>';
      }
      return {res:res,imgId:imgId,contId:contId};
    },
    calcContainerHeight : function(scrollerWidth,containerPad,containerMargin) {
      res  = scrollerWidth;
      res -= 2*containerMargin; // res is now a "projected" container width
      // The container width must be based on img width, because the later respects the ratio.
      var imgWidth = Math.floor((res - 2 -2*containerPad)/this.aspectRatioW) * this.aspectRatioW;
      var containerWidth  = imgWidth + 2 + 2*containerPad ;
      var imgHeight = (imgWidth * this.aspectRatioH) / this.aspectRatioW;
      var containerHeight = imgHeight + 2 +   2*containerPad ;
      return { w : { containerWidth : containerWidth , imgWidth        : imgWidth } , 
               h : { imgHeight      : imgHeight      , containerHeight : containerHeight } };
    },
    init : function(idBase,groupingMode,conf) {
      //XPRIMA.log('XPRIMA.Multimedia.Slider.init():');
      this.fadeOpacityIn = (YAHOO.env.ua.ie <= 0);
      this.imgList = [];
      this.cfg = conf;
      
      this.oSliderContainer = document.getElementById(idBase);
      //XPRIMA.log('this.oSliderContainer.id:'+this.oSliderContainer.id)
      var wCentral = parseInt(YAHOO.util.Dom.getStyle(this.oSliderContainer,'width'));
      var hCentral = parseInt(YAHOO.util.Dom.getStyle(this.oSliderContainer,'height'));
      //XPRIMA.log('wCentral :'+wCentral)
      //XPRIMA.log('hCentral :'+hCentral)
      
      this.oSliderLeft   = document.getElementById(idBase+'-left');
      var lSize = parseInt(YAHOO.util.Dom.getStyle(this.oSliderLeft,'border-left-width')) + 
                  parseInt(YAHOO.util.Dom.getStyle(this.oSliderLeft,'border-right-width'))+
                  parseInt(YAHOO.util.Dom.getStyle(this.oSliderLeft,'padding-left'))      +
                  parseInt(YAHOO.util.Dom.getStyle(this.oSliderLeft,'padding-right'))     +
                  parseInt(YAHOO.util.Dom.getStyle(this.oSliderLeft,'width'));
      this.oSliderRight  = document.getElementById(idBase+'-right');
      var rSize = parseInt(YAHOO.util.Dom.getStyle(this.oSliderRight,'border-left-width')) + 
                  parseInt(YAHOO.util.Dom.getStyle(this.oSliderRight,'border-right-width'))+
                  parseInt(YAHOO.util.Dom.getStyle(this.oSliderRight,'padding-left'))      +
                  parseInt(YAHOO.util.Dom.getStyle(this.oSliderRight,'padding-right'))     +
                  parseInt(YAHOO.util.Dom.getStyle(this.oSliderRight,'width'));
      this.oSliderCentral= document.getElementById(idBase+'-central');
      var lAdj     = parseInt(YAHOO.util.Dom.getStyle(this.oSliderCentral,'border-left-width')) + 
                     parseInt(YAHOO.util.Dom.getStyle(this.oSliderCentral,'padding-left'));
      var rAdj     = parseInt(YAHOO.util.Dom.getStyle(this.oSliderCentral,'border-right-width')) + 
                     parseInt(YAHOO.util.Dom.getStyle(this.oSliderCentral,'padding-right'));
      //XPRIMA.log('lAdj :'+lAdj);
      //XPRIMA.log('rAdj :'+rAdj);
      YAHOO.util.Dom.setStyle(this.oSliderCentral,'width',wCentral-(rSize+lSize+lAdj+rAdj)+'px');

      
      YAHOO.util.Dom.setStyle(this.oSliderCentral,'height',hCentral+'px');
      this.oSliderMover  = document.getElementById(idBase+'-central-mover');

      if(this.oSliderLeft!=null && this.oSliderRight!=null && this.oSliderCentral!=null) {
        this.vpHeight = parseInt(this.oSliderCentral.style.height);
        this.vpWidth  = parseInt(this.oSliderCentral.style.width);
        this.oSliderLeft.style.height = this.vpHeight+'px';
        this.oSliderRight.style.height= this.vpHeight+'px';
        this.oSliderMover.style.height= this.vpHeight+'px';
        document.getElementById(idBase).style.height= this.vpHeight+'px';
        // EVENT (scroll left and right) SUBSCRIBED HERE
        YAHOO.util.Event.addListener([this.oSliderLeft.id,this.oSliderRight.id,], "click", this.sliderMoverCB,this,true);        
        // Calculating optimal width and height of a thumbnail.
        this.h=this.calcImgHeight(this.vpHeight,this.containerPad,this.minContainerMargin);
        this.w=this.calcContainerWidth(this.h.imgHeight,this.containerPad);        
        // Check to see how much would fit.
        //XPRIMA.log('this.vpWidth:'+this.vpWidth);
        //XPRIMA.log('this.w.containerWidth:'+this.w.containerWidth);
        this.thCount = Math.floor(this.vpWidth / (this.w.containerWidth+2*this.minContainerMargin));
        if(this.thCount<1) {
          // We could not fit at least one thumbnail.
          // Aspect ratio is "taller" than preset
          // Constrain it the other way around then.
          o = this.calcContainerHeight(this.vpWidth,this.containerPad,this.minContainerMargin);
          this.w=o.w;
          this.h=o.h;
          this.thCount = 1;
        }
        
        //XPRIMA.log(this.w.imgWidth+'x'+this.h.imgHeight);
        
        // AT THIS PT w and h are fit for at least one image.
        this.opacity = [];
        for(var i=0;i<this.thCount;i++) {
          this.opacity[this.opacity.length] = null;
        }
        // Now that our thumbnail sizes are guaranteed to fit, distribute the margins values        
        // First the easiest, the top / bottom margin
        this.realTopMargin = Math.floor((this.vpHeight - this.h.containerHeight)/2);
        // Then, side margin ...
        // groupingMode == 0 ==>  10 2 2 2 9 (25) i.e. all thumbnails are "packed" in the center.
        // groupingMode == 1 ==>   3 5 5 5 2 (20) i.e. all thumbnails are "evenly" distributed.
        this.realInterMargin  = (groupingMode == 1 ? Math.floor((this.vpWidth-(this.thCount*this.w.containerWidth))/this.thCount) : this.minContainerMargin);
        var marginRemainder = this.vpWidth - this.thCount*this.w.containerWidth - this.realInterMargin*(this.thCount-1);
        this.realLeftMargin = marginRemainder -  Math.floor(marginRemainder / 2 );
        // Compute by how much we slide the thumbnails away.
        this.deltaMove = this.vpWidth  - marginRemainder + this.realLeftMargin;
      }    
    },
    storeImgList : function(il) {
      //XPRIMA.log('storeImgList');
      // Creates an object struct like the following:
      //[ // position 0
      //  {
      //    loaded : true, // or false
      //    vpkit  : [  // postion 0
      //                { id  : this.idBase + "-img-0",
      //                  pth : "..." // path to photo
      //                },
      //                // ...
      //                // position i
      //                { id  : this.idBase + "-img-"+i,
      //                  pth : "..." // path to photo
      //                },
      //                // ... 
      //                // position this.thCount - 1
      //                { id  : this.idBase + "-img-"+(this.thCount - 1),
      //                  pth : "..." // path to photo
      //                }
      //             ]
      //  },
      //  // ...
      //  // position i
      //  { loaded : true, // or false
      //    vpkit  : [  {...}, ... {...}, {...}  ] // this.thCount objects, as above
      //  },
      //  // ...
      //  // position (il.length) / this.thCount 
      //  { loaded : true, // or false
      //    vpkit  : [  {...}, ... {...}, {...}  ] // this.thCount objects, as above
      //  }
      //]
      var vpKit;
      vpKit=[];
      this.imgList = [];
      var strPicolioScaler = '';
      for (var i in il) {
        if(__uns__) {
          strPicolioScaler = '/scale-'+this.w.imgWidth+'x'+this.h.imgHeight;
        }
        if(i%this.thCount==this.thCount-1) {
          vpKit[vpKit.length] = {pth:il[i]+strPicolioScaler,id:this.generateImgId(i)};
          this.imgList[this.imgList.length] = {vpKit:vpKit,loaded:false};
          vpKit = [];
        } else {
          vpKit[vpKit.length] = {pth:il[i]+strPicolioScaler,id:this.generateImgId(i)};
        }
      }
      if(il.length%this.thCount!=0) {
        this.imgList[this.imgList.length] = {vpKit:vpKit,loaded:false};
      }
    },
    getImageCount:function() {
      return (this.imgList.length -1)* this.thCount + this.imgList[this.imgList.length-1].vpKit.length;
    },
    loadImgList : function(il,attribs) {
      if (this.oSliderMover==null) {
        return;
        }
      //XPRIMA.log('loadImgList');
      this.storeImgList(il);
      var ntotal = il.length;
      //XPRIMA.log('ntotal:'+ntotal);
      this.limitRight = Math.floor( (ntotal%this.thCount==0?ntotal-1:ntotal) / this.thCount) * this.thCount; 
      var moverWidth = (this.vpWidth*ntotal/this.thCount);
      YAHOO.util.Dom.setStyle(this.idBase+'-central-mover', "width", moverWidth+"px");
      idList = [];
      var innerHtml='';
      for (var imgFile in il) {
        var i = imgFile;
        var attrib=null;
        if(typeof(attribs) != "undefined" && attribs != null) {
          attrib = attribs[i];
        }
        //XPRIMA.log('  i:'+i)
        //XPRIMA.log('  this.thCount:'+this.thCount)
        var kit = this.imgList[Math.floor(i / this.thCount)];
        var vpkit = kit.vpKit[Math.floor(i % this.thCount)];
        var pth = vpkit.pth;
        var o = null;
        var realMarginToUse = i%(this.thCount)==0?this.realLeftMargin:this.realInterMargin;
        
        o=this.buildContainer(realMarginToUse,i,pth,null,attrib);
        innerHtml+=  o.res;
        idList[idList.length]=o.imgId;
      }
      //XPRIMA.log('idList.length:'+idList.length);
      this.oSliderMover.innerHTML = innerHtml;      
      YAHOO.util.Event.addListener(idList, "click",     this.imgMouseClick,this,true);
      YAHOO.util.Event.addListener(idList, "mouseover", this.imgMouseOver,this,true);
      YAHOO.util.Event.addListener(idList, "mouseout",  this.imgMouseOut,this,true);
      var vpKit = this.imgList[0];
      vpKit.loaded = true;
      this.loadKit(vpKit.vpKit,0.8);
      this.animateOpacity();
      this.setButtonState();
      // This does not bring back the scroller, however.
      // FIX NEEDED HERE.
      this.setPosition(0);
    },
    
    setPosition : function(pos) {
      //XPRIMA.log('XPRIMA.Multimedia.Slider.setPosition('+pos+'):');
      //XPRIMA.log('  this.photoPosFrom:'+this.photoPosFrom)
      //XPRIMA.log('  Math.floor(this.photoPosFrom/this.thCount):'+Math.floor(this.photoPosFrom/this.thCount));
      var moveCount = Math.floor(this.photoPosFrom/this.thCount)-pos;
      //XPRIMA.log('  moveCount:'+moveCount);
      this.motionSetPosition = new YAHOO.util.Motion(this.oSliderMover, { points: { by: [moveCount*this.deltaMove, 0]}}, this.moveSpeed, YAHOO.util.Easing.easeOut);
      this.motionSetPosition.onComplete.subscribe(this.motionSetPositionComplete,this,true);
      this.motionSetPosition.animate();     
      this.photoPosFrom = pos*this.thCount;
    },
    
    motionSetPositionComplete : function(){
      this.setButtonState();
    },
    
    loadKit : function(vpKit,delayOverride) {
      if(delayOverride==null) {
        delayOverride = this.fadeOpacitySpeed;
      }
      for(var i in vpKit){
        anId = vpKit[i].id;
        aPth = vpKit[i].pth;
        elem = document.getElementById(anId);
        elem.src = aPth;
        if(this.fadeOpacityIn==true) {
          YAHOO.util.Dom.setStyle(anId, 'opacity', '0.0');
          this.opacity[i] = { 
           'opacity': new YAHOO.util.Anim(anId, { opacity: { to: 1.0 }}, delayOverride, YAHOO.util.Easing.easeNone) }
        }
      }
    },
    moveRight :  function() {
      if(this.photoPosFrom < this.limitRight) {
        if(this.motionRight == null) {
          this.motionRight = new YAHOO.util.Motion(this.oSliderMover, { points: { by: [-this.deltaMove, 0]}}, this.moveSpeed, YAHOO.util.Easing.easeOut);
          this.motionRight.onComplete.subscribe(this.motionRightComplete,this,true);
        }
        this.motionRight.animate();
        if(this.photoPosFrom>=0) {
          var idx = Math.floor((this.photoPosFrom+this.thCount) / this.thCount);
          var vpKit = this.imgList[idx];
          if(vpKit.loaded==false) {
            vpKit.loaded = true;
            this.loadKit(vpKit.vpKit);
          }
        }
        this.animateOpacity();
      }
    },
    moveLeft :  function() {
      if(this.photoPosFrom>0){
        if(this.motionLeft == null) {
          this.motionLeft = new YAHOO.util.Motion(this.oSliderMover, { points: { by: [this.deltaMove, 0]}}, this.moveSpeed, YAHOO.util.Easing.easeOut);
          this.motionLeft.onComplete.subscribe(this.motionLeftComplete,this,true);
        }
        this.motionLeft.animate();        
      }
    },
    sliderMoverCB : function(e) {
      var oid = null;
      
      if(YAHOO.env.ua.ie > 0)
        oid = e.srcElement.id;
      else
        oid = e.target.id;
      switch(oid) {
        case this.idBase + "-left":
          this.moveLeft();
          break;
        case this.idBase + "-right":
          this.moveRight();
          break;
      }
    },
    setButtonState : function() {
      if(this.photoPosFrom == 0) {
        YAHOO.util.Dom.setStyle(this.oSliderLeft.id,'opacity','0.35');
        YAHOO.util.Dom.setStyle(this.oSliderRight.id,'opacity','1.0');
      } else if(this.photoPosFrom  == this.limitRight) {
        YAHOO.util.Dom.setStyle(this.oSliderLeft.id,'opacity','1.0');
        YAHOO.util.Dom.setStyle(this.oSliderRight.id,'opacity','0.35');
      } else {
        YAHOO.util.Dom.setStyle(this.oSliderLeft.id,'opacity','1.0');
        YAHOO.util.Dom.setStyle(this.oSliderRight.id,'opacity','1.0');
      }
    },
    animateOpacity : function() {
      if(this.fadeOpacityIn==true) {
        for(var i in this.opacity){
          if(typeof(this.opacity[i]) != "undefined" && this.opacity[i] != null && typeof(this.opacity[i].opacity) != "undefined" && this.opacity[i].opacity!=null) {
            this.opacity[i].opacity.animate();
          }
        }
      }
    },
    motionRightComplete : function() {
      this.photoPosFrom += this.thCount;
      this.setButtonState();
      //this.animateOpacity();
    },
    motionLeftComplete : function() {
      this.photoPosFrom -= this.thCount;
      this.setButtonState();
    },
    thisMustBeLast : function() {return null;}
};

/*
XPRIMA.Windows = function() {
  return {
    id_fullscreen_viewer : "xprima-multimedia-fullscreen-viewer",
    
    openFullSizeImageViewer : function() {
      var viewerContainer = document.getElementById(this.id_fullscreen_viewer);
      
      if(viewerContainer == null) {
        // We need to create it!
        var e = document.createElement("div");
        e.setAttribute("id", this.id_fullscreen_viewer);
        e.setAttribute("style", "border: 1px solid #d1d4d7; padding: 10px; text-align: center; overflow: hidden; background-color: white; position: absolute; top: 0; left: 0; width: 1px; height: 1px; z-index: 999;");
        
        var i = document.createElement("div");
        i.setAttribute("id", this.id_fullscreen_viewer + "-img");
        i.setAttribute("src", "/site/img/spacer.gif");
        
        e.appendChild(i);
        document.body.appendChild(e);
      }
      
      this.openFullSizeImageViewer_animOpen(e);
    },
    
    openFullSizeImageViewer_animOpen : function(e) {
      var cw = YAHOO.util.Dom.getClientWidth();
      var ch = YAHOO.util.Dom.getClientHeight();
      var attrs = {
        width  : { from: 1, to: cw - 40 },
        height : { from: 1, to: ch - 40 },
        top    : { to: 10 },
        left   : { to: 10 }
      };
      
      var a = new YAHOO.util.Anim(e, attrs, 0.4, YAHOO.util.Easing.easeNone);
      a.animate();
    }
  }
}();
*/
