$(document).ready(function(){

//	$('#sponsorSlide').attr('scrollamount', '1');
//	$( '#sponsorSlide' ).mouseover( function(){ $('#sponsorSlide').attr('scrollamount', '0'); });
//	$( '#sponsorSlide' ).mouseout( function(){ $('#sponsorSlide').attr('scrollamount', '1'); });
//
//	$('div#infoSlide marquee').marquee('pointer', 50).mouseover(function () {
//			$(this).trigger('stop');
//	}).mouseout(function () {
//			$(this).trigger('start');
//	}).mousemove(function (event) {
//			if ($(this).data('drag') == true) {
//					this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
//			}
//	}).mousedown(function (event) {
//			$(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
//	}).mouseup(function () {
//			$(this).data('drag', false);
//	});


   // Use the each() method to gain access to each of the elements attributes
   $('a.descriptionText').each(function() {
      $(this).qtip({
         content: $(this).parent().children('div.toolText').html(), // Give it some content
         position: 'topRight', // Set its position
         hide: {
            fixed: true // Make it fixed so it can be hovered over
         },
				 style: {
					 width: {
							min: 150,
							max: 250
					 },
					 background: 'transparent',
					 classes: { tooltip: 'toolTextBlock' }
				 }
      });
   });



	// obsługa axajowych informacji
//	$('.tooltip').tooltip({
//		track: false,
//		showURL: false,
//    bodyHandler: function() {return $( $(this).parent().children('div.toolText') ).html(); },
//		fixPNG: false,
//		left: 0,
//		top: 10,
//		positionLeft: true
//	});

	/* --------- obsługa kalendarza ---------------*/

	$('a.ui-state-default').mouseover( function(){$( this ).addClass('ui-state-hover');});
	$('a.ui-state-default').mouseout( function(){$( this ).removeClass('ui-state-hover');});
	$('a#calendar_next, a#calendar_prev').click( function(){getCalendar( this );});
	$('select#monthSelectList, select#yearSelectList').change(function(){
		getCalendar( $(this).children('option:selected') );
	});

	function getCalendar( calendar ){
		var month	= $( calendar ).attr('month');
		var year	= $( calendar ).attr('year');

		$.ajax({
			type: "POST",
			url: "/pobierzKalendarz.html",
			data: "month="+month+"&year="+year,
			beforeSend: function(){
				$('div#calendarData').block({
						message: '<div><img src="/_images/loading_green.gif"></div><div style="font-weight: bold;">proszę czekać</div>',
						css:{background: 'transparent', border: '0px', width: '100px'},
						overlayCSS: {backgroundColor: '#F6F0DA', opacity: .75}
				});
			},
			success: function( data ){
				$('div#calendarData').html( data );
				$('a.ui-state-default').mouseover( function(){$( this ).addClass('ui-state-hover');});
				$('a.ui-state-default').mouseout( function(){$( this ).removeClass('ui-state-hover');});
				$('a#calendar_next, a#calendar_prev').click( function(){getCalendar( this );});
				$('select#monthSelectList, select#yearSelectList').change(function(){
					getCalendar( $(this).children('option:selected') );
				});

				// obsługa axajowych informacji
			 $('a.descriptionText').each(function() {
					$(this).qtip({
						 content: $(this).parent().children('div.toolText').html(), // Give it some content
						 position: 'topRight', // Set its position
						 hide: {
								fixed: true // Make it fixed so it can be hovered over
						 },
						 style: {
							 width: {
									min: 150,
									max: 250
							 },
							 background: 'transparent',
							 classes: { tooltip: 'toolTextBlock' }
						 }
					});
			 });

			},
			complete: function(){
				$('div#calendarData').unblock();
			}
		});
	}

	/* --------- obsługa kalendarza ---------------*/


	// obsługa galerii zdjęć
	$('a.galeryImage').lightBox({txtImage: 'Zdjęcie', txtOf: 'z'});


  // Add Scroller Object
  $jScroller.add("#slideSponsor","#slideSponsorTable","up",1,true);
	$jScroller.config.refresh = 40;

  // Start Autoscroller
  $jScroller.start();

});
