var myrules = {
    /*'li.track' : function(element){
      element.onclick = function(){
        if(bTrackOpen != 'true') {
          setObjDisplay(returnObjById('trackCitationsContainer'),'block');
          var bTrackOpen = 'true';
          } else setObjDisplay(returnObjById('trackCitationsContainer'),'none');
      }
    }*/
    'div.productOption' : function(element){
      element.onclick = function(){
          var arrSelectedProds = document.getElementsByClassName('productOptionSelected',this.parentNode);
        for(i=0;i < arrSelectedProds.length;i++) {
            arrSelectedProds[i].className = 'productOption';
        }
        this.className = '';
        this.className = 'productOptionSelected';
        var crawlBack = getPreviousSibling(this.parentNode);
        document.getElementsByClassName('optionName',crawlBack)[0].innerHTML = this.title;
        this.getElementsByTagName('input')[0].checked = true;


        if(ArrayNodesSelected.length == 0) {
            ArrayNodesSelected.push(this.parentNode.id);
            selectedProductOptions++;
        } else if (ArrayNodesSelected.length > 0) {
                var stringifiedNodeArray = ArrayNodesSelected.toString();
                if(stringifiedNodeArray.indexOf(this.parentNode.id) == -1) {
                  ArrayNodesSelected.push(this.parentNode.id);
                  selectedProductOptions++;
                }
            }

        if (selectedProductOptions == numProdOptions) {
              returnObjById('button_addToCart').removeClassName('disabled');
          }

          /*I recommend using AJAX for this by creating an action at the BE that does whatever business logic you need
          and then returns formatted HTML for you to use in the "product includes" list update. Another option might be
          JSON. */



      }
      element.onmouseover = function(){
          if (this.className.indexOf('Selected') == -1) {
            this.className = 'productOptionHover';
        }
      },
      element.onmouseout = function(){
        if (this.className.indexOf('Selected') == -1) {
            this.className = 'productOption';
        }
      }
    },
    '#navHome' : function(element){
      element.onmouseover = function(){
          if(this.className != "activeNav") {
            setImgSrc(this,'media/SchoolHouse/images/background/lfsh_nav_home_on.gif');
        }
      },
      element.onmouseout = function(){
          if(this.className != "activeNav") {
            setImgSrc(this,'media/SchoolHouse/images/background/lfsh_nav_home.gif');
        }
      }
    },
    '#navClassroomProducts' : function(element){
      element.onmouseover = function(){
          if(this.className != "activeNav") {
            setImgSrc(this,'media/SchoolHouse/images/background/lfsh_nav_classroomProd_on.gif');
        }
      },
      element.onmouseout = function(){
          if(this.className != "activeNav") {
            setImgSrc(this,'media/SchoolHouse/images/background/lfsh_nav_classroomProd.gif');
        }
      }
    },
    '#navStore' : function(element){
      element.onmouseover = function(){
          if(this.className != "activeNav") {
            setImgSrc(this,'media/SchoolHouse/images/background/lfsh_nav_store_on.gif');
        }
      },
      element.onmouseout = function(){
          if(this.className != "activeNav") {
            setImgSrc(this,'media/SchoolHouse/images/background/lfsh_nav_store.gif');
        }
      }
    },
    '#navResources' : function(element){
      element.onmouseover = function(){
          if(this.className != "activeNav") {
            setImgSrc(this,'media/SchoolHouse/images/background/lfsh_nav_resources_on.gif');
        }
      },
      element.onmouseout = function(){
          if(this.className != "activeNav") {
            setImgSrc(this,'media/SchoolHouse/images/background/lfsh_nav_resources.gif');
        }
      }
    },
    '#navAboutUs' : function(element){
      element.onmouseover = function(){
          if(this.className != "activeNav") {
            setImgSrc(this,'media/SchoolHouse/images/background/lfsh_nav_about_on.gif');
        }
      },
      element.onmouseout = function(){
          if(this.className != "activeNav") {
            setImgSrc(this,'media/SchoolHouse/images/background/lfsh_nav_about.gif');
        }
      }
    },
    '#navSupport' : function(element){
      element.onmouseover = function(){
          if(this.className != "activeNav") {
            setImgSrc(this,'media/SchoolHouse/images/background/lfsh_nav_support_on.gif');
        }
      },
      element.onmouseout = function(){
          if(this.className != "activeNav") {
            setImgSrc(this,'media/SchoolHouse/images/background/lfsh_nav_support.gif');
        }
      }
    },
    'div.productOptionSelected' : function(element){
      element.onmouseover = function(){
        //this.className = 'productOptionSelected';
      },
      element.onmouseout = function(){
        if (this.className.indexOf('Selected') == -1) {
            this.className = 'productOption';
        }
      }
    },
    '#useBillingAddress' : function(element){
      element.onclick = function(){
        if(element.checked){
          if (returnObjById('billingFirstName').value != '') {
            returnObjById('shippingFirstName').value = returnObjById('billingFirstName').value;
          } else {
            returnObjById('shippingFirstName').value = '';
          }
          if (returnObjById('billingLastName').value != '') {
            returnObjById('shippingLastName').value = returnObjById('billingLastName').value;
          } else {
            returnObjById('shippingLastName').value = '';
          }
          if (returnObjById('billingAddress1').value != '') {
            returnObjById('shippingAddress1').value = returnObjById('billingAddress1').value;
          } else {
            returnObjById('shippingAddress1').value = '';
          }
          if (returnObjById('billingAddress2').value != '') {
            returnObjById('shippingAddress2').value = returnObjById('billingAddress2').value;
          } else {
            returnObjById('shippingAddress2').value = '';
          }
          if (returnObjById('billingCity').value != '') {
            returnObjById('shippingCity').value = returnObjById('billingCity').value;
          } else {
            returnObjById('shippingCity').value = '';
          }
          if (returnObjById('billingState').value != '') {
            returnObjById('shippingState').value = returnObjById('billingState').value;
          } else {
            returnObjById('shippingState').value = '';
          }
          if (returnObjById('billingZip').value != '') {
            returnObjById('shippingZip').value = returnObjById('billingZip').value;
          } else {
            returnObjById('shippingZip').value = '';
          }
          if (returnObjById('billingDaytimePhone').value != '') {
            returnObjById('shippingDaytimePhone').value = returnObjById('billingDaytimePhone').value;
          } else {
            returnObjById('shippingDaytimePhone').value = '';
          }
        }
      }
    }
  };

Behaviour.register(myrules);



