function attachInputToggle(id,col)
{
    if(!col) col = '#000'; 
    if(!id) id = document.forms[0];
    var id = (typeof id == 'string') ? document.getElementById(id) : id;
    if(!id) return false;
    var inps = id.getElementsByTagName('input');
    var inps2 = id.getElementsByTagName('textarea');

    function itemsArray(col)  
    {  
        for(var i=0, ary = [], len = col.length; i < len; i++) ary.push(col[i]); 
        return ary;  
    }

    if(inps.length) inps = itemsArray(inps);
    if(inps2.length) inps2 = itemsArray(inps2);
    if(inps.length && inps2.length) inps = inps.concat(inps2);
    
    var store = [];

    function toggle(fc,el,txt,c)
    {
        var f;
        if(fc)
        {
            f = function(){if(el.value == txt){el.value = '';el.style.color = c;}}
            el.fh = f;
        }
        else
        {
            f = function(){if(el.value == ''){el.value = txt;el.style.color = c;}}
            el.bh = f;
        }

        return f;
    }

    for(var n = 0,nLength = inps.length; n < nLength; ++n)
    {
        if(inps[n].type == 'text' || inps[n].type == 'textarea')
        {
            if(inps[n].type == 'text') try{inps[n].value = inps[n].getAttribute('value');}catch(e){}
            if(inps[n].type == 'textarea') try{inps[n].value = inps[n].innerHTML;}catch(e){}

            var oTxt = inps[n].value;
            var oCol;

            store.push({el: inps[n], t: oTxt});

            if(inps[n].value)
            {
                if(window.addEventListener)
                {               
                    if(inps[n].fh){ inps[n].removeEventListener('focus', inps[n].fh, false); inps[n].removeEventListener('blur', inps[n].bh, false) }
                    cs = window.getComputedStyle(inps[n],null);
                    oCol = cs.color;
                    inps[n].addEventListener('focus', toggle(1,inps[n],oTxt,col), false);
                    inps[n].addEventListener('blur', toggle(0,inps[n],oTxt,oCol), false);
                }
                else
                {
                    if(inps[n].fh){ inps[n].detachEvent('focus', inps[n].fh); inps[n].detachEvent('blur', inps[n].bh) }
                    oCol = inps[n].currentStyle.color;
                    inps[n].attachEvent('onfocus', toggle(1,inps[n],oTxt,col));
                    inps[n].attachEvent('onblur', toggle(0,inps[n],oTxt,oCol));
                }
            }
            else inps[n].style.color = col;
        }
    }

    var si = setInterval(function(){
      if(typeof doFormSubmission == 'function')
      {
          clearInterval(si);
          var oldSubmit = doFormSubmission;

          doFormSubmission = function()
          {
              for(var n = 0,nLength = store.length; n < nLength; ++n)
              {
                  if(store[n].el.value == store[n].t) store[n].el.value = ''; 
              }
              oldSubmit();
              for(var n = 0,nLength = store.length; n < nLength; ++n)
              {
                  if(store[n].el.value == '') store[n].el.value = store[n].t; 
              }
          }
      }
    }, 100)
}
