$(document).ready(function(){


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

	/* --------- obsługa lewego menu --------------*/
	$('div.menu_left div.content2').css('display', 'none');
	/* $('div.menu_left div.content div.list1').click( function(){$('#id_menu_'+$( this ).attr('list') ).slideToggle('fast');}); */
	$('div.menu_left div.content div.list1').mouseover( function(){$( this ).addClass('over');});
	$('div.menu_left div.content div.list1').mouseout( function(){$( this ).removeClass('over');});
	$('div.menu_left div.content2 div.list2').mouseover( function(){$( this ).addClass('over');});
	$('div.menu_left div.content2 div.list2').mouseout( function(){$( this ).removeClass('over');});


	$("div#layout_left a").each(function(i){
		if( $( this ).attr('href').length > 1 ){
			var href = $( this ).attr('href');
			var loc = document.location.toString();
			if( loc.indexOf( href ) > 0 ){
				$( this ).parent().parent().css('display', 'block');
				id_list = $( this ).parent().attr('list');
				$('div#id_menu_'+id_list ).css('display', 'block');
			}
		}

	});


	/* --------- obsługa lewego menu --------------*/
	
	/* --------- 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#gmn_calendar_next, a#gmn_calendar_prev').click( function(){getCalendar( this );});

	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#gmn_calendar').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: '#FFFFFF', opacity: .75}
				});

			},
			success: function( data ){
				$('div#gmn_calendar').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#gmn_calendar_next, a#gmn_calendar_prev').click( function(){getCalendar( this );});

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

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

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


	/* --------- obsługa formularza wyszukiwarki szkoleń ---*/
	$('a#searchCourseMore').click( function(){
		if( $('div#searchCourseMoreBlock').css('display') == 'none' ){$('div#searchCourseMoreBlock').slideDown('fast');$( $( this ).html('&laquo; mniej') );}
		else{$('div#searchCourseMoreBlock').slideUp('fast');$( $( this ).html('wiecej &raquo;') );}
	});


	/* --------- obsługa formularza wyszukiwarki szkoleń ---*/



	/* inne elementy szkoleń */
	$( 'input#company_bill' ).click( function(){
		if( $( this ).attr('checked') ){$( 'div#company_bill_block' ).slideDown('fast');}
		else{$( 'div#company_bill_block' ).slideUp('fast');}
		
	});



});



