﻿function showSheet(sheet,file){
	// set active handler
	jQuery('#dataSheet .active').removeClass('active');
	jQuery(sheet).addClass('active');
	
	// FadeOut
	jQuery('#dataSheetContainer .active').fadeOut(200,function(){
		jQuery(this).removeClass('active').addClass('hidden');
		
		// FadeIn
		jQuery('#dataSheetContainer #'+jQuery(sheet).attr('rel')).fadeIn(100,function(){
			jQuery(this).removeClass('hidden').addClass('active');
		})
	}); 
	
	// Replace PDF-Download SRC
	if(file != ''){
		jQuery('#dataSheetDownload').show();
		jQuery('#dataSheetDownload a').attr('href',file);		
	}else{
		jQuery('#dataSheetDownload').hide();
	}
	// prevent default click-action
	event.preventDefault();
}

function swapImage(image){
	// get src of current image
	var src = jQuery('#dataColorImage img').attr('src'); 	
	// fade current image out
	
	jQuery('#dataColorImage img').fadeOut(300,function(){
		// replace src
		jQuery('#dataColorImage img').attr('src',src.replace(/(.*)\/.*(\.jpg$)/, '$1/'+jQuery(image).attr('rel')));
		// fade it back in
		jQuery('#dataColorImage img').fadeIn(300);
	});
	
	// prevent default click-action
	event.preventDefault();
}


jQuery(document).ready(function(){
	// Nav-BG balken positionieren
	var pos = jQuery('#left .current').position();
	jQuery("#bgbalken").css('top',pos.top-25); // 35=offset

	jQuery("#dataColor a").each(function(){
		var content = jQuery(this).html();
		jQuery(this).qtip({
		   content:content,
		   style: { 
			  name: 'dark', // Inherit from preset style
			  border: {
				  width: 2
			  }
		   },
		   position:{
			  corner:{
				 target:'bottomMiddle',
				 tooltip:'topMiddle'
			  }
		   }
		});
	});
});



/* Karte */
jQuery(document).ready(function(){
	jQuery('#haendlermap area').click(function(){
		var kanton = jQuery(this).attr('alt');
		jQuery('.haendlermap').hide();
		jQuery('#haendlermap_'+kanton).show();
		
		if(jQuery('#haendlermap_'+kanton).length == 0){
			jQuery('#noHaendler span').html(kanton);
			jQuery('#noHaendler').show();
		}else{
			jQuery('#noHaendler').hide();
		}
		
		return false;
	});
	jQuery('#haendlermap area').mouseover(function(){
		var kanton = jQuery(this).attr('alt');
		var src = jQuery('#haendlermap img').attr('src');
		
		jQuery('#haendlermap img.holder').attr('src',src.replace(/(.*)\/.*(\.png$)/, '$1/karte_'+kanton+'.png'));
	});
	
});

