Javascript + jQuery Game Using Arrays (Number And Image)
<p>Sorry for my not very clear title. I was wandering if someone could help me. I am making a game and I want to make an array holding a number (tells you how much something is worth in credits) and also there is an image (to show the thing you are buying). I am putting all of these arrays into a slider so players can see the different items they can buy and here is what I have done so far. The website of my project is: theassets.staticloud.com
This is just something I knocked up to show you the basic idea of what I am doing:</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
     &lt;title&gt;Test&lt;/title&gt;
     &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"&gt;&lt;/script&gt;
     &lt;script type="text/javascript"&gt;
var island = new Array();
island[0] = 7000;
island[1] = $islandimg;
     &lt;/script&gt;
     &lt;/head&gt;
     &lt;body&gt;
          &lt;img src="http://avatarmaker.net/free-avatars/avatars/nature_217/scenery_275/moorea_island_avatar_100x100_83622.jpg" id="islandimg"&gt;
          &lt;body&gt;

&lt;/html&gt;
</code></pre>

<p>This is what I am working on:</p>

<pre><code>&lt;!doctype html&gt;

&lt;html lang="en"&gt;
&lt;body bgcolor="black"&gt;
&lt;head&gt;
    &lt;meta charset="utf-8" /&gt;
    &lt;title&gt;jQuery UI Slider - Slider scrollbar&lt;/title&gt;
&lt;center&gt;
&lt;img src="theassetsimg.png"&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;center&gt;&lt;table&gt;
&lt;tr&gt;&lt;td&gt;&lt;img src="cooltext819230394.png" onmouseover="this.src='cooltext819230394MouseOver.png';" onmouseout="this.src='cooltext819230394.png';" /&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src="cooltext819231213.png" onmouseover="this.src='cooltext819231213MouseOver.png';" onmouseout="this.src='cooltext819231213.png';" /&gt;&lt;a&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src="cooltext819232096.png" onmouseover="this.src='cooltext819232096MouseOver.png';" onmouseout="this.src='cooltext819232096.png';" /&gt;&lt;a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;/center&gt;
&lt;/center&gt;    
&lt;link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" /&gt;
    &lt;script src="http://code.jquery.com/jquery-1.8.2.js"&gt;&lt;/script&gt;
    &lt;script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"&gt;&lt;/script&gt;
    &lt;link rel="stylesheet" href="/resources/demos/style.css" /&gt;
    &lt;style&gt;
    .scroll-pane { overflow: auto; width: 99%; float:left; }
    .scroll-content { width: 2440px; float: left; }
    .scroll-content-item { width: 100px; height: 100px; float: left; margin: 10px; font-size: 3em; line-height: 96px; text-align: center; }
    * html .scroll-content-item { display: inline; } /* IE6 float double margin bug */
    .scroll-bar-wrap { clear: left; padding: 0 4px 0 2px; margin: 0 -1px -1px -1px; }
    .scroll-bar-wrap .ui-slider { background: none; border:0; height: 2em; margin: 0 auto;  }
    .scroll-bar-wrap .ui-handle-helper-parent { position: relative; width: 100%; height: 100%; margin: 0 auto; }
    .scroll-bar-wrap .ui-slider-handle { top:.2em; height: 1.5em; }
    .scroll-bar-wrap .ui-slider-handle .ui-icon { margin: -8px auto 0; position: relative; top: 50%; }
    &lt;/style&gt;
    &lt;script&gt;
    $(function() {
        //scrollpane parts
        var scrollPane = $( ".scroll-pane" ),
            scrollContent = $( ".scroll-content" );

        //build slider
        var scrollbar = $( ".scroll-bar" ).slider({
            slide: function( event, ui ) {
                if ( scrollContent.width() &gt; scrollPane.width() ) {
                    scrollContent.css( "margin-left", Math.round(
                        ui.value / 100 * ( scrollPane.width() - scrollContent.width() )
                    ) + "px" );
                } else {
                    scrollContent.css( "margin-left", 0 );
                }
            }
        });

        //append icon to handle
        var handleHelper = scrollbar.find( ".ui-slider-handle" )
        .mousedown(function() {
            scrollbar.width( handleHelper.width() );
        })
        .mouseup(function() {
            scrollbar.width( "100%" );
        })
        .append( "&lt;span class='ui-icon ui-icon-grip-dotted-vertical'&gt;&lt;/span&gt;" )
        .wrap( "&lt;div class='ui-handle-helper-parent'&gt;&lt;/div&gt;" ).parent();

        //change overflow to hidden now that slider handles the scrolling
        scrollPane.css( "overflow", "hidden" );

        //size scrollbar and handle proportionally to scroll distance
        function sizeScrollbar() {
            var remainder = scrollContent.width() - scrollPane.width();
            var proportion = remainder / scrollContent.width();
            var handleSize = scrollPane.width() - ( proportion * scrollPane.width() );
            scrollbar.find( ".ui-slider-handle" ).css({
                width: handleSize,
                "margin-left": -handleSize / 2
            });
            handleHelper.width( "" ).width( scrollbar.width() - handleSize );
        }

        //reset slider value based on scroll content position
        function resetValue() {
            var remainder = scrollPane.width() - scrollContent.width();
            var leftVal = scrollContent.css( "margin-left" ) === "auto" ? 0 :
                parseInt( scrollContent.css( "margin-left" ) );
            var percentage = Math.round( leftVal / remainder * 100 );
            scrollbar.slider( "value", percentage );
        }

        //if the slider is 100% and window gets larger, reveal content
        function reflowContent() {
                var showing = scrollContent.width() + parseInt( scrollContent.css( "margin-left" ), 10 );
                var gap = scrollPane.width() - showing;
                if ( gap &gt; 0 ) {
                    scrollContent.css( "margin-left", parseInt( scrollContent.css( "margin-left" ), 10 ) + gap );
                }
        }

        //change handle position on window resize
        $( window ).resize(function() {
            resetValue();
            sizeScrollbar();
            reflowContent();
        });
        //init scrollbar size
        setTimeout( sizeScrollbar, 10 );//safari wants a timeout
    });
    &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;div class="scroll-pane ui-widget ui-widget-header ui-corner-all"&gt;
    &lt;div class="scroll-content"&gt;
        &lt;div class="scroll-content-item ui-widget-header"&gt;&lt;img src="http://avatarmaker.net/free-avatars/avatars/nature_217/scenery_275/moorea_island_avatar_100x100_83622.jpg" id=""&gt;&lt;/div&gt;
        &lt;div class="scroll-content-item ui-widget-header"&gt;&lt;img src="http://i31.twenga.com/jewellery/watch/nixon-watches-all-gold-tp_531465411970057721.jpg"&gt;&lt;/div&gt;
        &lt;div class="scroll-content-item ui-widget-header"&gt;&lt;img src="http://www.glitteringstones.com/Images/bluediamond.gif"&gt;&lt;/div&gt;
        &lt;div class="scroll-content-item ui-widget-header"&gt;&lt;img src="http://www.rac.co.uk/images/tiles/car-driving.aspx"&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="scroll-bar-wrap ui-widget-content ui-corner-bottom"&gt;
        &lt;div class="scroll-bar"&gt;&lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


&lt;/body&gt;
&lt;/html&gt;
</code></pre>
