Cufon.now();
Cufon.replace('#main h1, #main h2, #main h3', { fontFamily: 'Alwyn New Th', hover: true});

$(function(){
 
	$.fn.scrollToTop=function(){
		$("#goTop").hide();
		if($(window).scrollTop()!="0"){ $(this).fadeIn("slow");}
		var scrollDiv = $(this);
		$(window).scroll(function(){ if($(window).scrollTop()=="0"){ $(scrollDiv).fadeOut("slow"); }else{	$(scrollDiv).fadeIn("slow");}});
		$(this).click(function(){ $("html, body").animate({scrollTop:0},"slow"); });
	};
	
	// banks icon
	var move_top = '0%';
	var move_left = '0%';
	$('.banks .bank').hover(function() {
		width = 80+'px';
		height = 50+'px';
		
		$(this).find('img').stop(false,true).animate({'width':width,  'top':move_top, 'left':move_left}, {duration:200});
	},
	function() {
		$(this).find('img').stop(false,true).animate({'width':'28px',  'top':'50%', 'left':'50%'}, {duration:100});	
	});
});
$(function() {
	$("#goTop").scrollToTop();
});

$(document).ready(function(){
	Shadowbox.init({overlayOpacity: 0.8});

	var flashvars = {};
	var params = {wmode:"opaque"};
	var attributes = {};
	swfobject.embedSWF("smarty/images/new/banki.swf","banks","970","57","9.0.115","false", flashvars, params, attributes);

	/*
	$('#table_ico td img').click(function(){			
		$('#table_ico_source div').show();
		$con = $('#table_ico_source div#html_source div.cont');
		$conl = $('#table_ico_source div#html_source div.cont').text().length;
		if($conl==0 || $conl !='						&nbsp;')
		{
			$('#table_ico_source div#html_source div.cont').html('<img src="'+ $(this).attr('src') +'" />'+'<textarea cols="85" rows="4"><a href="http://www.payu.pl/?utm_source=partners&utm_medium=ban&utm_campaign=partners"><img alt="'+$(this).attr('alt')+'" src="http://www.payu.pl/'+$(this).attr('src')+'" /></a></textarea>');
		}
		else
		{
			//$('#table_ico_source div#html_source div.cont img').attr('src', $(this).attr('src')).attr('alt', $(this).attr('alt'));
		}
	});
	$('#table_ico2 td img').click(function(){			
		$('#table_ico_source2 div').show();
		$con = $('#table_ico_source2 div#html_source div.cont');
		$conl = $('#table_ico_source2 div#html_source div.cont').text().length;
		if($conl==0 || $conl !='						&nbsp;')
		{
			$('#table_ico_source2 div#html_source div.cont').html('<img src="'+ $(this).attr('src') +'" />'+'<textarea cols="85" rows="4"><a href="http://www.payu.pl/?utm_source=partners&utm_medium=ban&utm_campaign=partners"><img alt="'+$(this).attr('alt')+'" src="http://www.payu.pl/'+$(this).attr('src')+'" /></a></textarea>');
		}

	});
	*/
	$('#table_ico td img,#table_ico2 td img').click(function(){
		showHtmlPopup('<textarea cols="85" rows="4"><a href="http://www.payu.pl/?utm_source=partners&utm_medium=ban&utm_campaign=partners"><img alt="'+$(this).attr('alt')+'" src="http://www.payu.pl/'+$(this).attr('src')+'" /></a></textarea>');
	});
});

function showHtmlPopup(txt)
{
	if($('.intPopup').length==0)
		$('body').append('<div class="intPopup"><div id="intPopupMask"></div><div id="intPopupBox"><div id="intPopupCls"><span></span></div><div id="intPopupCont"></div></div></div>');
	
	$('#intPopupCont').html(txt);
	$('#intPopupBox').css({
		'top': $getYPosition,
		'left': $getXPosition
	});
	$('.intPopup').css({
		'visibility': 'visible',
		'width': $(window).width(),
		'height': $(window).height()
	}).fadeIn();
	
	$('#intPopupCls span').click(function(){$('.intPopup').fadeOut().remove();});
}

$getYPosition = function()
{
	var top_pos = Math.round( ($(window).height() - $('#intPopupBox').height()) * 0.5 );
	if(top_pos < 0 || top_pos + $('#intPopupBox').height() > $(window).width())	{ top_pos = 0; }
	
	return top_pos;
};
$getXPosition = function()
{
	var left_pos = Math.round( ($(window).width() - $('#intPopupBox').width()) * 0.5 );
	left_pos = (left_pos < 0 ? 0 : left_pos);
	
	return left_pos;
};
