﻿// JScript File

$(document).ready(function() {

    var horizontal = true;

    var $panels = $('#slider .panel');

    var $container = $('#slider .scrollContainer');

    var $scroll = $('#slider .scroll').css('overflow', 'hidden');

    

    $scroll

        .before('<img src="media/images/btn_back.png" class="scrollButtons left" />')

        .after('<img src="media/images/btn_next.png" class="scrollButtons right" />')

        

        var scrollOptions = {

        target: $scroll,

        items: $panels,

        navigation: '.navigation a',

        prev: 'img.left',

        next: 'img.right',

        axis: 'xy',

        duration: 500,

        easing: 'swing'
		
        };

        

        //Make the panels move left to right

        if (horizontal) {

            $panels.css({

                'float' : 'left',

                'position' : 'relative'

            });

            

            $container.css('width', $panels[0].offsetWidth * $panels.length);

        }

        

        function trigger(data) {

            var el = $('#slider .navigation').find('a[href$="' + data.id + '"]').get(0);

            selectNav.call(el);

        }

        if (window.location.hash) {

            trigger({ id: window.location.hash.sbstr(1)});

        } else {

            $('#slider .navigation a:first').click();

        }

        

        $('#slider').serialScroll(scrollOptions);

        $.localScroll(scrollOptions);

        

        //FOR HOME PAGE ONLY

        if ((document.location.href.toLowerCase().indexOf("index.php") >= 0) || (document.location.href.toLowerCase().indexOf(".php") == -1)) {

				// first hide the navigation buttons

                var $buttons = $('img.right').add('img.left').hide();



                // start to automatically cycle the tabs

                var cycleTimer = setInterval(function () {

                   $scroll.trigger('next');

                }, 8000);



                var $transitionStyle = $scroll.fadeIn("slow",function(){

                 // alert("Animation Done.");

                });

                

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

                var $stopTriggers = $('#slider .navigation').find('a') // tab headers

                    .add('.scroll')                                     // panel itself

                    .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

                   $stopTriggers.unbind('click.cycle');

                   clearInterval(cycleTimer);          // stop the auto-cycle itself

                   $buttons.show();                       // show the navigation buttons

        }





        // bind stop cycle function to the click event using namespaces

        $stopTriggers.bind('click.cycle', stopCycle);

        

        

				//

			}

});




