﻿// base.js

// load shadowbox
Shadowbox.loadSkin('classic', '/fileadmin/web/scripts/plugins/shadowbox/skin'); // use the "classic" skin
Shadowbox.loadLanguage('de-DE', '/fileadmin/web/scripts/plugins/shadowbox/lang'); // use the English language
Shadowbox.loadPlayer(['img','iframe'], '/fileadmin/web/scripts/plugins/shadowbox/player'); // use img viewer

// configure shadowbox
$(document).ready(function() {
	Shadowbox.init({
		skipSetup: true
	});
	
	$('a[rel=media]').click(function() {
		Shadowbox.open($(this).get(0), {animSequence: 'sync', resizeDuration: 0.5, fadeDuration: 0.2, handleOversize: 'drag'});
		
		return false;
	});
});

// font resizer
$(document).ready(function() {
	var normal = $('body').css('font-size');
	var preset = $.cookie('font-size');
	var size;
	
	var setFontSize = function(size) {
		
		// get real size
		if(size == 'huge') {
			set = '17px';
		} else if(size == 'large') {
			set = '15px';
		} else {
			set = normal;
		}
		
		// set size
		$('body').css('font-size', set);
		$.cookie('font-size', size, {domain: 'www.hansaton.at', path: '/'});
		
		// delete cookie
		if(size == 'normal') {
			$.cookie('font-size', null, {domain: 'www.hansaton.at', path: '/'});
		}
		
		// handle active state
		$('#resizer a').removeClass('active');
		$('#resizer a[href$=' + size + ']').addClass('active');
	};
	
	// get cookie value
	if(preset != null) {
		setFontSize(preset);
	}
	
	// change the font size
	$('#resizer a').click(function() {
		
		// handle resize
		size = $(this).attr('href').substr(1);
		setFontSize(size);
		
		return false;
	});
});

// enable ie6 to use the css dropdown menu
$(document).ready(function() {
	if($.browser.msie && parseInt($.browser.version) < 7) {
		$('#topmenu li').hover(function() {
			$(this).find('ul').show(0);
		}, function() {
			$(this).find('ul').hide(0);
		});
	}
});

// linked teaser boxes
$(document).ready(function() {
	$('.box_teaser').fitted();
});

