var $jQ = jQuery.noConflict();
/*do bg*/
	$jQ(document).ready(function() {
   function sprawdzRozmiarOkna() {
	if ( $jQ(window).width() > 1000 ) {
		//alert($jQ(window).width());
		var poz,zm;
		poz=$jQ(window).width() - 1264  ;
		poz=poz/2;
		poz-=210;
		poz+='';
		poz+='px 0px';
		
		//alert(poz);
		
		document.getElementById('bodys').style.backgroundPosition =poz;
	}
	else {
		$jQ('body').removeClass('duzy');
	}
   }
	$jQ(window).resize(sprawdzRozmiarOkna);
	});
	function onloadbody(){
		var poz,zm;
		poz=screen.width - 1264  ;
		poz=poz/2;
		poz-=210;
		poz+='';
		poz+='px 0px';
		
		//alert(poz);
		
		document.getElementById('bodys').style.backgroundPosition =poz;		
	}
	;
/*do menu gornego*/
	
	$jQ(document).ready(function () {

		//transitions
		//for more transition, goto http://gsgd.co.uk/sandbox/jquery/easing/
		var style = 'easeOutElastic';

		//Retrieve the selected item position and width
		var default_left = Math.round($jQ('#lava li.selected').offset().left - $jQ('#lava').offset().left);
		var default_width = $jQ('#lava li.selected').width();
		//Set the floating bar position and width
		$jQ('#box').css({left: default_left});
		$jQ('#box .head').css({width: default_width});

		//if mouseover the menu item
		$jQ('#lava li').hover(function () {
			
			//Get the position and width of the menu item
			left = Math.round($jQ(this).offset().left - $jQ('#lava').offset().left);
			width = $jQ(this).width();
			
		$jQ('#debug').html(left);
			//Set the floating bar position, width and transition
			$jQ('#box').stop(false, true).animate({left: left},{duration:1000, easing: style});	
			$jQ('#box .head').stop(false, true).animate({width:width},{duration:1000, easing: style});	
		
		//if user click on the menu
		}).click(function () {
			
			//reset the selected item
			$jQ('#lava li').removeClass('selected');	
			
			//select the current item
			$jQ(this).addClass('selected');
	
		});
		
		//If the mouse leave the menu, reset the floating bar to the selected item
		$jQ('#lava').mouseleave(function () {

			//Retrieve the selected item position and width
			default_left = Math.round($jQ('#lava li.selected').offset().left - $jQ('#lava').offset().left);
			default_width = $jQ('#lava li.selected').width();
			//Set the floating bar position, width and transition
			$jQ('#box').stop(false, true).animate({left: default_left},{duration:1000, easing: style});	
			$jQ('#box .head').stop(false, true).animate({width:default_width},{duration:1000, easing: style});		
			
		});
		
	});
/*menu*/
	var menu_s=0;
	var pomo_czas=1;
	var pomo_2=0;
	function show_menu(){
		if(!menu_s){
			$jQ("#submenu").toggle("slow");
			menu_s=1;
		}
		pomo_czas=1;
		pomo_2=1;
		
	}
	function hidden_menu(){
		pomo_czas=0;
		setTimeout(
				function(){
					if(!pomo_czas && menu_s){
						$jQ("#submenu").toggle("slow");
						menu_s=0;
					}
				},2000
			);

	}
	function nowe_show(){
		pomo_czas=1;
		pomo_2=1;
	}
	function nowe_hidden(){
		pomo_czas=0;
	}
		
		


/*slider*/
$jQ(document).ready(function(){
  var currentPosition = 0;
  var slideWidth = 900;
  var slides = $jQ('.slide');
  var numberOfSlides = slides.length;

  // Remove scrollbar in JS
  $jQ('#slidesContainer').css('overflow', 'hidden');

  // Wrap all .slides with #slideInner div
  slides
    .wrapAll('<div id="slideInner"></div>')
    // Float left to display horizontally, readjust .slides width
	.css({
      'float' : 'left',
      'width' : slideWidth
    });

  // Set #slideInner width equal to total width of all slides
  $jQ('#slideInner').css('width', slideWidth * numberOfSlides);

  // Insert controls in the DOM
  $jQ('#slideshow')
    .prepend('<span class="control" id="leftControl">Clicking moves left</span>')
    .append('<span class="control" id="rightControl">Clicking moves right</span>');

  // Hide left arrow control on first load
  manageControls(currentPosition);

  // Create event listeners for .controls clicks
  $jQ('.control')
    .bind('click', function(){
    // Determine new position
	currentPosition = ($jQ(this).attr('id')=='rightControl') ? currentPosition+1 : currentPosition-1;
    
	// Hide / show controls
    manageControls(currentPosition);
    // Move slideInner using margin-left
    $jQ('#slideInner').animate({
      'marginLeft' : slideWidth*(-currentPosition)
    });
  });

  // manageControls: Hides and Shows controls depending on currentPosition
  function manageControls(position){
    // Hide left arrow if position is first slide
	if(position==0){ $jQ('#leftControl').hide() } else{ $jQ('#leftControl').show() }
	// Hide right arrow if position is last slide
    if(position==numberOfSlides-1){ $jQ('#rightControl').hide() } else{ $jQ('#rightControl').show() }
  }	
});
