var frutigerRoman = { src: '/~siteDesign/site/~fonts/frutiger-roman.swf' };
var frutigerBold = { src: '/~siteDesign/site/~fonts/frutiger-bold.swf' };
var frutigerCn = { src: '/~siteDesign/site/~fonts/frutiger-cn.swf' };

sIFR.fitExactly = true;
sIFR.forceWidth = true;
sIFR.preventWrap = false;
sIFR.useStyleCheck = true;

sIFR.activate(frutigerRoman, frutigerBold, frutigerCn);

// header fonts
replaceText('h2', frutigerCn, 'left', '#464545', '#f7f7f7', 0, 0, 0, 1, false);
replaceText('h3, .button-large h4', frutigerRoman, 'left', '#464545', '#f7f7f7', 0, 0, 0, 1, false);

// navigation fonts
replaceText('#header li.current span', frutigerBold, 'center', '#464545', '#2b2b2b', 3, 6, 3 - 1, 6, true);
replaceText('#header li span', frutigerBold, 'center', '#c5c6c6', '#2b2b2b', 3, 6, 3 - 1, 6, true);
replaceText('#content-header li.current span', frutigerBold, 'center', '#464545', '#f7f7f7', 12, 19, 19 - 2, 5, true);
replaceText('#content-header li span', frutigerBold, 'center', '#959494', '#f7f7f7', 12, 12, 15 - 2, 12, true);
replaceText('#sub-nav li.current span', frutigerRoman, 'center', '#474747', '#f7f7f7', 0, 0, 1, 1, true);
replaceText('#sub-nav li span', frutigerRoman, 'center', '#9b9a9a', '#f7f7f7', 0, 0, 1, 1, true);

// buttons
replaceText('.button.left-image span', frutigerBold, 'left', '#959494', '#f7f7f7', 3 + 1, 16, 10 - 1, 10, true);
replaceText('.button.right-image span', frutigerBold, 'left', '#959494', '#f7f7f7', 3 + 1, 41, 10 - 1, 7, true);
replaceText('.button.no-text span', frutigerBold, 'left', '#959494', '#f7f7f7', 3 + 1, 20, 10 - 1, 15, true);
replaceText('.button span', frutigerBold, 'left', '#959494', '#f7f7f7', 3 + 1, 16, 10 - 1, 10, true);

// other fx
$(document).ready(function() {
	// FAQ accordion
	$('.faq').accordion({ collapsible: true, active: 'false', autoHeight: false, header: 'a.header' });

	// clickable elements
	$('.clickable').click(function() {
		if($(this).find('a.blockLink').attr('target') == '_blank'){
			window.open($(this).find('a.blockLink').attr('href'));
			} else {
				document.location.href = $(this).find('a.blockLink').attr('href');
				}
	});
});/**/

// utility functions

function replaceText(selector, font, align, color, backgroundColor, paddingTop, paddingRight, paddingBottom, paddingLeft, noWrap)
{
	sIFR.replace(font, {
		selector: selector,
		css: '.sIFR-root a { color: ' + color + '; text-decoration: none; cursor: pointer; } .sIFR-root a:hover { color: ' + color + '; cursor: pointer; } .sIFR-root { color: ' + color + '; background-color: ' + backgroundColor + '; text-align: ' + align + '; margin-left: ' + paddingLeft + '; margin-right: ' + paddingRight + '; }',
		offsetTop: paddingTop,
		preventWrap: noWrap,
		forceSingleLine: noWrap,
		wmode: 'transparent',
		antiAliasType: 'normal', // or 'advanced'
		tuneHeight: paddingBottom - 2,
		tuneWidth: paddingLeft + paddingRight
	});
}

function showPopup()
{
	$('#popup').modal({
		overlayCss: {
			backgroundColor: '#000000',
			cursor: 'wait'
		},
		onOpen: function(dialog) {
			dialog.overlay.fadeIn(500, function() {
				dialog.container.show();
				dialog.data.show();

				// fix sIFR
				replaceText('#popup h2', frutigerCn, 'left', '#464545', '#f7f7f7', 0, 0, false);
				replaceText('#popup .button.right-image span', frutigerBold, 'left', '#959494', '#f7f7f7', 3 + 1, 41, 10 - 1, 7, true);

				// fix PNGs
				if ($.layout.name == 'trident' &&  $.layout.versionX < 7) {
					DD_belatedPNG.fix('#popup, img');
				}
			});
		},
		onClose: function(dialog) {
			dialog.container.hide();
			dialog.data.hide();
			dialog.overlay.fadeOut(500, function() {
				$.modal.close();
			});
		}
	});
}

