//*********************************************************************************************
//
// Coded by Artis Co.,Ltd.
// http://www.artisj.com
// If you want to use this code, feel free to do so, however; please leave this message intact.
// Copyright(C) Artis Co.,Ltd. All rights reserved.
//
//*********************************************************************************************


// window.onload = function tN(){
//
// function Focus(){
//  this.style.backgroundColor="#F0F7FF";
// }
//
// function Blur(){
//  this.style.backgroundColor="#FFFFFF";
// }
//
// var n=document.forms[0].elements.length;
//
// for(i=0;i<n;i++){
//  if(document.forms[0].elements[i].type != "submit"){
//      if(document.forms[0].elements[i].type != "checkbox"){
//          if(document.forms[0].elements[i].type != "radio"){
//              if(document.forms[0].elements[i].type != "button"){
//                  document.forms[0].elements[i].onfocus = Focus;
//                  document.forms[0].elements[i].onblur = Blur;
//              }
//          }
//      }
//  }
// }
//
// }

window.onload = function() {
   MM_preloadImages('<?=base_url();?>common/image/form_bt001_on.gif,<?=base_url();?>common/image/form_bt003_on.gif,<?=base_url();?>common/image/form_bt004_on.gif')
   var colorful = new ColorfulInput;
   colorful.set();
}

function ColorfulInput() {
   this.skip  = ['submit', 'checkbox', 'radio', 'button'];
   this.color = { 'blur': '', 'focus': '#FFFFC4' };

   this.set = function() {
      for (var i = 0; i < document.forms.length; i++) {
         for (var f = 0; f < document.forms[i].length; f++) {
            var elm = document.forms[i][f];
            if(!this._checkSkip(elm)) continue;

            this._setColor(elm, 'focus');
            this._setColor(elm, 'blur');
         }
      }
   }

   this._checkSkip = function(elm) {
      for(var i in this.skip) {
         if(elm.type == this.skip[i]) return false;
      }
      return true;
   }

   this._setColor = function(elm, type) {
      var color = this.color[type];
      var event = function() { elm.style.backgroundColor = color; };

      if(elm.addEventListener) {
         elm.addEventListener(type, event, false);
      } else if(elm.attachEvent) {
         elm.attachEvent('on'+type, event);
      } else {
         elm['on'+type] = event;
      }
   }
}
