// 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 = {
    'a'   : function(element){
        element.onfocus = function(event) {
            this.blur();
        }
    },
    '#blogger'   : function(element){
        element.onchange = function(event) {
            window.location = '/people/profile/' + encodeURI(this.value);
        }
    },
    '#bquestions'   : function(element){
        element.onchange = function(event) {
            window.location = '/people/questions/' + encodeURI(this.value);
        }
    },
    '#imageLocation'   : function(element){
        element.onchange = function(event) {
            window.location = '/images/index/' + encodeURI(this.value);
        }
    },
    '#blogLocation'   : function(element){
        element.onchange = function(event) {
            window.location = '/blogs/index/' + encodeURI(name) + '/' + encodeURI(this.value);
        }
    },
    '#blogBlogger'   : function(element){
        element.onchange = function(event) {
            window.location = '/blogs/index/' + encodeURI(this.value) + '/' + encodeURI(location_id);
        }
    },
    '#commentLocation'   : function(element){
        element.onchange = function(event) {
            window.location = '/comments/index/' + encodeURI(this.value);
        }
    },
    '.close'   : function(element){
        element.onclick = function(event) {
            window.close();
        }
    },
    '.image'   : function(element){
        element.onclick = function(event) {
            var k = window.open(
                this.href,
                'image',
                'width=400,height=600,scrollbars=auto');
            k.focus();
            return false;
        }
    },
    '.comment'   : function(element){
        element.onclick = function(event) {
            var k = window.open(this.href, 'comment', 'width=400,height=600');
            k.focus();
            return false;
        }
    },
    '.submit'   : function(element){
        element.onclick = function(event) {
            $('f').submit();
            return false;
        }
    }
};

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;
    }
    */
});