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];
            }
        }
    },
    '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;
        }
    },
		
				
		'a.tip' : function(el) {
        el.onmouseover = function() {
            var image_small = this.getElementsByTagName("img")[0];
						var image = document.getElementById("tip").getElementsByTagName("img")[0];
						image.src = image_small.src.replace(/_small/,"");
        };
        el.onclick = function() {
            return false;
        }
    },
		
    'a.switch' : function(el) {
        el.onclick = function() {
						c = $(this.id.replace('_switch',''));
            if (c) {
                if (c.style.display != 'none') {
                    c.style.display = 'none';
                } else {
                    c.style.display = 'block';
                }
            }
            return false;
        }
    }
}
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','_hover');
                }
            }
        };
        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('_hover','_normal');
                }
            }
        }
    },
    'input.rollover' : function(el) {
        el.onmouseover = function() {
            if (this.className.search('selected') == -1) {
                this.src = this.src.replace('_normal','_hover');
            }
        };
        el.onmouseout = function() {
            if (this.className.search('selected') == -1) {
                this.src = this.src.replace('_hover','_normal');
            }
        };
    },
    'input.bg_rollover' : function(el) {
        el.onmouseover = function() {
            if (this.className.search('selected') == -1) {
                this.className = this.className.replace('_normal','_hover');
            }
        };
        el.onmouseout = function() {
            if (this.className.search('selected') == -1) {
                this.className = this.className.replace('_hover','_normal');
            }
        };
    }
}
Behaviour.register(form_rules);

function gettip(image)
{
document.getElementById('tip').innerHTML="<img src='" + image + "' />"
}
function reset()
{
document.getElementById('tip').innerHTML=" "
}