$(document).ready(function() { Buttons.init(); }); Buttons = { init: function() { $("a.button, button, input[type=button], input[type=submit]").each( function() {; if( !$(this).data('button') ) { // Links if(this.tagName.toUpperCase()=="A") { var text = $(this) .addClass("Button") .addClass("icons") .html(); $(this) .empty() .append(""+text+"") .bind("mousedown", function() {$(this).addClass('buttonActive');}) .bind("mouseup", function() {$(this).removeClass('buttonActive');}); } else if(this.tagName.toUpperCase()=="BUTTON") { var original = this; var classes = $(this).attr('class'); var style = $(this).attr('style'); var text = $(this) .css({position: "absolute", top: "-1000px"}) .html(); $(""+text+"") .bind("click", function() { original.click(); return false; }) .bind("mousedown", function() {$(this).addClass('buttonActive');}) .bind("mouseup", function() {$(this).removeClass('buttonActive');}) .insertAfter(original); } else if(this.tagName.toUpperCase()=="INPUT") { var original = this; var text = this.value; var classes = $(this).attr('class'); var style = $(this).attr('style'); if(this.type=="submit") { text = ""+text+""; } $(this).css({position: "absolute", top: "-1000px"}); $(""+text+"") .bind("click", function() { original.click(); return false; }) .bind("mousedown", function() {$(this).addClass('buttonActive');}) .bind("mouseup", function() {$(this).removeClass('buttonActive');}) .insertAfter(original); } $(this).data("button", true); } }); } }