// turn on this img if not already on function rollOver(obj) { obj.src = obj.src.replace(/(\.[a-z0-9]+)$/i,'_on$1'); }; // turn off this img if not off function rollOff(obj) { obj.src = obj.src.replace(/_on(\.[a-z0-9]+)$/i,'$1'); }; // behaviour rules var rules = { '#nav a' : function(element){ element.onmouseover = function () { rollOver(this.childNodes[0]); }, element.onmouseout = function () { rollOff(this.childNodes[0]); } }, '#go' : function(element){ element.onclick = function () { var val = $('value').value; if(val){ window.location = '/works/search/' + encodeURI(val); return; } return false; } }, '#value' : function(element){ element.onkeydown = function (event) { if(event.keyCode == 13){ window.location = '/works/search/' + encodeURI(this.value); return; } } }, '#gologin' : function(element){ element.onclick = function () { var val = $('login').value; if(val){ window.location = '/works/search/event:' + encodeURI(val); return; } return false; } }, '#login' : function(element){ element.onkeydown = function (event) { if(event.keyCode == 13){ window.location = '/works/search/event:' + encodeURI(this.value); return; } } }, '.email' : function(element){ element.onclick = function (event) { var k = window.open(this.href, 'Inquiry', 'width=333,height=666,scrollbars=yes'); k.focus(); return false; } }, '.map' : function(element){ element.onclick = function (event) { var m = window.open(this.href, 'Map', 'width=703,height=536,scrollbars=no'); m.focus(); return false; } }, '.image_pop' : function(element){ element.onclick = function (event) { var img = window.open(this.href, 'Image', 'width=550,height=650,scrollbars=no'); img.focus(); return false; } }, 'a' : function(element){ element.onfocus = function(event) { this.blur(); } }, '#asearch' : function(element){ element.onclick = function () { var val = ''; var input = document.getElementsByClassName('form'); for(i in input){ val += (input[i].name && input[i].value) ? input[i].name + ':' + input[i].value + ';' : ''; } window.location = '/works/search/' + val; return; } } }; Behaviour.register(rules); Behaviour.addLoadEvent( function() { var k = new Array(); for(var i = 1; i <= 6; i++){ k[i] = new Image(); k[i].src = $('i'+i).src.replace(/(\.[a-z0-9]+)$/i,'_on$1'); $('debug').innerHTML = k[i].src; } });