
/*  ----------------------------------------------
    home.js
    author: Regi E. (rellis@pushhere.com, Lead Dev)
    
    req/location
      scripts/mootools.js
      scripts/clientcide.js
      scripts/home.js
    ----------------------------------------------  */


/*  Class: SlideShow
    -----------------------------------------------  */
    function watchSlideshow(mask, slides, link) {
      var mask = $(mask);
      var slides = $$(slides);
      var link = $$(link);
      
      var moreInfo = new SimpleImageSlideShow({
         startIndex: 0,
         slides: link,
         nextLink: 'next',
         prevLink: 'prev'
       });
      
    
      if($defined(mask)) {
        var watches = new SimpleImageSlideShow.Carousel(mask, {
          startIndex: 0,
          slides: slides,
          nextLink: 'next',
          prevLink: 'prev',
          currentIndexContainer: 'count',
          maxContainer: 'max',
          onNext: function () {
            var slideCount = $('count').get('text').toInt() + 1;
            var indicators = $$('#indicator li');
    
            indicators.removeClass('on');
            indicators[slideCount].addClass('on');
          },
          onPrev: function() {
            var slideCount = $('count').get('text').toInt() + 1;
            var indicators = $$('#indicator li');
    
            indicators.removeClass('on');
            indicators[slideCount].addClass('on');
          }
        });
      }
    }


/*  Function: featuredSwf
    -----------------------------------------------  */
    // Refresh Token
    var token_pool = 'abcdefghijklmnopqrstuvwxyz0123456789';
    var token = "";
      while (token.length < 8) {
        token += token_pool.charAt(Math.floor(Math.random()*token_pool.length));
      };
    
    var featuredSwf = new Swiff('/static/images/flash/flash_slideshow.swf?' + token, {
        id: 'splash',
        width: '100%',
        height: '485',
        style: 'visibility: visible',
        container: $('flash-auction'),
            params: {
                bgcolor: '#000000',
                allowScriptAccess: 'always',
                quality: 'high',
                wMode: 'transparent',
                scale: 'noscale',
                menu: 'false',
                swLiveConnect: 'false'
            },
            vars: {
				XML_PATH: '/featured.xml'
            }
        });
     
    var newsletter = new InfoModule();

/*  Ready 
    -----------------------------------------------  */
    window.addEvent('domready', function() {
        watchSlideshow('mask', '#mask a.slides', '#featured-news a');
      	($chk($('flash-auction'))) ? featuredSwf.replaces($('flash-auction')) : '';
        insertVisual('#seconday-content', 'top', 'span', 'shadow');
        newsletter.init('newsletter','#newsletter-link');
    });