var JModalBoxes = new Class({
	Implements: [Events, Options],
	options: {
		textLoad: 'Click OK to download our free software while browsing the site',
		textUnload: 'Click Cancel, Download Planet23 and Win a Trip to Las Vegas',
		redirectURL: './download/'
	},
	initialize: function(options){
		//this.setOptions(options);
		this.triggerOnBeforeUnload = true;
	},
	onLoad: function(){
		if ( confirm(this.options.textLoad) ) {
			triggerOnBeforeUnload = false;
			window.location = this.options.redirectURL;
		}
		Cookie.set('onLoadExecuted','true')
	},
	onBeforeUnload: function(e){
		if ( typeof(jAutoDownload) == "boolean" ) {
			jAutoDownload = null;
			return;
		}
		if ( triggerOnBeforeUnload ) {
			var e = e || window.event;
			triggerOnBeforeUnload = false;

			// For IE and Firefox
			if (e) {
			e.returnValue = 'Click Cancel, Download Planet23 and Win a Trip to Las Vegas';
			}

			// For Safari
			return 'Click Cancel, Download Planet23 and Win a Trip to Las Vegas';
		}
		triggerOnBeforeUnload = true;
	}
});
