﻿BenefulMap.ModalShareThis = BenefulMap.Modal.extend({
	init: function(modalTitle, modalElements, modalOptions, snippetPath, params, context) {
		this._super( modalTitle, modalElements, modalOptions, snippetPath, params);
		this.context = context;
		this.spotId = 0;
	},
	getContext: function() {
	   return this.context;
	},
	setContext: function(context) {
	   this.context;
	},
	getSpotId: function() {
	   return this.spotId;
	},
	setSpotId: function(spotId) {
	   this.spotId = spotId;
	},
	addModalListeners: function() {
	   this._super();
	   this.cancelButtonListener();
	},
	cancelButtonListener: function() {
		var self = this;
		$( this.getModalDiv() + " .cancel" ).unbind();
		$( this.getModalDiv() + " .cancel" ).click(function(event) {
			event.preventDefault();
			self.close();
		});
	},
	addModalTargetListener: function() {
		var self = this;
		$(this.targetEl).live('click', function(event) {
			event.preventDefault();
			self.setFiredTarget(this);
			self.setContext($(this).attr("rel"));
			var params = {};
			params.context = self.getContext();
			if (self.getContext() == "spot") {
			    self.setSpotId(jQuery.url.attr("file").replace(".aspx", ""));
			    params.id = self.getSpotId();
			}
            self.setParams(params);
			self.populate();
		});
	}
});
