function myInputListener(el,which){
  //el.src=el.getAttribute(which || "origsrc");
  /*if( which == 'down' ) {
	el.src=el.getAttribute("oversrc");
	el.state=1;
  } else if( which == 'up' ) {
	el.src=el.getAttribute("origsrc");
	el.state=0;
  } else if( which == 'over' && el.state==1 ) {
	el.src=el.getAttribute("oversrc");
  } else if( which == 'out' ) {
	el.src=el.getAttribute("origsrc");
  } else {}*/

  if( which == 'over' ) {
	el.src=el.getAttribute("oversrc");
  } else if( which == 'out' ) {
	el.src=el.getAttribute("origsrc");
  } else {}
}

function myInputListenerSetup(){
  var x = document.getElementsByTagName("input");
  for (var i=0;i<x.length;i++){
	var oversrc = x[i].getAttribute("oversrc");
	if (!oversrc) continue;

	x[i].state=0;
	  
	// preload image
	x[i].oversrc_img = new Image();
	x[i].oversrc_img.src=oversrc;
	
	// set event handlers
	x[i].onmousedown = new Function("myInputListener(this,'down');");
	x[i].onmouseup   = new Function("myInputListener(this,'up');");
	x[i].onmouseover = new Function("myInputListener(this,'over');");
	x[i].onmouseout  = new Function("myInputListener(this,'out');");

	// save original src
	x[i].setAttribute("origsrc",x[i].src);
  }
}

var PremyInputListenerOnload =(window.onload)? window.onload : function(){};
window.onload = function(){PremyInputListenerOnload(); myInputListenerSetup();}
