
/*if (window.onload) {
    var _previousOnload = window.onload;
}
// Define the new window.onload
window.onload = function(evt) {
    // execute a previous window.onload if it exists
    if (_previousOnload) {
        _previousOnload.call(this, evt);
    }*/
    $(document).ready(function(){ 
// put your custom jScript here - will execute on completion of DOM load	    

// 1. create scroll effect
// 2. handle the selection of the navigation
var $panels = $('#slider .panel');
var $container = $('#slider .scrollContainer');
var $scroll = $('#slider .scroll').css('overflow', 'hidden');


$('#slider .navigation a').click(selectNav);

function selectNav() {
	$(this)
		.parents('ol:first')
			.find('a')
				.removeClass('selected')
				.end()
			.end()

    .addClass('selected'); 
    
    }
    
    var scrollOptions = 
    {
    
    target: $scroll,
    items: $panels,
    navigation: '.navigation a',
	axis: 'y',
	duration: 500,
	easing: 'swing'
    
    };
    
   
    
      // apply serialScroll to the slider - we chose this plugin because it 
    // supports// the indexed next and previous scroll along with hooking 
    // in to our navigation.
    $('#slider').serialScroll(scrollOptions);

    // now apply localScroll to hook any other arbitrary links to trigger 
    // the effect
    // $.localScroll(scrollOptions);

    // finally, if the URL has a hash, move the slider in to position, 
    // setting the duration to 1 because I don't want it to scroll in the
    // very first page load.  We don't always need this, but it ensures
    // the positioning is absolutely spot on when the pages loads.
    scrollOptions.duration = 1;
    $.localScroll.hash(scrollOptions);
    
// autoscroll

// start to automatically cycle the tabs
   cycleTimer = setInterval(function () {
   $scroll.trigger('next');
}, 5000);  // how many milliseconds, change this to whatever you like

// select some trigger elements to stop the auto-cycle
var $stopTriggers = $('#slider .navigation').find('a')    
    .add('.scroll')                    
    .add('.stopscroll')             // links to the stop class div
    .add('.navigation')          // links to navigation id for tabs
    .add("a[href='#']");      // links to a tab

// this is the function that will stop the auto-cycle
function stopCycle() {
   // remove the no longer needed stop triggers
   clearInterval(cycleTimer);          // stop the auto-cycle itself
   $buttons.show();                           // show the navigation buttons
   document.getElementById('stopscroll').style.display='none';    // hide the stop div
   document.getElementById('startscroll').style.display='block';  // block the start div
}

// bind stop cycle function to the click event using namespaces
$stopTriggers.bind('click.cycle', stopCycle);


// end autoscroll

// select some trigger elements to stop the auto-cycle

var $startTriggers_start = $('#slider .navigation').find('a') // tab headers
    .add('.startscroll');               // links to the start class div

// this is the function that will stop the auto-cycle
function startCycle() {
   // remove the no longer needed stop triggers
   $buttons.hide();                    // show the navigation buttons
   $scroll.trigger('next');          // directly to the next first
   cycleTimer = setInterval(function () {         // now set timer again
   $scroll.trigger('next');
   }, 5000);  // how many milliseconds, change this to whatever you like
   document.getElementById('stopscroll').style.display='block';  // block the stop div
   document.getElementById('startscroll').style.display='none';  // hide the start div
}

// bind stop cycle function to the click event using namespaces
$startTriggers_start.bind('click.cycle', startCycle);

    });


