А вообще так делать не нужно!
<div class="class1"></div>
<style type="text/css">
div{width: 100px; height: 100px;}
.class1 {background: #000000;}
.class2 {background: #8000FF;}
</style>
<script type="text/javascript">
window.onload = function(){
if(!/IE(6).+Win/.test(navigator.userAgent)){
var input = document.getElementsByTagName('div')[0];
var items = ["mouseover", "mouseout"];
for (var i = 0; i < items.length; i++){
(function(){
var item = items[i];
input['on'+item] = function(){
this.className = (this.className == 'class2') ? 'class1' : 'class2';
};
})();
}
}
};
</script>