jQuery(document).ready(function() {
	//jQuery('#c2861').hide();

	CountryTabs.init(4);
});




CountryTabs = {
	imagePath: 'fileadmin/templates/images/header/',


	init: function(tabCount) {
		/*for (var i = 1; i <= tabCount; i++) {
		jQuery('#country_tab'+i).bind('click', function() {
		CountryTabs.initTab(i);
		});
		}*/

		jQuery('#country_tab1').bind('click', function() {
			CountryTabs.toggleTab(1, new Array('#c134', '#c713'), new Array('#c2861', '#c2862', '#c2863', '#c2940', '#c2941', '#c2942'));
		});

		jQuery('#country_tab2').bind('click', function() {
			CountryTabs.toggleTab(2, new Array('#c2861', '#c2940'), new Array('#c134', '#c2862', '#c2863', '#c713', '#c2941', '#c2942'));
		});

		jQuery('#country_tab3').bind('click', function() {
			CountryTabs.toggleTab(3, new Array('#c2862', '#c2941'), new Array('#c134', '#c2861', '#c2863', '#c713', '#c2940', '#c2942'));
		});

		jQuery('#country_tab4').bind('click', function() {
			CountryTabs.toggleTab(4, new Array('#c2863', '#c2942'), new Array('#c134', '#c2861', '#c2862', '#c713', '#c2940', '#c2941'));
		});

	},


	toggleTab : function(tabIndex, showContentElements, hideContentElements) {
		//Disable all tabs
		jQuery('#country_tabs img').each(function() {
			jQuery(this).attr('src', jQuery(this).attr('src').replace(/_enabled/g, ''));
		});
		//Enable clicked tab
		jQuery('#country_tab' + tabIndex + ' img').attr('src', jQuery('#country_tab' + tabIndex + ' img').attr('src').replace(/.png/g, '_enabled.png'));

		//Change header image
		jQuery('.fp-header-img1').attr('src', this.imagePath+'theme'+tabIndex+'.jpg');
		jQuery('.fp-header-img2').attr('src', this.imagePath+'logo'+tabIndex+'.gif');

		//Hide tab specific content elements
		for (var i = 0; i < hideContentElements.length; ++i) {
			jQuery(hideContentElements[i]).hide();
		}

		//Show tab specific content elements
		for (var i = 0; i < showContentElements.length; ++i) {
			jQuery(showContentElements[i]).show();
		}

	}


};

