//swf
swfobject.registerObject("mapa_serwis062010", "9.0.0", "/assets/flash/expressInstall.swf");
swfobject.registerObject("abbott_mapka_dzial_handlowy2011-02-14", "9.0.0", "/assets/flash/expressInstall.swf");
swfobject.registerObject("gold_standardization", "9.0.0", "/assets/flash/expressInstall.swf");

var externalLink = function(e){
	if( $(this).attr('rel') === '_external' ){
		e.preventDefault();
		window.open( $(this).attr('href'), 'NewWindow' );
		$('#zewnetrznyLink').hide();
	} else if( $(this).attr('rel') === '_externalPopup' ) {
		e.preventDefault();
		externalLinkPopup( $(this).attr('href') );
	} else if ( $(this).attr("rel") === '_blank' ) {
		e.preventDefault();
		window.open( $(this).attr("href"), 'NewWindow'+Math.round(Math.random*100) );
	}
};

var externalLinkPopup = function(strAddress){
	$('#zewnetrznyLink').show();
	$('#zwLink').attr('href', strAddress);
};

$(document).ready(function(){
	var section = '.wrapper';
	var fontSizeNum = $.cookie('fontsize');
	if (fontSizeNum != null) $(section).css('font-size', fontSizeNum);

	// Increase Font Size
	$(".increaseFont").click(function(e){
		e.preventDefault();
		var currentFontSize = $(section).css('font-size');
		var currentFontSizeNum = parseInt(currentFontSize.slice(0, -2), 10) / 10.0 ;

		if (currentFontSizeNum <= 2.2) {
			var newFontSize = (currentFontSizeNum+0.2)+'em';
			$.cookie('fontsize', newFontSize);
			$(section).css('font-size', newFontSize);
		}
	});
	// Decrease Font Size
	$(".decreaseFont").click(function(e){
		e.preventDefault();
		var currentFontSize = $(section).css('font-size');
		var currentFontSizeNum = parseInt(currentFontSize.slice(0, -2), 10) / 10.0 ;
		if (currentFontSizeNum >= 0.8) {
			var newFontSize = (currentFontSizeNum-0.2)+'em';
			$.cookie('fontsize', newFontSize);
			$(section).css('font-size', newFontSize);
		}
	});

	$('.printPage').click(function(e){
		e.preventDefault();
		window.print();
	});

	$('#zwClose, .close.closeZ').click(function(e){
		e.preventDefault();
		$('#zewnetrznyLink').hide();
	});

	$('a').click(externalLink);

	$('#searchname, #searchname2')
	.focusin(function(){ if('Wpisz pytanie'==$(this).val()) $(this).val(''); })
	.focusout(function(){ if(''==$(this).val()) $(this).val('Wpisz pytanie'); });

	$('#content .toggle').click(function(e){
		e.preventDefault();
		$(this).next().toggle();
	});
});

