$(document).ready(function(){
    $(".menu > li > a").not(".open").find("+ ul").hide();
    $(".menu > li > a").click(function(){
        $(this).find("+ ul").slideToggle("fast");
    });
    $('.row_belt a').mouseover(function() {
        $(this).animate({
            backgroundColor: "#C39FDF"
        }, 'fast');
    });
    $('.row_belt a').mouseout(function(){
        $(this).animate({
            backgroundColor: "#FF0000"
        }, 'fast');
    });
    
	$("a.single_image").fancybox({
		'autoScale' : false
	});
	
	/* Using custom settings */
	
	$("a.inline").fancybox({
		'hideOnContentClick': true
	});

	/* Apply fancybox to multiple items */
	
	$("a.grouped_elements").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
                'titlePosition' 		: 'inside'
	});



       (function ($) {
        $.fn.fadeTransition = function(options) {
          var options = $.extend({pauseTime: 5000, transitionTime: 2000, ignore: null, delayStart: 100, pauseNavigation: false}, options);
          var transitionObject;

          Trans = function(obj) {
            var timer = null;
            var current = 0;
            var els = (options.ignore)?$("> *:not(" + options.ignore + ")", obj):$("> *", obj);
            
            
            if (options.delayStart > 0) {
              setTimeout(showFirst, options.delayStart);
            }
            else
              showFirst();

            function showFirst() {
              if (options.ignore) {
                $(options.ignore, obj).fadeOut(options.transitionTime);
                $(els[current]).fadeIn(options.transitionTime);
              }
              else {
                $(els[current]).css("display", "block");
              }
            }

            function transition(next) {
              $(els[current]).fadeOut(options.transitionTime);
              $(els[next]).fadeIn(options.transitionTime);
              current = next;
              cue();
            };

            function cue() {
              if ($("> *", obj).length < 2) return false;
              if (timer) clearTimeout(timer);
              if (!options.pauseNavigation) {
                timer = setTimeout(function() { transition((current + 1) % els.length | 0)} , options.pauseTime);
              }
            };
            
            this.showItem = function(item) {
              if (timer) clearTimeout(timer);
              transition(item);
            };

            cue();
          }

          this.showItem = function(item) {
            transitionObject.showItem(item);
          };

          return this.each(function() {
            transitionObject = new Trans(this);
          });
        }

      })(jQuery);
    
      var page = {
        tr: null,
        init: function() {
          page.tr = $(".area").fadeTransition({pauseTime: 5000, transitionTime: 2000, ignore: "#introslide", delayStart: 2000});
          $("div.navigation").each(function() {
            $(this).children().each( function(idx) {
              if ($(this).is("a"))
                $(this).click(function() { page.tr.showItem(idx); return false; })
            });
          });
        },

        show: function(idx) {
          if (page.tr.timer) clearTimeout(page.tr.timer);
          page.tr.showItem(idx);
        }
      };

      $(document).ready(page.init);


if (uruchom_start) {
            $('a[rel=grupa_' + uruchom_start + ']').first().click();
        }
	/* przewijane logosy */

});

function uruchom_gal(id)
{
    $('a[rel=grupa_' + id + ']').first().click();
}

function kontakt_trigger()
{
    var typ = $("#kontakt_form_typ").val();
    if (typ == "hale stalowe") {
        $("#kontakt_hale_stalowe").show();
    } else {
        $("#kontakt_hale_stalowe").hide();
    }
 }
 


  
