function menuRedirect( selObj, restore ) {
	eval( "document.location='" + selObj.options[ selObj.selectedIndex ].value + "'" );
	if( restore )
		selObj.selectedIndex = 0;
}

function submitForm( formName ) {
	document.forms[ formName ].submit();
}

function printPage() {
	var tPrintLink = 'index.php?' + printLink + '&_view=print';
	window.open( tPrintLink, 'print', 'scrollbars=yes,status=no,width=600,height=600' );
}

function updatePoviats( regionId, poviatId ) {
	$.post(
		'index.php',
		{
			page: 'ajax',
			get: 'poviatList',
			regionId: $(regionId).val()
		},
		function( data ) {
			$('#'+poviatId).html( $(data).find('response:first').text() );
		}
	)
}

function switchMap(nr)
{
	var altNr = ( nr == 1 ) ? 2 : 1;
	$('#mapa' + nr).removeClass("on");
	$('#mapa' + altNr).addClass("on");
	$('#mapa' + nr + 'Sub').html($('#mapa' + nr + 'Header').html()).show();
	$('#mapa' + altNr + 'Sub').hide();
	$('#mapa' + nr + 'Body').show();
	$('#mapa' + altNr + 'Body').hide();
	$('#mapa' + nr + 'Body li[id^=li_]').hide();
	$('#mapa' + nr + 'Body li[id^=li_]:first-child').show();
}

function toggleMapNode(nr, id, el)
{
	$('#mapa' + nr + 'Sub a').removeClass('on');
	$(el).addClass('on');
	$('#mapa' + nr + 'Body li[id^=li_]').hide();
	$('#li_' + id).show();
}

function showCombos(nr)
{
	$('#SubCombos'+nr).show();
}

function setNewsletterAction(action) { 
	if (action == 1) {
	 document.newsletter.act.value = 'out';
	} else {
	 document.newsletter.act.value = 'add';
	}
}

var overSelect = 0;
$(document).ready( function() {
	$('div[id^=SubCombos]').find('select').each( function() {
			$(this).bind("focus", function() { overSelect++; } );
			$(this).bind("blur", function() { overSelect--; } );
		});
	$('div[id^=SubCombos]')
		.bind("mouseleave", function(e){
			if( !overSelect ) {
				$('div[id^=SubCombos]').hide();
			}
		});
});
