/**
 * @author ZuLuS
 */
var searchText = "wpisz wyszukiwaną frazę";

function start() {
	$("#top form .text").attr("value", searchText).css("font-style", "italic");
	$("#top form .text").focus(function() {
		if($(this).attr("value") == searchText)
			$(this).attr("value", "").css("font-style", "normal");
	});
	$("#top form .text").blur(function() {
		if($(this).attr("value") == "")
			$(this).css("font-style", "italic").attr("value", searchText);
	});
	$("#content .news .roll").toggle(function() {
		$("#news").slideUp(700);
		$(this).css("background-position", "0px -34px");
		return false;
	}, function() {
		$("#news").slideDown(700);
		$(this).css("background-position", "0px 0px");
		return false;
	});
	
	$("#content .lastActions .roll").toggle(function() {
		$("#lastActions").slideUp(700);
		$(this).css("background-position", "0px -34px");
		return false;
	}, function() {
		$("#lastActions").slideDown(700);
		$(this).css("background-position", "0px 0px");
		return false;
	});
	
	$("#content .partners .roll").toggle(function() {
		$("#partners").slideUp(700);
		$(this).css("background-position", "0px -34px");
		return false;
	}, function() {
		$("#partners").slideDown(700);
		$(this).css("background-position", "0px 0px");
		return false;
	});
	
	$("#content .art .roll").toggle(function() {
		$("#art").slideUp("normal");
		$(this).css("background-position", "0px -34px");
		return false;
	}, function() {
		$("#art").slideDown("normal");
		$(this).css("background-position", "0px 0px");
		return false;
	});
	$("#content .search .roll").toggle(function() {
		$("#search").slideUp("normal");
		$(this).css("background-position", "0px -34px");
		return false;
	}, function() {
		$("#search").slideDown("normal");
		$(this).css("background-position", "0px 0px");
		return false;
	});
	$("#content .clickRoll .roll").toggle(function() {
		$(".toRoll").slideUp("normal");
		$(this).css("background-position", "0px -34px");
		return false;
	}, function() {
		$(".toRoll").slideDown("normal");
		$(this).css("background-position", "0px 0px");
		return false;
	});
	$("#lastActions .box .img").lightBox();
	$("#lastActions .box img").hover(borderOut, borderIn);
}
$(start);
var pages;
var actualPage = 1;
function startGalSmall() {
	pages = $("#galSmall .img").get().length;
	$("#galSmall .images").html("<div class=\"anim\" style=\"position:relative\">"+$("#galSmall .images").html()+"</div>");
	$("#galSmall .anim").width(pages*180);
	$("#galSmall .images .img a").lightBox({fixedNavigation:true}).hover(borderOut, borderIn);
	pages-=3;
	if(pages>0) {
		$("#galSmall .next").show();
	}
	actualPage=0;
	$("#galSmall .next").click(nextSmallPage);
	$("#galSmall .prev").click(prevSmallPage);
}
function borderIn() {
	$(this).animate({borderLeftColor:"#e1e3e3",
					 borderTopColor:"#e1e3e3",
					 borderBottomColor:"#e1e3e3",
					 borderRightColor:"#e1e3e3"}, 500);
}
function borderOut() {
	$(this).animate({borderLeftColor:"#f8ca14",
					 borderTopColor:"#f8ca14",
					 borderRightColor:"#f8ca14",
					 borderBottomColor:"#f8ca14"}, 500);
}
function nextSmallPage() {
	if(actualPage < pages) {
		actualPage++;
		$("#galSmall .anim").animate({left : "-"+(actualPage*150)+"px"}, 600);

		if(actualPage >= pages) {
			$("#galSmall .next").fadeOut();
		}
		$("#galSmall .prev").fadeIn();
	}
	return false;
}
function prevSmallPage() {
	if(actualPage > 0) {
		actualPage--;
		$("#galSmall .anim").animate({left : (actualPage > 0 ? "-" : '')+(actualPage*150)+"px"}, 600);
		if(actualPage == 0) {
			$("#galSmall .prev").fadeOut();
		}
		$("#galSmall .next").fadeIn();
	}
	return false;
}
$(startGalSmall);
function startGal() {
	$("#galery .images .img a").lightBox({fixedNavigation:true}).hover(borderOut, borderIn);
	if($("#galery .noJS").get().length == 0 && $("#galery").get().length==1) {
		pages = $("#galery .images .page").get().length;

		$("#galery .pages").width(pages*710);
		if(pages>1) {
			$("#galery .next").show();
		}
		$("#galery .next").click(nextGalPage);
		$("#galery .prev").click(prevGalPage);
	}
}
function nextGalPage() {
	if(actualPage < pages) {
		actualPage++;
		$("#galery .pages").animate({left : "-"+(actualPage*708)+"px"}, 600);
		if(actualPage >= pages-1) {
			$("#galery .next").fadeOut();
		}
		$("#galery .prev").fadeIn();
	}
	return false;
}
function prevGalPage() {
	if(actualPage > 0) {
		actualPage--;
		//alert(actualPage*708);
		$("#galery .pages").animate({left : (actualPage > 0 ? "-" : '')+(actualPage*708)+"px"}, 600);
		if(actualPage == 0) {
			$("#galery .prev").fadeOut();
		}
		$("#galery .next").fadeIn();
	}
	return false;
}
$(startGal);

