function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(document).ready(function(){
	 
  	$('select[name="SortMiasta"]').change(
		function() {
			$('table.Pok tr').show();
			if (this.value=='') $('table.Pok tr').fadeIn();
			else $('table.Pok tr[class!="'+this.value+'"]').hide();
			$('table.Pok tr.Head').show();
			}
		);
	
	$('a.link_gorny').click(function() {
			
			rel = this.rel;
			
			$('div[class^=podmenu_]').hide();
			$('div.podmenu_'+rel).fadeIn('fast');
			
		});	
	
});

$(function() {
    setInterval( "slideSwitch()", 7000 );
	
	var i = 0;
	$('div#jAn div.Item').hide();
	$('div#jAn div.Item:first').show();
	$('div#jAn').everyTime(7000, function(i) {
		showNext(i);
	});
	$('a[name^="Item_"]').click(function() {
		var oBj = $('div#jAn div.Item');
		for (i = 0; i<oBj.length; i++) {
			if (i==this.name.split('_')[1]) $(oBj[i]).fadeIn('slow'); 
			else $(oBj[i]).hide();
			}
		$('div#jAn').stopTime();
		$('div#jAn').everyTime(7000, function(i) {
			showNext(i);
		});
	});


var i = 0;
	$('div#haslo p.Itemp').hide();
	$('div#haslo p.Itemp:first').show();
	$('div#haslo').everyTime(7000, function(i) {
		showNextp(i);
	});
	$('a[name^="Item_"]').click(function() {
		var oBj = $('div#haslo p.Itemp');
		for (i = 0; i<oBj.length; i++) {
			if (i==this.name.split('_')[1]) $(oBj[i]).fadeIn('slow'); 
			else $(oBj[i]).hide();
			}
		$('div#haslo').stopTime();
		$('div#haslo').everyTime(7000, function(i) {
			showNextp(i);
		});
	});


	
	$('a.lightbox').lightBox(); // Select all links with lightbox class
	$('div#tresc a img').lightBox();
});

function zatrzymaj() {
	$('div#jAn').stopTime();
	$('div#haslo').stopTime();
}
function showNext(a) { 
	var oBj = $('div#jAn div.Item');
	var z = 0;
	for (i = 0; i<oBj.length; i++) {
		if ($(oBj[i]).is(":visible")) z = i;
		$(oBj[i]).hide();
	}
	z++;
	if (z>=oBj.length) z = 0;
	$(oBj[z]).fadeIn();
}

function showNextp(a) { 
	var oBj = $('div#haslo p.Itemp');
	var z = 0;
	for (i = 0; i<oBj.length; i++) {
		if ($(oBj[i]).is(":visible")) z = i;
		$(oBj[i]).hide();
	}
	z++;
	if (z>=oBj.length) z = 0;
	$(oBj[z]).fadeIn();
}


function showDiv(id) {
	$('div.GPW ul.Gray').hide();
	$('div.GPW ul.Orange').hide();
	$('div.GPW div.Gray').attr('class','Orange');
	$('div.GPW div#DIV_'+id).attr('class','Gray');
	$('div.GPW ul#UL_'+id).fadeIn();
}

function FAQ(id) {
	$('div.Faq p.FAQ').hide();
	$('div.Faq p.FAQ_'+id).fadeIn();

}

function load() {
    var a=12;
    var b=new GLatLng(50.703123, 16.737642);
    var c=new GMarker(b);
    if(GBrowserIsCompatible()) {
        var d=new GMap2(document.getElementById("map"));
        GEvent.addListener(c,"click",function() {
            alert("DSS")
        }
        );
        d.addControl(new GSmallZoomControl());
        d.setCenter(new GLatLng(50.703123, 16.737642),a);
        d.addOverlay(c)
    }
}
