function b4j_addEvent(selector, event, eventName, preventDefault) {
var obj = $(selector);
if (obj.length > 0) {
obj.on(event, function (e) {
if (preventDefault) {
e.preventDefault();
e.stopPropagation();
}
if (e.target.id) {
b4j_raiseEvent(eventName, {which: e.which, target: e.target.id, pageX: e.pageX, pageY: e.pageY, metaKey: e.metaKey});
} else {
b4j_raiseEvent(eventName, {which: e.which, target: selector, pageX: e.pageX, pageY: e.pageY, metaKey: e.metaKey});
}
});
}
}