
        $(document).ready(function() {
            ITS.category = Math.floor(Math.random() * 1);
            ITS.changeCategory();
            ITS.toggleStoryControls();

            //set effect from select menu value
            $("#NextButton").click(function() {
                if (ITS.scrollPosition < (ITS.storyCount - 4)) {
                    $('.Link').animate({ "left": '-=186px' }, 400);
                    ITS.scrollPosition++;
                }
                ITS.toggleStoryControls();
                return false;
            });

            //set effect from select menu value
            $("#PrevButton").click(function() {
                if (ITS.scrollPosition > 0) {
                    $('.Link').animate({ "left": '+=186px' }, 400);
                    ITS.scrollPosition--;
                }
                ITS.toggleStoryControls();
                return false;
            });

            //set effect from select menu value
            $('.Link').click(function() {
                $('div.Link.Selected').removeClass('Selected');
                var parent = $(this).parent();
                var children = $(parent).children();
                var i;
                for (i = 0; i < children.length && this != children[i]; i++);
                $('div#ImageContainer > div > img').css('display', 'none');
                $('div#ImageContainer > div > img:nth-child(' + (i + 1) + ')').css('display', 'block');
                $('div#StoryContainer > div:nth-child(' + (ITS.category + 1) + ') > div').css('display', 'none');
                $('div#StoryContainer > div:nth-child(' + (ITS.category + 1) + ') > div:nth-child(' + (i + 1) + ')').css('display', 'block');
                $(this).addClass('Selected');
                return false;
            });

            $('#Categories a').click(function() {
                var parent = $(this).parent();
                var children = $(parent).children();

                var i;
                for (i = 0; i < children.length && this != children[i]; i++);
                ITS.category = i;
                ITS.changeCategory();
                ITS.toggleStoryControls();

                return false;
            });
        });


        var ITS = function() {
            return {
                categories: new Array('Portfolio Projects'),
                category: 0,
                scrollPosition: 0,
                storyCount: 6,
                changeCategory: function() {
                    $('div#Categories a.Selected').removeClass('Selected');
                    $('div#StoryLinksContainer > div').css('display', 'none');
                    $('div#StoryLinksContainer > div:nth-child(' + (ITS.category + 1) + ')').css('display', 'block');
                    ITS.storyCount = $('div#StoryLinksContainer > div:nth-child(' + (ITS.category + 1) + ')').children().length;
                    $('.Link').css('left', -(ITS.storyCount * 186) + "px");
                    $('div#StoryContainer > div').css('display', 'none');
                    $('div#StoryContainer > div:nth-child(' + (ITS.category + 1) + ')').css('display', 'block');
                    $('div#StoryContainer > div:nth-child(' + (ITS.category + 1) + ') > div').css('display', 'none');
                    $('div#StoryContainer > div:nth-child(' + (ITS.category + 1) + ') > div:nth-child(1)').css('display', 'block');

                    //show story
                    $('div#ImageContainer > div').css('display', 'none');
                    $('div#ImageContainer > div:nth-child(' + (ITS.category + 1) + ')').css('display', 'block');
                    $('div#ImageContainer > div:nth-child(' + (ITS.category + 1) + ') > img').css('display', 'none');
                    $('div#ImageContainer > div:nth-child(' + (ITS.category + 1) + ') > img:nth-child(1)').css('display', 'block');

                    $('.Link').animate({ "left": '0px' }, 400);
                    ITS.scrollPosition = 0;
                    $('div.Link').removeClass('Selected');
                    $('div.Link:nth-child(1)').addClass('Selected');
                    $('div#Categories a:nth-child(' + (ITS.category + 1) + ')').addClass('Selected');
                },
                toggleStoryControls: function() {
                    if (ITS.scrollPosition > 0) {
                        $('a#PrevButton').css('display', 'block');
                    }
                    else {
                        $('a#PrevButton').css('display', 'none');
                    }

                    if (ITS.scrollPosition < (ITS.storyCount - 4)) {
                        $('a#NextButton').css('display', 'block');
                    }
                    else {
                        $('a#NextButton').css('display', 'none');
                    }
                }
            };
        } ();

 