function toggle(id,switch='on') { // Get the element e = document.getElementById(id); // Determine on/off if (switch=='on') { c = '#eee'; } else { c = 'none'; } // If element exists, change the style accordingly if (e) { e.style.background = c; } return; } ///// then call it this way