var buttonbgcolor = '';

function button(t,state,bgcolor) {
    if(!bgcolor) bgcolor = '#3E99DF';
    if(state == 1) {
      buttonbgcolor=t.style.backgroundColor;
      t.style.backgroundColor=bgcolor;
    } else {
      t.style.backgroundColor=buttonbgcolor;
    }
}