// system scripts
"use strict";

$.fx.speeds._default = 200;

var View = {

  mode: undefined,

  display: function (results) {
    if ($(".results").is(":visible")) {
      $(".results").fadeOut(function () {
        $(".results").html(results);
      });
      $(".results").fadeIn();
      /*
      if () { //this is for shit that needs to fade in or out when you're switching modes
        $(".options").slideUp(function () {});
        $(".options").slideDown();
      }
      */
    } else {
      $("#welcome").slideUp(function () {
        $(".results").html(results);
        $(".results, .reload-button, .options").slideDown();
      });
    }
    if (View.mode === "from_list" || View.mode === "sort_list") {
      $(".options-header").slideDown();
      $(".number-options").slideUp(function () {
        $(".list-options").slideDown();
      });
    } else if (View.mode === "number") {
      $(".options-header").slideDown();
      $(".list-options").slideUp(function () {
        $(".number-options").slideDown();
      });
    } else {
      $(".list-options, .number-options, .options-header").slideUp();
    }
  },

  reload: function () {
    Tools[View.mode]();
  },

  preload: function () {
    var to_preload = [], i, preload_html = "", preload_size;
    // coins
    to_preload.push("images/coins/coin_heads.png");
    to_preload.push("images/coins/coin_tails.png");
    // dice
    for (i = 1; i <= 6; i++) { to_preload.push("images/dice/die_" + i + ".png"); }
    // cards
    for (i = 1; i <= 13; i++) { to_preload.push("images/cards/c" + i + ".png"); }
    for (i = 1; i <= 13; i++) { to_preload.push("images/cards/d" + i + ".png"); }
    for (i = 1; i <= 13; i++) { to_preload.push("images/cards/h" + i + ".png"); }
    for (i = 1; i <= 13; i++) { to_preload.push("images/cards/s" + i + ".png"); }
    to_preload.push("images/cards/jb.png");
    to_preload.push("images/cards/jr.png");

    // load stuff!
    preload_size = to_preload.length;
    for (i = 0; i < preload_size; i++) {
      preload_html += "<img src='" + to_preload.shift() + "'>";
    }
    $("<div id='preloader'></div>").appendTo("body").hide().html(preload_html);
  }

};

$(function ($) {
  // buttons
  $("#dice-button").click(Tools.die);
  $("#coins-button").click(Tools.coin);
  $("#card-button").click(Tools.card);
  $("#numbers-button").click(Tools.number);
  $("#from-list-button").click(Tools.from_list);
  $("#sort-list-button").click(Tools.sort_list);
  $(".reload-button").click(View.reload);

  // preload
  View.preload();
});

@@ -2157,16 +2157,124 @@
 _html);%0A
+  %7D,%0A%0A  setBinds: function (binds) %7B%0A    $.each(binds, function (el, fun) %7B%0A      $(el).click(fun);%0A    %7D);%0A
   %7D%0A%0A%7D;%0A
@@ -2306,18 +2306,36 @@
 ttons%0A  
-$(
+View.setBinds(%7B%0A    
 %22#dice-b
@@ -2336,32 +2336,31 @@
 dice-button%22
-).click(
+:      
 Tools.die);%0A
@@ -2356,23 +2356,22 @@
 ools.die
-);%0A  $(
+,%0A    
 %22#coins-
@@ -2373,32 +2373,30 @@
 oins-button%22
-).click(
+:     
 Tools.coin);
@@ -2393,23 +2393,22 @@
 ols.coin
-);%0A  $(
+,%0A    
 %22#card-b
@@ -2409,32 +2409,31 @@
 card-button%22
-).click(
+:      
 Tools.card);
@@ -2430,23 +2430,22 @@
 ols.card
-);%0A  $(
+,%0A    
 %22#number
@@ -2449,32 +2449,28 @@
 bers-button%22
-).click(
+:   
 Tools.number
@@ -2469,23 +2469,22 @@
 s.number
-);%0A  $(
+,%0A    
 %22#from-l
@@ -2490,32 +2490,26 @@
 list-button%22
-).click(
+: 
 Tools.from_l
@@ -2511,23 +2511,22 @@
 rom_list
-);%0A  $(
+,%0A    
 %22#sort-l
@@ -2536,24 +2536,18 @@
 -button%22
-).click(
+: 
 Tools.so
@@ -2557,15 +2557,14 @@
 list
-);%0A  $(
+,%0A    
 %22.re
@@ -2575,24 +2575,21 @@
 -button%22
-).click(
+:    
 View.rel
@@ -2591,16 +2591,20 @@
 w.reload
+%0A  %7D
 );%0A%0A  //

Add View.setBinds()