/*
 * jQuery UI - worker
 *
 */

$(document).ready( function() {
        //$(".showPopupWin").mouseover( function() {
        $(".showPopupWin").click( function() {
                $(".ui-dialog-titlebar-close").trigger('click')
                var pos = $(this).position();
                var dialog = $('<div class="dialogWin" ></div>').insertAfter(this);
                $(dialog).attr('title',$(this).attr('title'));
                $(dialog).load("/ajax_popup_win.php" + $(this).attr('href').replace("#",""), function() {
                        var d_width = $(dialog).width() + 20;
                        var d_left = pos.left;
                        if ( (d_left + d_width) > $(window).width() ) {
                                d_left = d_left + $(window).width() - (d_left + d_width) - 10;
                        }
                        var d_top = pos.top + 15;
			$(dialog).dialog({
                                resizable: true,
                                draggable: true,
                                modal: false, 
                                //modal: true,
                                width: d_width,
                                title: $(this).attr('title'), 
								close: function(ev, ui) {
									$(this).remove();
									$("#dialogWinTextEl").removeAttr('id');
									$("#dialogWinHiddenEl").removeAttr('id');
								}                        });
                        $(".ui-dialog").css('top', d_top );
                        $(".ui-dialog").css('left', d_left );
                });
        });

        //$(".inDatepicker").datepicker( {dateFormat: 'dd/mm/yy', showMonthAfterYear: false } );

		// colorbox
		$("a[rel='gal1']").colorbox();
		$("a[rel='gal2']").colorbox();
		$("a[rel='gal3']").colorbox();
		$("a[rel='gal4']").colorbox();
		$("a[rel='gal5']").colorbox();
		$("a[rel='gal6']").colorbox();
		$("a[rel='gal7']").colorbox();
		$("a[rel='gal8']").colorbox();
		$("a[rel='gal9']").colorbox();
		$("a[rel='gal10']").colorbox();
		$("a[rel='gal11']").colorbox();
		$("a[rel='gal12']").colorbox();
		$("a[rel='gal13']").colorbox();
		$("a[rel='gal14']").colorbox();
		$("a[rel='gal15']").colorbox();
		$("a[rel='gal16']").colorbox();
		$("a[rel='gal17']").colorbox();
		$("a[rel='gal18']").colorbox();
		$("a[rel='gal19']").colorbox();
		$("a[rel='gal20']").colorbox();
		$("a[rel='gal21']").colorbox();
		$("a[rel='gal22']").colorbox();
		$("a[rel='gal23']").colorbox();
		$("a[rel='gal24']").colorbox();
		$("a[rel='gal25']").colorbox();
		$("a[rel='gal26']").colorbox();
		$("a[rel='gal27']").colorbox();
		$("a[rel='gal28']").colorbox();
		$("a[rel='gal29']").colorbox();
		$("a[rel='gal30']").colorbox();
		$("a[rel='gal31']").colorbox();
		$("a[rel='gal32']").colorbox();
		$("a[rel='gal33']").colorbox();
		$("a[rel='gal34']").colorbox();
		$("a[rel='gal35']").colorbox();

		$(document).bind('cbox_open', function(){ 
			$('#Unie-150x150').css({'visibility':'hidden'}); 
			$('#Vzory-smluv-150x150').css({'visibility':'hidden'}); 
		}).bind('cbox_cleanup', function(){ 
		    $('#Unie-150x150').css({'visibility':'visible'});
		    $('#Vzory-smluv-150x150').css({'visibility':'visible'}); 
		}); 


	/* *** dropdownchecklist part BEGIN *** */
	$('#ddcList').dropdownchecklist( {
		width: $('#ddcList').width() - 15,
		firstItemChecksAll: true,
		maxDropHeight: 400
	} );
	/* *** dropdownchecklist part BEGIN *** */

	/* *** jquery ui datepicker -- function BEGIN *** */
	$(".inDatepicker").datepicker( {
		dateFormat: 'dd.mm.yy', 
		showOtherMonths: true, 
		showMonthAfterYear: false,  
		showAnim: 'slideDown',  
		showOn: 'focus', 
		showWeek: true, 
		weekHeader: 'Tęden' 
	} );
	/* *** jquery ui datepicker -- function END *** */

	var getTooltipContent = function() {
		var ret = $(this).next('div.showTooltipContent').html();
		if ( ret ) { return ret; } 
		else { return this.tooltipText; }
	}

	$('.showTooltip').tooltip({
		bodyHandler: getTooltipContent,
		track: true,
		delay: 0,
		showURL: false,
		showBody: " - ",
		fade: false,
		left: 5,
		top: 5
	});

} );
/*
         $(document).ready(function(){
            //Examples of how to assign the ColorBox event to elements
            $("a[rel='example1']").colorbox();

            $("a[rel='example3']").colorbox({transition:"none", width:"75%", height:"75%"});
            $("a[rel='example4']").colorbox({slideshow:true});
            $(".example5").colorbox();
            $(".example6").colorbox({iframe:true, innerWidth:425, innerHeight:344});
            $(".example7").colorbox({width:"80%", height:"80%", iframe:true});
            $(".example8").colorbox({width:"50%", inline:true, href:"#inline_example1"});
            $(".example9").colorbox({
               onOpen:function(){ alert('onOpen: colorbox is about to open'); },
               onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); },
               onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); },
               onCleanup:function(){ alert('onCleanup: colorbox has begun the close process'); },
               onClosed:function(){ alert('onClosed: colorbox has completely closed'); }
            });
            
            //Example of preserving a JavaScript event for inline calls.
            $("#click").click(function(){ 
               $('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
               return false;
            });
         });*/
