/**
* Price table data switcher according to current CHF/EUR exchange rate.
* 
* @author Stickerei Stoiber <info@stickerei-stoiber.de>
* @copyright Stickerei Stoiber <info@stickerei-stoiber.de>
*/

/**
* Rate switcher class
*/
RateSwitcher = {
	/**
	* CHF prices shown?
	*/
	chPricesShown : false,
	
	/**
	* Changes the prices
	*/
	switchPrices : function(){			
		if(RateSwitcher.chPricesShown){
			$$('p.CHFprice').each(function(price){price.setStyle({display : 'none'})});
			$$('p.EURprice').each(function(price){price.setStyle({display : 'block'})});
			
			RateSwitcher.chPricesShown = false;
			
			$$('.tablePriceSwitcher div div').each(function(switcherLink){
				switcherLink.update('<span class="currentPriceTypeText">EUR</span> / <a href="javascript:void(0)" class="switcherLink">CHF</a>');
			});
		} else {
			$$('p.CHFprice').each(function(price){price.setStyle({display : 'block'})});
			$$('p.EURprice').each(function(price){price.setStyle({display : 'none'})});
			
			RateSwitcher.chPricesShown = true;
			
			$$('.tablePriceSwitcher div div').each(function(switcherLink){
				switcherLink.update('<a href="javascript:void(0)" class="switcherLink">EUR</a> / <span class="currentPriceTypeText">CHF</span>');
			});
		}
		
		$$('.switcherLink').each(function(switcher){
			switcher.observe('click', RateSwitcher.switchPrices);
		});
	},
	
	/**
	* Initializes the price switcher system for all tables in the current page.	
	*/
	initRateSwitchers : function(){
		$$('.switcherLink').each(function(switcher){
			switcher.observe('click', RateSwitcher.switchPrices);
		});
	}
}
