// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
//
// Author: John Leach
// Contact: john.leach@syger.it

/*
 Tests the Closure.js code.
*/

// Create a short cut to the normal output device
if (!syger.exists(this, "puts")) {
	var puts = function (str) {
		document.write(str);
	};
}

// Utility function to print the list
function printList(tickers) {
	puts("<ul>\n");
	for (var idx in tickers) {
		if (tickers.hasOwnProperty(idx)) {
			puts("  <li><a href='" + refs["linkTo" + idx]("5d")
				+ "'>" + idx + "</a></li>\n");
		}
	}
	puts("</ul>\n");
}

// Create references for Yahoo! Inc. financial services
var systemTickers = {
	"Yahoo" : "YHOO",
	"Google" : "GOOG",
	"Microsoft" : "MSFT",
	"Sun" : "JAVA"
};     
var refs = app.createFinancialLinks("http://finance.yahoo.com/q/bc",
		 ["s", "t"], systemTickers);

// Show the Yahoo! Inc. links
puts("<p>Links for tickers in ");
puts("<a href='" + refs.linkToYahoo("5d") + "'>Yahoo! Inc</a>");
puts(" financial services:</p>\n");
printList(systemTickers);

// Create references for Google Inc. financial services
refs = app.createFinancialLinks("http://finance.google.com/finance",
	     ["q"], systemTickers);

// Show the Google links
puts("<p>Links for tickers in ");
puts("<a href='" + refs.linkToGoogle("5d") + "'>Google Inc</a>");
puts(" financial services:</p>\n");
printList(systemTickers);
