
/*
FILE CONCAT ADD FILE
PATH: /ft/resources/client/modules/glossary/Popup_PermanentLink.js
*/
var PermanentLink_class = function(){
	PermanentLink_class.Super(this);
}

PermanentLink_class.Extend(Popup);

PermanentLink_class.prototype.init = function() {
	// has to be onload to handle the module in the FT wrapper
	Events.add(window, "load", function() {
		var permanentLink = Element.parseSelector("a.permanentLink", document.body, "first");
	
		Events.add(permanentLink, "click", this.drawPermanentLinkPopup, this);
	}.Context(this));
}

PermanentLink_class.prototype.resetPopup = function() {
	this.setTitleText("");
	this.clearContent();
	
	Element.addClass(this.getFrame(), "glikiPopup");
}

PermanentLink_class.prototype.drawPermanentLinkPopup = function(e, el) {
	if (e) { e.cancel(); }

	var termInput;
	
	this.resetPopup();
	
	this.setTitleText("Permanent Link");
	Element.addClass(this.getFrame(), "permanentLinkPopup");
	
	Element.create("div", {"class":"popupBody"}, [
		Element.create("p", {"class":"termText"}, ["Use a permanent link to cite a specific version of a Lexicon entry. Copy and paste the url below into your blog or web page to link to this term."]),
		termInput = Element.create("input", {"value":location.href})
	], this.getContent());
	
	this.getEventManagerPermanentLink().add(termInput, "click", this.selectText, this);
	
	this.draw();
	this.sizeShim();
}

PermanentLink_class.prototype.close = function (e, el) {
	PermanentLink_class.Super(this, "close", [e, el]);
	
	if (el) {
		this.getEventManagerPermanentLink().removeAll();
	}
};

PermanentLink_class.prototype.selectText = function(e, el) {
	e.cancel();
	
	el.focus();
	el.select();
}

PermanentLink_class.prototype.getEventManagerPermanentLink = function() {
	var em = new EventManager();
	
	this.getEventManagerPermanentLink = function() {
		return em;
	}
	
	return this.getEventManagerPermanentLink();
}

var permanentLink = new PermanentLink_class();
	permanentLink.init();
/*
FILE CONCAT ADD FILE
PATH: /ft/resources/client/modules/Popup_Subscribe.js
*/
var Subscribe_class = function() {}

Subscribe_class.Extend(Popup);

Subscribe_class.prototype.init = function() {
	Events.add(Element.parseSelector("a[subscribeText]"), "click", this.drawLoginPopup, this);
}

Subscribe_class.prototype.resetPopup = function() {
	this.setTitleText("");
	this.clearContent();
	
	Element.addClass(this.getFrame(), "glikiPopup");
}

Subscribe_class.prototype.drawLoginPopup = function(e, el) {
	e.cancel();

	var elCancel,
		elRegister;

	this.resetPopup();
	
	this.setTitleText("Log in to Financial Times");
	Element.addClass(this.getFrame(), "registerPopup");
	
	Element.create("div", {"class":"popupBody"}, [
		Element.create("p", {}, el.getAttribute("subscribeText")+" If you are not currently registered for this site, these are some of the benefits of registration:"),
		Element.create("ul", {}, [
			Element.create("li", {}, "More articles per 30 days"),
			Element.create("li", {}, "Price and portfolio email alerts"),
			Element.create("li", {}, "Portfolio tool"),
			Element.create("li", {}, "News by email")
		])
	], this.getContent());
	
	Element.create("div", {"class":"popupControls contain"}, [
		elRegister = Element.create("div", {"class":"basicButton", "link":el.getAttribute("href")}, [
			Element.create("div", {}, "Register &amp; Log In")
		]),
		elCancel = Element.create("div", {"class":"basicButton"}, [
			Element.create("div", {}, "Cancel")
		])
	], this.getContent());

	this.getEventManager().add(elCancel, "click", this.close, this);
	this.getEventManager().add(elRegister, "click", this.gotoRegistrationPage, this);
	
	this.draw();
	this.sizeShim();
}

Subscribe_class.prototype.gotoRegistrationPage = function(e, el) {
	location.href = el.getAttribute("link");
}

var subscribeToFT = new Subscribe_class();
	subscribeToFT.init();