var totalText = 6;
var currentText = 1;

function swapHeroText() {
    $('.hero-copy .text-' + currentText).fadeOut(1000);
    currentText = (currentText >= totalText ) ? 1 : currentText + 1;
    $('.hero-copy .text-' + currentText).fadeIn(0);
  }
	

$(document).ready(function() {

    
    $('#pdf-table tr:even').addClass('even');
    $('#sidebar ul li a span').hide();

	setTimeout(function() {
    $('#hero-image-stairs').crossSlide({
	  fade: 1
	}, [
	  { src: 'assets/images/hero-stair-1.jpg', from: '100% 100% 1x', to: '100% 20% 1x', time: 5  },
	  { src: 'assets/images/hero-stair-2.jpg',  from: '100% 100% 1x', to: '100% 20% 1x', time: 5  },
	  { src: 'assets/images/hero-iron-collection.jpg', from: '100% 100% 1x', to: '100% 20% 1x', time: 5 },
	  { src: 'assets/images/hero-box-newels.jpg', from: '100% 100% 1x', to: '100% 20% 1x', time: 5 },
	  { src: 'assets/images/hero-spiral-stairs.jpg', from: '20% 50% 1x', to: '100% 50% 1x', time: 5 },
	  { src: 'assets/images/hero-custom.jpg', from: '100% 50% 1x', to: '20% 50% 1x', time: 5 }
	])
}, 2000);

setTimeout(function() {window.setInterval('swapHeroText();', 6100)}, 3000);

  $('.tin-btn').click(function() {
      window.open('/stairbuilder.aspx','L.J. Smith Interactive Stair Builder','width=980, scrollbars=yes');
      return false;
    });

$(function(){
  var div = $('div.timeline'),
               ul = $('.timeline ul'),
               // unordered list's left margin
               ulPadding = 15;
		  var divWidth = div.width();
		  div.css({overflow: 'hidden'});
			  var lastLi = ul.find('li:last-child');
			  div.mousemove(function(e){
			    var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;
			    var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
		    div.scrollLeft(left);
		  });
		});

$(function() {
  $('#photo-gallery li a').lightBox();
  });

$('#showfalsetreadinstallation').click(function() {
    $('.false-tread-click-list').slideDown('fast');
    return false;
    });

var numberOfItemsInHScroll = $('#newel-scroll ul').size();
var numberOfNewelsInHScroll = $('.newel-scroll ul li').size();
var numberOfHandrailsInHScroll = $('.handrail-scroll ul li').size();
var hScrollWidth = numberOfItemsInHScroll * 8;
var hScrollWidthNewels = numberOfNewelsInHScroll * 5;
var hScrollWidthHandrails = numberOfHandrailsInHScroll * 9;
$('#newel-scroll').css('width', hScrollWidth + '0px');
$('.newel-scroll').css('width', hScrollWidthNewels + '0px');
$('.handrail-scroll').css('width', hScrollWidthHandrails + '0px');


$('#accept-agreement').toggle(function() {
    $(this).addClass('agreement-accepted');
    $(this).removeClass('agreement-not-accepted');
    $('#ctl00_ContentPlaceHolder_Main_FormView1_InsertButton').addClass('signup-on');
    $('#ctl00_ContentPlaceHolder_Main_FormView1_InsertButton').removeClass('signup-off');
    return false;
    },

    function() {
    $(this).addClass('agreement-not-accepted');
    $(this).removeClass('agreement-accepted');
    $('#ctl00_ContentPlaceHolder_Main_FormView1_InsertButton').removeClass('signup-on');
    $('#ctl00_ContentPlaceHolder_Main_FormView1_InsertButton').addClass('signup-off');
    return false;
    });
                    
var numberOfItemsInHScroll = $('.wood-types img').size();
var numberOfNewelsProducts = $('.related-newels-list li img').size();
var numberOfHandrailsProducts = $('.handrail-scroll li img').size();
var hNewelScrollWidth = numberOfNewelsProducts * 2;
var hHandrailScrollWidth = numberOfNewelsProducts * 2;
var hScrollWidth = numberOfItemsInHScroll * 7;
$('.wood-types').css('width', hScrollWidth + '0px');
$('.related-newels-list').css('width', '3' + hNewelScrollWidth + 'px');
$('.related-handrails-list').css('width', hHandrailScrollWidth + '0px');



});


