var $j = jQuery.noConflict();

var iterator=0;


function myf() {
 var space      = $j('body').width()-1000;
 var layerWidth = 0;
 if(space>0) {
	 layerWidth = (space/2)+220;
 }else {
     layerWidth = 220;
 } 
 $j("#car").animate({ 'left': '-585px'},4000);
 $j("#car").fadeIn(1000);
 $j("#car").animate({ 'left': layerWidth},1500);
 
 $j("#onas").animate({ 'opacity':1 },4000);
 $j("#onas").fadeIn(1300);
 $j("#onas").animate({ 'left': layerWidth-200},1000);
 
 $j("#oferta").animate({ 'opacity':1 },4000);
 $j("#oferta").fadeIn(600);
 $j("#oferta").animate({ 'left': layerWidth+50},800);

 $j("#galeria").animate({ 'opacity':1 },4000); 
 $j("#galeria").fadeIn(600);
 $j("#galeria").animate({ 'right': layerWidth+50},800);

 $j("#kontakt").animate({ 'opacity':1 },4000);
 $j("#kontakt").fadeIn(1300);
 $j("#kontakt").animate({ 'right': layerWidth-200},1000);
 
 $j(".f1").fadeIn(1300);
 $j(".f1").animate({ 'right':layerWidth+290 },5000);

 $j(".f2").fadeIn(1900);
 $j(".f2").animate({ 'right':layerWidth-200 },5000);
 
 $j(".f3").fadeIn(2300);
 $j(".f3").animate({ 'right':layerWidth-100 },5000); 

 $j(".f4").fadeIn(2800);
 $j(".f4").animate({ 'right':layerWidth-260 },5000); 

 $j("#mark").animate({ 'opacity':1 },3500);
 $j("#mark").fadeOut(500);
 
 $j("#automat").fadeIn(6000);
 iterator++;
 if(iterator>0){ clearInterval(interval1);}
				//alert(iterator);											  
 }


$j(document).ready(function() {
 var hei = 	$j('body').height();					
 $j("#mark").css({ 'height': hei });
 
 interval1 = setInterval("myf()",500);
 
$j(".bt img").hoverIntent(function() {
  var p = $j(this); //alert("przed"+$j(this).attr('id'));
  $j(".bt img").each( function() {
	if(p.attr('id')!=$j(this).attr('id')) {
		 $j(this).animate({      
           	 'opacity':0.5   
         },300);
	}
  });
  } ,
 function() {
  $j(".bt img").animate({       
	 'opacity':1
	}, 200);  
   }
);

$j("#onas").click( function() {
  $j(".ct").fadeOut(200);	
  $j("#content1").animate({ padding:0 },200);
  $j("#content1").fadeIn(500);
  return false;
});
$j("#oferta").click( function() {
  $j(".ct").fadeOut(200);			
  $j("#content2").animate({ padding:0 },200);
  $j("#content2").fadeIn(500);
  return false;
});
$j("#galeria").click( function() {
  $j(".ct").fadeOut(200);					
  $j("#content3").animate({ padding:0 },200);
  $j("#content3").fadeIn(500);
  return false;
});
$j("#kontakt").click( function() {
  $j(".ct").fadeOut(200);					
  $j("#content4").animate({ padding:0 },200);
  $j("#content4").fadeIn(500);
  return false;
});
$j("#automat").click( function() {
  $j(".ct").fadeOut(200);					
  $j("#content5").animate({ padding:0 },200);
  $j("#content5").fadeIn(500);
  return false;
});
$j(".zamknij").click( function() {
  $j(".ct").fadeOut(400);					
  return false;
});


$j(".scrollUp").hover( 
  function() {
	$j(this).parent().parent().children('.txt').scrollTo(0,800);							
  },
  function() {
							
  }
);
$j(".scrollDown").hover( 
  function() {
	$j(this).parent().parent().children('.txt').scrollTo(300,800);							
  },
  function() {
							
  }
);
$j('a.gal').lightBox();
$j("a.gal").hover( 
  function() {
	$j(this).animate({ opacity: 0.8 }, 300);							
  },
  function() {
	$j(this).animate({ opacity: 1 }, 200);						
  }
);
}); 