﻿
var Input = {
        initialize: function() 
        {
            if(document.getElementsByTagName("form")){
            var divs = document.getElementsByTagName("div");
                for(var i = 0; i < divs.length; i++){
                        if(divs[i].className.match("checkbox")) {
                            divs[i].onmousedown = Input.handle;
                            window.onmouseup = Input.clear;
                        }
                }
            }
        },

        handle: function() 
        {
            selector = this.getElementsByTagName("input")[0];
            
             if(this.className == "checkbox") {
               selector.checked = true;
               this.className = "checkbox selected";
              this.style.backgroundPosition = "0px 0px";
            }
            
            else if(this.className == "checkbox selected") {
             selector.checked = false;
              this.className = "checkbox";
              this.style.backgroundPosition = "0px -18px";
            } 
         },
  
     clear: function() {
       divs = document.getElementsByTagName("div");
       for(var i = 0; i < divs.length; i++) {
         if(divs[i].className == "checkbox") {
           divs[i].style.backgroundPosition = "0px 0px";
            } 
         else if(divs[i].className == "checkbox selected") {
           divs[i].style.backgroundPosition = "0px -18px";
            }
       }
     }
     
   }
   
   window.onload = Input.initialize;



