this.PSP = this.PSP || {};
this.PSP.Widgets = this.PSP.Widgets || {};

this.PSP.Widgets.FindMore = new Class({

	Implements: [Options, Events],

	options: { type: null,
			   file: null,
			   id: null,
			   width: 640,
			   height: 532,
			   padding: 10,
			   urls: { baseUrl: null } },

	initialize: function(element, options)
	{
		this.setOptions(options);

		$(element).addEvent('click',function(e) {
			this._showHrefList(e);
		}.bind(this));

		$$('#header span').addEvent('click',function(e) {
			this._showHrefList(e);
		}.bind(this));
	},

	_showHrefList: function(e)
	{
		e.stop();
		var liteboxWidth = parseInt(this.options.width) + this.options.padding * 2;
		var liteboxHeight = parseInt(this.options.height) + this.options.padding * 2;

		var box = new PSP.Litebox({
			formEl: { width: liteboxWidth, height: liteboxHeight, y: '18px' },
			closeEl: { y: '18px', src: this.options.urls.baseUrl + 'public/website/images/closed.png' }
		});

		var hrefListEl = new Element('ul');

		$splat(this.options.hrefList).each(function(entry) {

			new Element('a', {
				target:'_blank',
				href: entry.href,
				html: entry.link_value
			}).inject(
				new Element('li', {
					'class': entry.link_value.toLowerCase().replace(/\s+/g, '-')
				}).inject(hrefListEl));
		});

		box.addEvent('shown', function(formEl) {

			var mainBoxDiv = new Element('div', {
				id: 'href-list',
				styles: {
					width: this.options.width,
					height: this.options.height
				}
			}).inject(formEl);

			new Element('h3', { html:'If you would like to shop, please click on your country of residence:' }).inject(mainBoxDiv);

			hrefListEl.inject(mainBoxDiv);

		}.bind(this));

		box.show();
	}
});

