$(document).ready(function(){
	
	$('#slideshow a').lightBox();
	
	$('a.js_slide').click(function() {
		$(this).next().toggle();
	});


   //font style
    Cufon.replace('.cufon', {
        hover: true
    });

    $(function(){
    	  $('#slider').bxSlider({
    	    displaySlideQty: 20,
    	    moveSlideQty: 1,

    	    ticker: true,
    	    tickerSpeed: 1000,
    	    infiniteLoop: true,
    	    /*
    	    auto: true,
    	    autoHover: true,
    	    */
    	    controls: false
    	  });
    	  
    	});
/*
	$(function(){
		$("#slider").jMyCarousel({  
	        visible: '100%',
	        auto: true,
	        speed: 1000,
	        eltByElt: false,
	        circular: true,
	        easing: "linear"
	    });
	});
*/
    $(function() {
    	$('.page-gallery a').lightBox({
    		fixedNavigation:true,
    		txtImage: "",
    		txtOf: "z",
			imageLoading: '/static/img/layout/lightbox-ico-loading.gif',
			imageBtnClose: '/static/img/layout/lightbox-btn-close.gif',
			imageBtnPrev: '/static/img/layout/lightbox-btn-prev.gif',
			imageBtnNext: '/static/img/layout/lightbox-btn-next.gif'
    	});
    });
    
    $(function() {
    	setInterval( "slideSwitch()", 5000 );
    });
    
   //contact form
   $("#contactForm form dl dd *").focus(function() {
	   if($(this).val() == 'Imię i nazwisko' || $(this).val() == 'E-mail' || $(this).val() == 'TrePć wiadomoPci'){
		   $(this).val('');
	   }
        
   });
   
   $("#contactForm form dl dd *").blur(function() {
	   if($(this).val() == ''){
		   if($(this).attr('name') == 'name'){
			   $(this).val('Imię i nazwisko');
		   }
		   if($(this).attr('name') == 'email'){
			   $(this).val('E-mail');
		   }
		   if($(this).attr('name') == 'content'){
			   $(this).val('TrePć wiadomoPci');
		   }
		   
	   }
        
   });

   $("#spolki-slider").easySlider({
		auto: true,
		continuous: true,
		controlsShow: false,
		speed: 800,
		pause: 3000
	});

   /* google map start */
   mapaStart();
   
   

})

function slideSwitch() {
        var $active = $('#image_container IMG.active');

        if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

        var $next =  $active.next().length ? $active.next()
            : $('#image_container IMG:first');

        $active.addClass('last-active');

        $next.css({opacity: 0.0})
            .addClass('active')
            .animate({opacity: 1.0}, 1000, function() {
                $active.removeClass('active last-active');
            });
    }


var mapa;
function mapaStart() {
  var geo = new GClientGeocoder();
  /* adres */
  var adres = 'Kraków, Kosynierów 15 B';
  geo.getLatLng(adres,function(punkt) {
      if(punkt) {
    	  
          if (GBrowserIsCompatible()) {
                  var mapa = new GMap2(document.getElementById("google-map"), { size: new GSize(310, 200) }); // !
                  mapa.addControl(new GLargeMapControl());
                  mapa.addControl(new GMapTypeControl());
                  mapa.setCenter(punkt, 15);
                  var marker = new GMarker(punkt, {title: adres, clickable: false});
                  mapa.addOverlay(marker);
          }

      }
  });

}
