var fi = {};

var FiLife = Class.create({
	
	initialize: function() {
		this.numInterviewsSWE = $$('div#filife_interviews_swe a.featured_link').length;
		this.numInterviewsNYC = $$('div#filife_interviews_nyc a.featured_link').length;
		this.addListeners();
		this.setupNavigationTabs();
	},

	setupNavigationTabs:function(){
		this.navigationTabs = new TabView("filifeNavigation");
	},

	addListeners: function() {
		$('filife_show_all_benefits_swe_button').observe('click', function(event) {
			$('filife_more_benefits_swe').show();
			$('filife_show_all_benefits_swe_button').hide();
		});

		$('filife_show_all_benefits_nyc_button').observe('click', function(event) {
			$('filife_more_benefits_nyc').show();
			$('filife_show_all_benefits_nyc_button').hide();
		});

		$$('div#filife_interviews_swe a.featured_link').each(function(item, index) {
			item.observe('click', function(event) {
				$$('div.filife_interview_swe').invoke('hide');
				var id = index + 1;

				if(id >= this.numInterviewsSWE) {
					id = 0;
				}

				$('interview_swe_' + id).show();
			}.bind(this));
		}.bind(this));

		$$('div#filife_interviews_nyc a.featured_link').each(function(item, index) {
			item.observe('click', function(event) {
				$$('div.filife_interview_nyc').invoke('hide');
				var id = index + 1;

				if(id >= this.numInterviewsNYC) {
					id = 0;
				}

				$('interview_nyc_' + id).show();
			}.bind(this));
		}.bind(this));
	}	
});

function initpage(){
	var numOfTsEntries = 8;
	fi.base = new Base(numOfTsEntries);
	fi.gallery_swe = new ComponentGallery("compGallerySWE");
	fi.gallery_nyc = new ComponentGallery("compGalleryNYC");
	fi.filife = new FiLife();
	fi.formValidator = new FormValidator();
}

document.observe("dom:loaded",initpage);
