var javascript_rules = {
    
}
Behaviour.register(javascript_rules);
var rollover_rules = {
    'img.rollover' : function(el) {
        el.onmouseover = function() {
            parts = this.src.match(/^(.+)\.(\w+)$/);
            if (parts[1] != null && parts[1].match(/_ro/) == null ) {
                this.src = parts[1] + "_ro." + parts[2];
            }
        };
        el.onmouseout = function() {
            parts = this.src.match(/^(.+)_ro\.(\w+)$/);
            if (parts != null ) {
                this.src = parts[1] + "." + parts[2];
            }
        }
    },
    'a.rollover_orange' : function(el) {
        el.onmouseover = function() {
            var image = this.getElementsByTagName("img")[0];
            var parts = image.src.match(/^(.+)\.(\w+)$/);
            if (parts[1] != null && parts[1].match(/_orange/) == null ) {
                image.src = parts[1] + "_orange." + parts[2];
            }
        };
        el.onmouseout = function() {
            var image = this.getElementsByTagName("img")[0];
            var parts = image.src.match(/^(.+)_orange\.(\w+)$/);
            if (parts != null ) {
                image.src = parts[1] + "." + parts[2];
            }
        }
    },
    'ul.nav li' : function(el) {
        el.onmouseover = function() {
            this.className = 'MenuItemOver';
        };
        el.onmouseout = function() {
            this.className = 'MenuItem';
        };
    }
}
Behaviour.register(rollover_rules);
var popup_rules = {
    'a.popup' : function(el) {
        el.onclick = function() {
            window.open(this.href,
                'PopUp',
                'width=684,height=350,top=200,left=50%,scrollbars=0,status=no,resizable=0,toolbar=0,titlebar=0,menubar=0,location=0');
            return false;
        }
    },
    'a.status' : function(el) {
        el.onmouseover = function() {
            window.status=this.title;
            return true;
        };
        el.onmouseout = function() {
            window.status='';
            return true;
        }
    }
}
Behaviour.register(popup_rules);
var form_rules = {
    'input.auto_upper' : function(el) {
        el.onblur = function() {
            toUpper(this)
        };
        el.onchange = function() {
            toUpper(this)
        };
				
    },
	  '.auto_blur' : function(el) {
        if (typeof el.onfocus == 'function') {
            var cascade = el.onfocus;
        }
        el.onfocus = function() {
            if (typeof cascade == 'function') {
                cascade.call(this);
            }
            this.className = this.className.replace('_off','_on'); 
            var fieldLabel = $(this.id + '_label');
            if (fieldLabel) {
            	  fieldLabel.className = fieldLabel.className.replace('_off','_on');
                var image = fieldLabel.getElementsByTagName('img')[0];
                if (image) {
                    image.src = image.src.replace('_normal','_active');
                }
            }
        };
        el.onblur = function() {
            this.className = this.className.replace('_on','_off');
            var fieldLabel = $(this.id + '_label');
            if (fieldLabel) {
            	  fieldLabel.className = fieldLabel.className.replace('_on','_off');
                var image = fieldLabel.getElementsByTagName('img')[0];
                if (image) {
                    image.src = image.src.replace('_active','_normal');
                }
            }
        }
    },
    'input.rollover' : function(el) {
        el.onmouseover = function() {
            if (this.className.search('selected') == -1) {
                this.src = this.src.replace('_normal','_active');
            }
        };
        el.onmouseout = function() {
            if (this.className.search('selected') == -1) {
                this.src = this.src.replace('_active','_normal');
            }
        };
    }
}
Behaviour.register(form_rules);