

/*
    Viva Mambo, Inc. JavaScriptライブラリ
    Ver.0.01
    http://www.viva-mambo.co.jp/
    作成日：2006年7月05日
    更新日：2006年11月28日
    Copyright 2006 Viva Mambo, Inc. All Rights Reserved.
*/


/*--------------------------------------------------------------------
	onsubmitでsubmitボタンをdisableにする
--------------------------------------------------------------------*/

var DisableSubmit = {
   init: function() {
      this.addEvent(window, 'load', this.set());
   },

   set: function() {
      var self = this;
      return function() {
         for (var i = 0; i < document.forms.length; ++i) {
            if(document.forms[i].onsubmit) continue;
            document.forms[i].onsubmit = function() {
               self.setDisable(this.getElementsByTagName('input'));
            };
         }
      }
   },

   setDisable: function(elms) {
      for (var i = 0, elm; elm = elms[i]; i++) {
         if ((elm.type == 'submit' || elm.type == 'image') && !elm.disabled) {
            Set(elm);
            unSet(elm);
         }
      }

      function Set(button) {
         window.setTimeout(function() { button.disabled = true; }, 1);
      }
      function unSet(button) {
         window.setTimeout(function() { button.disabled = false; }, 10000);
      }
   },

   addEvent: function(elm, type, event) {
      if(elm.addEventListener) {
         elm.addEventListener(type, event, false);
      } else if(elm.attachEvent) {
         elm.attachEvent('on'+type, event);
      } else {
         elm['on'+type] = event;
      }
   }
}

DisableSubmit.init();


/*--------------------------------------------------------------------
	テキストボックスのvalueを空にする
--------------------------------------------------------------------*/

function initSearchWord() {
	if (document.searchForm.searchWord.value == 'Search this site') {
		document.searchForm.searchWord.value = "";
	}
}


/*--------------------------------------------------------------------
	テキストボックスのvalueを評価する
--------------------------------------------------------------------*/

function checkSearchWord() {
	if (document.searchForm.searchWord.value == 'Search this site'){
		alert('Please input keywords!');
		return false;
	} else {
		return true;
	}
}