function clearField(e,v)
{
	if ( e && v ) {
		if ( e.value == v ) e.value = "";
	}
}

function print() { 
	window.open('?'+printLink+'&print=1','print','scrollbars=yes,status=no,width=600,height=600');
}

function showhide( link, blockId ) {
	if( document.getElementById( blockId ).style.display=='none' ) {
		document.getElementById( blockId ).style.display = '';
	}
	else {
		document.getElementById( blockId ).style.display = 'none';
	}
	link.blur();
}

function showhide1( link, blockId, count, index )
{
	for ( i = 1; i <= count; i++ ) {
		var currentBlockId = blockId + i;
		if ( i == index ) {
			document.getElementById( currentBlockId ).style.display = '';
		}
		else {
			document.getElementById( currentBlockId ).style.display = 'none';
		}
	}
	link.blur();
}

this.tooltip = function(){
	$("area.tt").hover(function(e){
		$("body").append("<p id='tmptt'>" + $("#tt" + this.id).html() + "</p>");
		$("#tmptt")
			.css("top",(e.pageY - 10) + "px")
			.css("left",($(this).offset().left + 240) + "px")
			.fadeIn("fast");
	},
	function(){
		$("#tmptt").remove();
   });
};

function flipflop(e1,e2)
{
	$('#'+e1).hide();
	$('#'+e2).show();
}

function calcAdjustPeriodForName(n, l)
{
	$('#calcSelectPeriod').load('ajaxindex.php?action=BSCalculators&start=showPeriod&name=' + n + '&lang=' + l);
}

/* kalejdoskop */
var currentNx = 1;
var maxNx = 0;

function showNx(i)
{
	$('.nx_all').hide();
	$('#nx_' + i).show();
	$('#nx_nav li a').removeClass('active');
	$('#nxn_' + i).addClass('active');
	currentNx = i;
}

function showNxPrev()
{
	currentNx--;
	if ( currentNx < 1 ) {
		currentNx = maxNx;
	}
	showNx(currentNx);
}

function showNxNext()
{
	currentNx++;
	if ( currentNx > maxNx ) {
		currentNx = 1;
	}
	showNx(currentNx);
}
/* /kalejdoskop */

$(document).ready(function(){
	tooltip();
	$(".bondttlink").click(function(e){
		$("body").append('<p id="bondtt"></p>');
		$("#bondtt")
			.load('?page=' + $(this).attr('rel') + '&nazwa=' + $(this).text())
			.css("top",(e.pageY + 15) + "px")
			.css("left",(e.pageX + 15) + "px")
			.fadeIn("fast");
	});

	// kalejdoskop
	if ( $('.nx_all').length > 0 ) {
		maxNx = $('.nx_all').length;
		setInterval('showNxNext()', 10000);
	}
	
});
