/*******************************************************************************

  CSS on Sails Framework
  Title: Site Name
  Author: XHTMLized (http://www.xhtmlized.com/)
  Date: May 2010

*******************************************************************************/

function fixPNG() {
  var PNG_fix_selectors = [
    '#nav li',
    '#nav a',
	'#quickview .about',
	'#quickview .testimonials',
	'#quickview .testimonials .next',
	'#quickview .testimonials .prev',
	'#quickview .testimonials .nav a',
	'#quicklinks h3',
	'#quicklinks a',
	'#clients img'
  ];

  if (typeof DD_belatedPNG !== 'undefined') {
    DD_belatedPNG.fix(PNG_fix_selectors.join(','));
  }
}
fixPNG();

var Testimonials = (
  function () {
    var self = {

      elm: null,

      init: function () {
        self.elm  = $('#quickview .testimonials');
        if (self.elm.size() == 0) return;

        self.elm.append('<div id="testimonials-nav" class="nav"></div>');
        self.elm.append('<span class="next">Next</span><span class="prev">Prev</span>');

        self.elm.find('.next').click(self.handleNextClick);
        self.elm.find('.prev').click(self.handlePrevClick);

        self.prepare();
      },

      prepare: function () {
        self.elm.find('.items').cycle({
          'fx':        'fade',
          'timeout':    5000,
          'speed':      600,
          'fastOnEvent':  300,
          'autostopCount':     10000,
          'pause':      1,
          'height':      295,
          'pager':      '#testimonials-nav'
        });

		var nav = $('#testimonials-nav');
		nav.css('left', (300 - nav.width())/2 + 11);
      },

      handleNextClick: function () {
        self.elm.find('.items').cycle('next');
      },

      handlePrevClick: function () {
        self.elm.find('.items').cycle('prev');
      }
    };

    return self;
  }
)();


$(document).ready(function(){
  Testimonials.init();
})


