﻿// overrides for jquery because IE throws an error when setting e.returnValue = false; / e.cancelBubble = true;
// therefore we surround in a try/catch block
// see: http://osdir.com/ml/jQuery/2009-10/msg00532.html for more info

function returnFalse() {
    return false;
}
function returnTrue() {
    return true;
}

jQuery.Event.prototype = {
	preventDefault: function() {
		this.isDefaultPrevented = returnTrue;

		var e = this.originalEvent;
		if ( !e ) {
			return;
		}
		
		// if preventDefault exists run it on the original event
		if ( e.preventDefault ) {
			e.preventDefault();
		}
		// otherwise set the returnValue property of the original event to false (IE)
		try {
		    e.returnValue = false;
		}
		catch(e)
		{}
	},
	stopPropagation: function() {
		this.isPropagationStopped = returnTrue;

		var e = this.originalEvent;
		if ( !e ) {
			return;
		}
		// if stopPropagation exists run it on the original event
		if ( e.stopPropagation ) {
			e.stopPropagation();
		}
		// otherwise set the cancelBubble property of the original event to true (IE)
		try {
		    e.cancelBubble = true;
		}
		catch(e)
		{}
	},
	stopImmediatePropagation: function() {
		this.isImmediatePropagationStopped = returnTrue;
		this.stopPropagation();
	},
	isDefaultPrevented: returnFalse,
	isPropagationStopped: returnFalse,
	isImmediatePropagationStopped: returnFalse
};