    $(function() {




var anchorek = location.hash;


if (anchorek == '#notowania') {
	/*$("#nav_ul a[rel], #nota a[rel]").overlay({*/
        $("#overlay_notowania").overlay({
                load: true,
                top: 20,
                mask: '#000',
		effect: 'apple',
                fixed: false,
                api:true,
                closeOnClick : false,

		onBeforeLoad: function() {
			var wrap = this.getOverlay().find(".contentWrap");
			wrap.load("/ajax/notowania_new.php", function(){
                        
                        

                    $('#exposeMask').next().remove();
                                                $(document).ajaxStart(function(){
                                                        $('#whole').html('<img style="" src="../pic/ajaxloader.gif" />');
                                                        
                                                        
                                                });
                                                $(document).click(function() {
                                                    if ($('div.schowane_rynki').is(':visible'))
                                                        $('div.schowane_rynki').slideUp();

                                                    if ($('div.schowane_produkty').is(':visible'))
                                                        $('div.schowane_produkty').slideUp();
                                                });

                                                $('input.rynek_show').click(function(e){
                                                            $('div.schowane_rynki').slideToggle();
                                                            e.stopPropagation();
                                                });

                                                $('img.rozwin_rynki').click(function(e){
                                                            $('div.schowane_rynki').slideToggle();
                                                            e.stopPropagation();
                                                });


                                                $('input.produkt_show').click(function(e){
                                                    $('div.schowane_produkty').slideToggle();
                                                    e.stopPropagation();
                                                });

                                                $('img.rozwin_produkty').click(function(e){
                                                    $('div.schowane_produkty').slideToggle();
                                                    e.stopPropagation();
                                                });


                                                $('.item1').hover(
                                                function(){
                                                    $(this).removeClass('item1');
                                                    $(this).addClass('item1_hover');
                                                },
                                                function()  {
                                                    $(this).removeClass('item1_hover');
                                                    $(this).addClass('item1');
                                                }
                                                );

                                                $('.item1').click(function(){
                                                    id = $(this).attr('id');
                                                    tresc = $(this).attr('tresc');
                                                   //$(this).parent().prev('input').val(wartosc);
                                                   $('input.rynek').val(id);
                                                   $(this).parent().prev('input').prev().val(tresc);
                                                   $(this).parent().slideToggle();
                                                });


                                                $('.item2').hover(
                                                function(){
                                                    $(this).removeClass('item2');
                                                    $(this).addClass('item2_hover');
                                                },
                                                function()  {
                                                    $(this).removeClass('item2_hover');
                                                    $(this).addClass('item2');
                                                }
                                                );

                                                $('.item2').click(function(){
                                                    id = $(this).attr('id');
                                                    tresc = $(this).attr('tresc');
                                                    $('input.produkt').val(id);
                                                   $(this).parent().prev('input').prev().val(tresc);
                                                   $(this).parent().slideToggle();
                                                });


                                                        var dateMin = new Date();
                                                        var curr_date = dateMin.getDate();
                                                            if (curr_date.toString().length == 1)
                                                                curr_date = '0' + curr_date.toString();
                                                        var curr_month = dateMin.getMonth()+1;
                                                            if (curr_month.toString().length == 1)
                                                                curr_month = '0' + curr_month.toString();
                                                        var curr_year = dateMin.getFullYear();


                                               $("#data").datepicker(
                                                        {
                                                                minDate: new Date(2010, 6 - 1, 24),
                                                                maxDate: dateMin,
                                                                yearRange: '-90:+0',
                                                                dateFormat: 'yy-mm-dd',
                                                      numberOfMonths: 1,
                                                      firstDay: 1,
                                                      current: $(this).val(),
                                                      changeFirstDay: false,
                                                      monthNames:['Styczeń','Luty','Marzec','Kwiecień','Maj','Czerwiec','Lipiec','Sierpień','Wrzesień','Październik','Listopad','Grudzień'],
                                                        dayNamesMin: [ 'Nd','Po', 'Wt', 'Śr', 'Cz', 'Pt', 'So']

                                                });


                                                if ($("#data").val() == "")
                                                            $("#data").val(curr_year + "-" + curr_month + "-" + curr_date);




                            $('.submit').click(function() {
                                
                                $.post('/ajax/notowania_kontroler.php',{pRynek : $('.rynek').val(), pData : $('#data').val(), pGrupa: $('.produkt').val()},function(xml){
                                    $('#whole').html(xml);
                                    var wys = $('#whole').height();
                                    var wys2 = $('#wrapper').height();
                                    if (wys > wys2) {
                                        wys = wys+300;
                                        $('#exposeMask').height(wys);
                                    }else {
                                        wys2 = wys2 +300;
                                        $('#exposeMask').height(wys2);
                                    }
                                    
                                    
                                });

                            return false;

                            });

                                    /* DRUKOWANSKO */
                                    var do_druku = $("#whole");

                                    $('#drukuj').click(function(){
                                        do_druku.jqprint({ operaSupport: true });
                                    });


                            $.post('/ajax/notowania_kontroler.php',{pRynek : $('.rynek').val(), pData : $('#data').val(), pGrupa: $('.produkt').val()},function(xml){
                                    $('#whole').html(xml);
                                    var wys = $('#whole').height();
                                    var wys2 = $('#wrapper').height();
                                    if (wys > wys2) {
                                        wys = wys+300;
                                        $('#exposeMask').height(wys);
                                    }else {
                                        wys2 = wys2 +300;
                                        $('#exposeMask').height(wys2);
                                    }
                            });
                        });





		}
                


	});
}






$("#nav_ul a[rel], #nota a[rel],div.seeRate a[rel], a.notFromBaner[rel]").overlay({

                top: 20,
                mask: '#000',
		effect: 'apple',
                fixed: false,
                api:true,
                closeOnClick : false,

		onBeforeLoad: function() {
                        window.location.hash = 'notowania';
			var wrap = this.getOverlay().find(".contentWrap");
                        var link = this.getTrigger().attr("id");
                        
			wrap.load("/ajax/notowania_new.php"+link, function(){


                    $('#exposeMask').next().remove();
                                                $(document).ajaxStart(function(){
                                                        $('#whole').html('<img style="" src="../pic/ajaxloader.gif" />');


                                                });
                                                $(document).click(function() {
                                                    if ($('div.schowane_rynki').is(':visible'))
                                                        $('div.schowane_rynki').slideUp();

                                                    if ($('div.schowane_produkty').is(':visible'))
                                                        $('div.schowane_produkty').slideUp();
                                                });

                                                $('input.rynek_show').click(function(e){
                                                            $('div.schowane_rynki').slideToggle();
                                                            e.stopPropagation();
                                                });

                                                $('img.rozwin_rynki').click(function(e){
                                                            $('div.schowane_rynki').slideToggle();
                                                            e.stopPropagation();
                                                });


                                                $('input.produkt_show').click(function(e){
                                                    $('div.schowane_produkty').slideToggle();
                                                    e.stopPropagation();
                                                });

                                                $('img.rozwin_produkty').click(function(e){
                                                    $('div.schowane_produkty').slideToggle();
                                                    e.stopPropagation();
                                                });


                                                $('.item1').hover(
                                                function(){
                                                    $(this).removeClass('item1');
                                                    $(this).addClass('item1_hover');
                                                },
                                                function()  {
                                                    $(this).removeClass('item1_hover');
                                                    $(this).addClass('item1');
                                                }
                                                );

                                                $('.item1').click(function(){
                                                    id = $(this).attr('id');
                                                    tresc = $(this).attr('tresc');
                                                   //$(this).parent().prev('input').val(wartosc);
                                                   $('input.rynek').val(id);
                                                   $(this).parent().prev('input').prev().val(tresc);
                                                   $(this).parent().slideToggle();
                                                });


                                                $('.item2').hover(
                                                function(){
                                                    $(this).removeClass('item2');
                                                    $(this).addClass('item2_hover');
                                                },
                                                function()  {
                                                    $(this).removeClass('item2_hover');
                                                    $(this).addClass('item2');
                                                }
                                                );

                                                $('.item2').click(function(){
                                                    id = $(this).attr('id');
                                                    tresc = $(this).attr('tresc');
                                                    $('input.produkt').val(id);
                                                   $(this).parent().prev('input').prev().val(tresc);
                                                   $(this).parent().slideToggle();
                                                });


                                                        var dateMin = new Date();
                                                        var curr_date = dateMin.getDate();
                                                            if (curr_date.toString().length == 1)
                                                                curr_date = '0' + curr_date.toString();
                                                        var curr_month = dateMin.getMonth()+1;
                                                            if (curr_month.toString().length == 1)
                                                                curr_month = '0' + curr_month.toString();
                                                        var curr_year = dateMin.getFullYear();


                                               $("#data").datepicker(
                                                        {
                                                                minDate: new Date(2010, 6 - 1, 24),
                                                                maxDate: dateMin,
                                                                yearRange: '-90:+0',
                                                                dateFormat: 'yy-mm-dd',
                                                      numberOfMonths: 1,
                                                      firstDay: 1,
                                                      current: $(this).val(),
                                                      changeFirstDay: false,
                                                      monthNames:['Styczeń','Luty','Marzec','Kwiecień','Maj','Czerwiec','Lipiec','Sierpień','Wrzesień','Październik','Listopad','Grudzień'],
                                                        dayNamesMin: [ 'Nd','Po', 'Wt', 'Śr', 'Cz', 'Pt', 'So']

                                                });


                                                if ($("#data").val() == "")
                                                            $("#data").val(curr_year + "-" + curr_month + "-" + curr_date);




                            $('.submit').click(function() {

                                $.post('/ajax/notowania_kontroler.php',{pRynek : $('.rynek').val(), pData : $('#data').val(), pGrupa: $('.produkt').val()},function(xml){
                                    $('#whole').html(xml);
                                    var wys = $('#whole').height();
                                    var wys2 = $('#wrapper').height();
                                    if (wys > wys2) {
                                        wys = wys+300;
                                        $('#exposeMask').height(wys);
                                    }else {
                                        wys2 = wys2 +300;
                                        $('#exposeMask').height(wys2);
                                    }

                                });

                            return false;

                            });


                                /* DRUKOWANSKO */
                                    var do_druku = $("#whole");

                                    $('#drukuj').click(function(){
                                        do_druku.jqprint({ operaSupport: true });
                                    });

                            $.post('/ajax/notowania_kontroler.php',{pRynek : $('.rynek').val(), pData : $('#data').val(), pGrupa: $('.produkt').val()},function(xml){
                                    $('#whole').html(xml);
                                    var wys = $('#whole').height();
                                    var wys2 = $('#wrapper').height();
                                    if (wys > wys2) {
                                        wys = wys+300;
                                        $('#exposeMask').height(wys);
                                    }else {
                                        wys2 = wys2 +300;
                                        $('#exposeMask').height(wys2);
                                    }
                            });
                        });


                                    


		}



	});
});


