// jquery.tooltips.js (English)
// Requires jquery.js
// Mar, 2009 TMX Group Inc.

$(function() {
	var toolTips = {};
	toolTips.targetClassName = 'terms';
	toolTips.className = 'toolTips';
	toolTips.width = 240;					// in pixels
	toolTips.terms = {
		
		AdvisorClassUnit: {
			name: 'Advisor Class Unit',
			description: 'The Advisor Class Units that are listed by some ETF Providers (denoted by &quot;.A&quot; on the symbol) have been designed only for clients who are advised by a registered investment advisor and purchased through an advisor. The only difference between this class of units and the Common Unit, which has been designed to be purchased by institutional and individual investors, is the service fee component for the managed fees payable on the Advisor Class Unit.'
		},
		AssetClass: {
			name: 'Asset Class (Asset Allocation)',
			description: 'Investments can be divided into different categories such as stocks, bonds, cash equivalents or commodities. Dividing investments into the different asset classes is one method of diversifying a portfolio according to the investor\'s objectives, time horizon and basic risk tolerance level. The proportion of investment in different asset classes is referred to as asset allocation.'
		},
		Basket: {
			name: 'Basket',
			description: 'A group of several securities created for the purpose of simultaneous buying or selling.'
		},
		Benchmark: {
			name: 'Benchmark',
			description: 'An index that serves as a standard against which performance can be measured. For example, a broad, widely known index can be considered a benchmark and can be used to assess the performance of a fund or portfolio over time.'
		},
		Bonds: {
			name: 'Bonds',
			description: 'Promissory notes issued by a corporation or government to its lenders, usually with a specified amount of interest for a specified length of time.'
		},
		CallOption: {
			name: 'Call Option',
			description: 'An option which gives the holder the right, but not the obligation, to buy a fixed amount of a certain stock at a specified price within a specified time. Calls are purchased by investors who expect a price increase.'
		},
		CapitalGains: {
			name: 'Capital Gains (or Losses)',
			description: 'Profit or loss resulting from the sale of certain assets classified under the federal income tax legislation as capital assets. This includes stocks and other investments such as investment property.'
		},
		Commodities: {
			name: 'Commodities',
			description: 'Products used for commerce that are traded on a separate, authorized commodities exchange. Commodities include agricultural products and natural resources such as timber, oil and metals. Commodities are the basis for futures contracts traded on these exchanges.'
		},
		Constituents: {
			name: 'Constituents',
			description: 'The components of a grouping. For instance the stocks included or that make up an index are considered the index constituents.'
		},
		CreationUnits: {
			name: 'Creation Units',
			description: 'Large blocks of tens of thousands of ETF shares which can be exchanged in-kind with baskets of the underlying securities when an ETF is initially established.'
		},
		DayOrder: {
			name: 'Day Order',
			description: 'An order that is valid only for the day it is entered. If the order is still outstanding when the market closes, it will be purged overnight.'
		},
		Derivatives: {
			name: 'Derivatives',
			description: 'A financial contract that has its value derived from a traditional security (such as a stock or bond), an asset such as a commodity, or a market index.'
		},
		DesignatedBroker: {
			name: 'Designated Broker',
			description: 'A person who is registered as a broker and must perform certain brokerage duties in relation to an ETF.'
		},
		ETFProvider: {
			name: 'ETF Provider/ETF Sponsor',
			description: 'The company that establishes and administers an Exchange Traded Fund. It administers the ETF by dealing with the creation units and institutional investors when there are changes to the underlying index.'
		},		
		ExchangeTradedCommodities: {
			name: 'Exchange Traded Commodities (ETCs)',
			description: 'Exchange Traded Funds that invest in commodities like energy, metals or agriculture. ETCs trade like ETFs but are investment vehicles that track the performance of an underlying commodity index rather than an equity index.'
		},		
		ExchangeTradedNotes: {
			name: 'Exchange Traded Notes (ETNs)',
			description: 'ETNs like ETFs are linked to the performance of an index; however they are based on debt securities, not equities or commodities. ETNs are based on debt securities issued by an underwriting bank. ETN returns are based upon the performance of a market index, minus applicable fees. ETNs have additional risk compared to ETFs since if there is any reduction in the credit rating of the underwriting bank or if the bank goes bankrupt, the value of the ETN will be adversely affected.'
		},
		ExchangeTradedProducts: {
			name: 'Exchange Traded Products (ETPs)',
			description: 'A term used to describe a specialized grouping of exchange traded investments that have a common structure. The term is often used to categorize a grouping of Exchange Traded Funds, Exchange Traded Commodities, Exchange Traded Derivatives, or Exchange Traded Notes.'
		},		
		Expiration: {
			name: 'Expiration (option)',
			description: 'The date at which an option contract expires. This means that the option can\'t be exercised after that date. Typically, the Saturday following the third Friday of the expiration month is the expiration day.'
		},
		GoodTilCancelled: {
			name: 'Good Til Cancelled (GTC)',
			description: 'A Good Til Cancelled (GTC) order will remain in the system until the date that it is filled or until a maximum of 90 calendar days from date of entry, whichever happens first. This type of order is also referred to as an open order. The investor can cancel a GTC order at any time.'
		},
		Leverage: {
			name: 'Leverage',
			description: 'The use of borrowing for the potential of magnified percentage returns, or losses on an investment. The greater the proportion of borrowing to the value of the investment, the greater the leverage.'
		},
		LimitOrder: {
			name: 'Limit Order',
			description: 'An order to buy or sell stock at a specified price. The order can be executed only at the specified price or better. A limit order sets the maximum price the client is willing to pay as a buyer, and the minimum price they are willing to accept as a seller.'
		},
		ManagementExpenseRatio: {
			name: 'Management Expense Ratio (MER) (Management fees, management expense)',
			description: 'A measure of the cost to shareholders of operating a fund, usually calculated as a percentage of assets.'
		},
		Margin: {
			name: 'Margin',
			description: 'The amount a broker will lend a client to purchase securities.'
		},
		MarketOrder: {
			name: 'Market Order',
			description: 'An order to buy or sell a security immediately at the best current price.'
		},
		NetAssetValue: {
			name: 'Net Asset Value (NAV)',
			description: 'The market value of a fund\'s total assets, minus liabilities, divided by the number of shares/units outstanding.'
		},
		Options: {
			name: 'Options',
			description: 'A contract that gives the holder (buyer) the right, but not the obligation, to buy or sell certain securities at a specified price within a specified time. A put option gives the holder the right to sell the security, and a call option gives the holder the right to buy the security.'
		},
		PutOption: {
			name: 'Put Option',
			description: 'A put option is a contract that gives the holder the right to sell a specified number of shares at a stated price within a fixed time period. Put options are purchased by those who think a stock may decline in price.'
		},
		Sector: {
			name: 'Sector',
			description: 'A related group of industries.'
		},
		ShortSelling: {
			name: 'Short Selling (Short Sale)',
			description: 'The selling of a security that the seller does not own in the belief that it will decline in value. Short selling is a trading strategy. Short sellers assume the risk that they will be able to buy the stock at a lower price, cover the outstanding short, and realize a profit from the difference.'
		},
		StopLimit: {
			name: 'Stop Limit',
			description: 'An order type option that can be specified by an investor. A stop limit is reached when the price of a stock rises or falls to a specified price. Once the stop price is reached, the stop-limit order becomes a limit order to buy (or to sell) at no more (or less) than a specified price. As with all limit orders, a stop-limit order will not get filled if the security\'s price never reaches the specified limit price.'
		},
		StrikePrice: {
			name: 'Strike Price',
			description: 'The price the owner of an option can purchase or sell the underlying security.'
		},
		Swaps: {
			name: 'Swaps',
			description: 'Agreements made between two parties to exchange a stream of periodic payments. Swaps are used to minimize risks associated with fluctuating factors such as currency or interest rates.'
		},
		UnderlyingIndex: {
			name: 'Underlying Index',
			description: 'The index that is being tracked by an ETF or index fund. For example the S&P/TSX 60 Index is the underlying index for the iShares CDN S&P/TSX 60 Index Fund (symbol XIU).'
		},

		Volatility: {
			name: 'Volatility',
			description: 'A statistical measure of changes in price over a period of time.'
		},
		Weighting: {
			name: 'Weighting',
			description: 'A designated proportion given to each component of an index, portfolio or fund. The proportion illustrates the relative importance or influence on the whole (index, fund or portfolio). Usually a weighting is stated as a percentage of the whole (for example, the stock makes up 21% of the total index).<br/><br/>The determination of the proportions can be based on various factors such as market capitalization, trading price, or a company fundamental. Weightings can change as the underlying factors change.'
		}

	};

	$('.' + toolTips.targetClassName).each(function(i) {
		$(this).bindToolTip(this, $(this).attr('href').slice(1), toolTips);
	});
});



(function($){
$.fn.bindToolTip = function(o, termName, toolTips) {

	toolTips.X = function(coordX) {
		if (coordX < toolTips.width) {
			return coordX + 15;
		} else {
			return coordX - toolTips.width - 15;
		}
	};
	toolTips.Y = function(coordY) {
		toolTips.height = $('.toolTips').height();
		if ($('body').height() - coordY < toolTips.height) {
			return coordY - toolTips.height - 15;
		} else {
			return coordY + 15;
		}
	};

	$(o)
		.mouseover(function(event) {
			$('<div />')
				.addClass(toolTips.className)
				.css({width: toolTips.width + 'px', left: toolTips.X(event.pageX), top: toolTips.Y(event.pageY)})
				.html(
					'<h5>' + toolTips.terms[termName].name + '</h5>' +
					'<p>' + toolTips.terms[termName].description + '</p>'
				)
				.appendTo('body');
		})
		.mousemove(function(event) {
			$('.' + toolTips.className).css({left: toolTips.X(event.pageX), top: toolTips.Y(event.pageY)});
		})
		.mouseout(function() {
			$('.' + toolTips.className).remove();
		})
		.click(function() {return false;});

};
})(jQuery);
