﻿// JScript File
  // Build an empty URL structure in which we will store
        // the individual query values by key.
        var QueryString = new Object();
        // Use the String::replace method to iterate over each
        // name-value pair in the query string. Location.search
        // gives us the query string (if it exists).
        window.location.search.replace(
           new RegExp( "([^?=&]+)(=([^&]*))?", "g" ), 
           function( $0, $1, $2, $3 ){QueryString[ $1 ] = $3;});
        //Variable declarations for image gallery
        var t;
        var position = 1;
        var videoCollection;
        var currentPositionText;
        
        
        //Core Image gallery functionality methods
        //Function for changing the main Image source
        function changeVideo(src)
        {
           document.getElementById("largeImg").src = src;
        }
        
        
        //Function for changing the main image source and setting the current position
        function changeVideoWithPos(src, pos, teaser, title)
        {
           document.getElementById("summarytitle").innerHTML = title;
           document.getElementById("summarytext").innerHTML = teaser;
            position = pos;

            changeVideo(src);

            clearInterval(t);
        }
        
        
        //Function for changing the main image source based on array position
        function changeVideoByPos(pos)
        {
            if(pos > 0)
            {
                if(videoCollection == null)
                {
                    videoCollection = document.getElementById("smallvideo").getElementsByTagName("img");
                }
                document.getElementById("summarytext").innerHTML = videoCollection[(pos-1)].getAttribute('alt');
                changeVideo(videoCollection[(pos-1)].getAttribute('large'));
            }
        }
        
        
        //Function for changing the main image to the previous image based on the array position
        function changePrevVideo()
        {
           changeVideoByPos(position);
            if(videoCollection.length > 0)
            {
                if((position-1) > 0)
                {
                    position -= 1;
                }
                else
                {
                    
                }
            }
        }
        
        
        //Function for changing the main image to the previous image based on the array position
        function changeNextVideo()
        {
            changeVideoByPos(position);
            if(videoCollection.length > 0)
            {
                if((position+1) <= videoCollection.length)
                {
                    position += 1;
                }
                else
                {
                    position = videoCollection.length;
                }
            }
        }
