
function wyliczLeftOkna(szerokosc)
{
	left_okna = window.getScrollLeft();
	width_okna = window.getWidth();
	x = left_okna + width_okna/2 - szerokosc/2;
	return (x<1 ? 1 : x);
}

function wyliczTopOkna(wysokosc)
{
	top_okna = window.getScrollTop();
	height_okna = window.getHeight();	
	y = top_okna + height_okna/2 - wysokosc/2;
	return (y<1 ? 1 : y);	
}

function fade(element_id, fade_in_enable, full_enable, onComplete_function)
{
	element = $(element_id);
	effect = element.effects({
			duration:500, 
			wait:false,
			onComplete: function()			
			{
				if (onComplete_function)
					onComplete_function();					
			}
	});
	if (full_enable)
		fade_to = '1';
	else
		fade_to = '.5';
	if (fade_in_enable)
		fade_rules = ['.0', fade_to];
	else
		fade_rules = [element.style.opacity, 0];
	effect.start(
		{
		"opacity" : fade_rules
		});
}

function iframe_wyslijWiadomoscForm()
{
	szerokosc = 620;
	wysokosc = 390;
	x_pos = wyliczLeftOkna(szerokosc);
	y_pos = wyliczTopOkna(wysokosc);
	window123 = new Element('div',{
		id: 'window_wiadomosc',
		styles : {
			'background-color': 'white',
			'border-style' : 'double solid',
			'z-index':999,
			opacity:0,
			width: szerokosc,
			height : wysokosc,
			position: 'absolute',
			left: x_pos,
			top: y_pos
		}
	});
	tlo123 = new Element('div',{
		styles: {
			width:window.getScrollWidth(),
			height:window.getScrollHeight(),
			opacity:0,
			'background-color':'black',
			position:'absolute',
			left:0,
			top:0
		},
		id : 'windows123_sciana'
	});
	zamknij_div_str = '<div class="iframe_wiadomoscZamknij"><a href="" onclick="iframe_wW_CloseWindow();return false;">Zamknij</a></div>';
	window123.setHTML(zamknij_div_str+'<iframe width="'+szerokosc+'px" height="'+wysokosc+'px" src="/index.php?id=196&tipUrl='+document.location+'"></iframe>');
	//alert(window123.innerHTML);
	mountPoint = $E('body');
	tlo123.injectInside(mountPoint);
	window123.injectInside(mountPoint);
	fade('window_wiadomosc', true, true, false);
	fade('windows123_sciana', true, false, false);	
}

function iframe_wW_CloseWindow()
{
	var remove_func = function()
					{
						$('window_wiadomosc').remove();
						$('windows123_sciana').remove();					
					}
	fade('window_wiadomosc', false, false, false);
	fade('windows123_sciana', false, false, remove_func);
	return false;
}

// author: Bas Wenneker		website: http://www.solutoire.com
// Fx.FontPlus is MIT-Licensed

Fx.FontPlus = new Class({
	initialize: function(elements, sid, gid, gmid, growsize, growmoresize){
		this.growsize = (growsize) ? growsize : -2;
		this.growmoresize = (growmoresize) ? growmoresize : 2;
		
		this.elements = [];
 		elements.each(function(el){
			this.elements.push([el,el.getStyle('font-size').toInt()]);									   
		},this);
		
		$(gmid).onclick = function(){this.growmore()}.bind(this);
		$(gid).onclick = function(){this.shrink()}.bind(this);
		$(sid).onclick = function(){this.grow()}.bind(this);		
	},
	
	growmore: function(){
		this.elements.each(function(el){
			var currentfsize = el[0].getStyle('font-size').toInt();
			if(currentfsize == el[1])
				el[0].effect('font-size',{duration:300,unit:'px'}).custom(el[1],el[1]+this.growmoresize);
			else if(currentfsize == el[1]+this.growsize)
				el[0].effect('font-size',{duration:300,unit:'px'}).custom(el[1]+this.growsize,el[1]+this.growmoresize);			
		},this);							
	},
	
	grow: function(){		
		this.elements.each(function(el){
			var currentfsize = el[0].getStyle('font-size').toInt();
			if(currentfsize == el[1])
				el[0].effect('font-size',{duration:300,unit:'px'}).custom(el[1],el[1]+this.growsize);
			else if(currentfsize == el[1]+this.growmoresize)
				el[0].effect('font-size',{duration:300,unit:'px'}).custom(el[1]+this.growmoresize,el[1]+this.growsize);	
		},this);							
	},
	
	shrink: function(){
		this.elements.each(function(el){
			var currentfsize = el[0].getStyle('font-size').toInt();
			if(currentfsize == el[1]+this.growsize)
				el[0].effect('font-size',{duration:300,unit:'px'}).custom(el[1]+this.growsize, el[1]);
			else if(currentfsize == el[1]+this.growmoresize)
				el[0].effect('font-size',{duration:300,unit:'px'}).custom(el[1]+this.growmoresize, el[1]);
		},this);		
	}						
});


