var moveRightMv;
var moveLeftMv;
var taa;

function verticalAlign(){
	h1=$(this).attr("height");
	h2=$(this).height();
 	$(this).css("padding-top",(83-h1)/2);
}

function showFloor(){ 
 			$(this).children("img").fadeTo("slow",1);
}

function hideFloor(){
	$(this).children("img").fadeTo("slow",0.1);
}

function show1(){ 
	$(this).children("span").fadeIn("fast");
}

function hide1(){
	if ($(this).attr("class")!="set"){
		$(this).children("span").fadeOut("fast"); 
	}
}

function clickme(){
	if ($(this).attr("class")!="set"){	
	var dp=$(this).attr("rel");
	if (dp){
			$("#scroller > div:visible").fadeOut("fast");
	 		height1=$("#scroller > div#"+dp).height();
			$("#content").animate({height:(height1+20)+"px"},750);
		
			$("#scroller > div#"+dp).fadeIn("slow");
			if (dp=="oferta") {
		  		$("#offerContent > div:visible").fadeOut("fast");
				$("#Wstep").fadeIn("slow");
			}
		}
		var id1=$(this).parent().attr("id");
 		if (id1!="banner"){
			$(this).siblings(":visible").removeClass("set").each(hide1);
			$(this).addClass("set").children("span").fadeIn("fast");
		}
		else{
			if  ($(this).attr("id")!="galeriaLink"){
				$("#linkOferta").siblings(":visible").removeClass("set").each(hide1);
				$("#linkOferta").addClass("set").children("span").fadeIn("fast");
			}
			else{
					$("#topMenu a.set").removeClass("set").each(hide1);
			}
		}
		if (dp=="srealizacje"){
			onReal();
		}
	}	
}

function showZdjecie(){
	var ktojry=$(this).attr("rel").replace("pokazZdjecie","duzeZdjecie");
	if (ktojry!=$("#duzeZdjecia img:visible").attr("rel")){
		
		var lastSmall=$("#duzeZdjecia img:visible").attr("rel").replace("duzeZdjecie","pokazZdjecie");
		$("#widzialneScroll a.imageSet").removeClass("imageSet");

		$(this).addClass("imageSet");
		
		$("#duzeZdjecia img:visible").fadeOut("fast");
		$("#duzeZdjecia img[@rel="+ktojry+"]").fadeIn("slow");
	}
}

function moveLeft(){
	var pos1=$("#widzialneScroll").position().left;
	var widz=4*85;	//szerokosc widocznego elementu
	pos1+=85;
	if (pos1<=0)
		$("#widzialneScroll").animate({left:pos1+"px"},30).animate({opacity: 1.0}, 500);
}
function moveRight(){
  	var width1=$("#widzialneScroll").width();
	var pos1=$("#widzialneScroll").position().left;
	var widz=4*85;	//szerokosc widocznego elementu
	pos1-=85;
	if (pos1>-width1+3*85)
		$("#widzialneScroll").animate({left:pos1+"px"},30).animate({opacity: 1.0}, 500);
}

/* ------------------------ */
/* FUNKCJE NA START			 */
/* ------------------------ */

function body_js(){

	//wizualizacje

	var ileZdjec=$("#widzialneScroll a img").load(verticalAlign).length;
	$("#widzialneScroll").width(ileZdjec*85);
	
	$("#widzialneScroll a").each(function(i){
		if (i==0)
			$(this).addClass("imageSet");
		$(this).attr("rel","pokazZdjecie"+(i+1)).click(showZdjecie);
	});
	$("#duzeZdjecia img").each(function(i){
		$(this).attr("rel","duzeZdjecie"+(i+1));
		if (i>0)
		$(this).fadeOut("fast");
	});

	$("#moveRight").click(moveRight);
	$("#moveLeft").click(moveLeft);
}

