// <![CDATA[

	var picturesfull = new Array();
	var loadedPicture = new Array();
	var pictureId = 0;
	var galleryId = null;
	var currentPicture = 1;
	var lastId;
	var loaderPicture = null;
	var loadDone = false;
	var timeId = null;
	var timeIdAnim = null;
	var f_height = 300;
	var f_width = 300;
	timeId_strzalki = null;
	var loaderPictureAnim = null;
	var loadedPictureAnim = new Array();
	var picturesName = new Array();
	var images_count;
	var images_first;
	var images_last;
	var flaga = false;
function pictures () {
	images_count = picturesName.length;
	for (var i = 0; i < images_count+1; i++) {
		loadImage('/images/right_'+picturesName[i]+'.jpg', i);
	}
	setTimeout("displayPictureAnim(0);",500);
}

function displayPictureAnim(id) {
	if (id > images_count-1) {
		id = 0;
	}
	if (!flaga) {
		document.images.img_right.src = loadedPicture[id].src;
		$("#img_right").fadeIn(3000);
		flaga = true;
	} else {
		document.getElementById('prawy').style.background='url('+loadedPicture[id].src+')';
		$("#img_right").fadeOut(3000);
		flaga = false;
	}
	timeIdAnim = setTimeout("displayPictureAnim("+(id+1)+");",5000);
}

function newImage(source) {
        if (document.images) {
            img = new Image();
        	img.src = source;
        	return img;
        }
	}
	
function loadImage(src, name) {
		if(document.images) {
    		loadedPicture[name] = newImage(src);
            loadDone = true;
        }
	}
	function mailSend(info, type) {
		$("#insideOverdiv").css({margin: 25}).text(info);
		if (type == 1) {
			$("#overDiv").css({position: "absolute", top: (screen.height/2)-125, left: (screen.width/2)-220, width: 440, height: 70, "font-size": 16, background: "#dff3dc", "border": "1px solid #45ab34", "text-align": "center", color: "#105305", "font-weight": "bold"}).show();
		} else {
			$("#overDiv").css({position: "absolute", top: (screen.height/2)-125, left: (screen.width/2)-220, width: 440, height: 70, "font-size": 16, background: "#eacfc7", "border": "1px solid #e12405", "text-align": "center", color: "#e12405", "font-weight": "bold"}).show();
		}
		setTimeout("$('#overDiv').fadeOut();",3000);
	}
	
	function setDivHeight() {
		if ( $("div#content_container").height() < 323) {
			$("div#content_container").height(323);
		}
		$("div#content_container").height()
	}
	
		function loadBuffImage(src) {
		if(document.images) {
    		loadedBuffPicture = newImage(src);
            loadBuffDone = true;
        }
	}
	function loadLoader() {
		if(document.images) {
    		loaderPicture = newImage("/images/loader.gif");
            loaderDone = true;
        }
	}
	
	loadLoader();

	 function displayPicture(func, state) {
	 	
    	if (func == 1 && state != 1) {
    		//loadedPicture["main"] = loadedPicture["buff"];
    		loadImage(picturesfull[galleryId][pictureId],"main");;
    	} 
    	if(document.images && loadedPicture["main"].complete == true && loadDone == true) {
			$("#picture").hide();
			document.images.picture.src = loadedPicture["main"].src;
			$("#picture_canvas").width(loadedPicture["main"].width+20).height(loadedPicture["main"].height+20);
			$("#picture_canvas").css({position: "absolute", left: ((screen.width/2)-(loadedPicture["main"].width/2)-10), top: ((screen.height/2)-(loadedPicture["main"].height/2)-(screen.height/8) + $(document).scrollTop())});
			$("#picture_canvas").show();
			
			//$("#desc").show().width(loadedPicture["main"].width+10).text(desc);
			$("#gallery_menu2").text((pictureId+1)+" z "+lastId);
			$("#picture").css({position: "relative", top: 0, left: 0});
			$("#picture").fadeIn("slow", function() {
				$("#close_obj").slideDown("slow");
				if (timeId_strzalki == null && galleryId == 'mapa'){
					pulsujacaStrzalka(500, true);
				}
				if (pictureId == 1 && galleryId == 'mapa') {
					$("#strzalka").hide().fadeIn(200).css({top: 165, left: 365});
				} else if (pictureId == 0 && galleryId == 'mapa') {
					$("#strzalka").hide().fadeIn(200).css({top: 170, left: 515});
				}
			});
			f_height = $("#picture_canvas").height();
			f_width = $("#picture_canvas").width();
			loadDone = false;
			displayDone = true;
			if (galleryId != null) {
				loadImage(picturesfull[galleryId][pictureId+1],"buff");
			}

		} else { 
		
			if (state != 1) {
				$("#picture").hide();				
				$("#close_obj").hide();
				$("#desc").hide();
				$("#close_obj").slideUp("slow");
				document.images.picture.src = loaderPicture.src;
				//if (document.images && loaderPicture.complete == true) {
					$("#picture_canvas").width(f_width).height(f_height);
					$("#picture_canvas").css({position: "absolute", left: ((screen.width/2)-(f_width/2)), top: ((screen.height/2)-(f_height/2)-(screen.height/8)+10 + $(document).scrollTop())}).show();
			
					$("#picture").css({position: "relative", top: f_height/2-30, left: f_width/2-30});
					$("#picture").show();
					
				//}
				
			}
			
			setTimeout("displayPicture("+func+", 1);",500);
		}
    }

	function galleryInit(gall_id, last_id, state, pic_id) {
		pictureId = pic_id - 1;
		galleryId = gall_id;
		if (typeof document.height != "undefined") {
			docHeight = document.height;
		} else if (document.body && typeof document.body.scrollHeight != "undefined") {
			docHeight = document.body.scrollHeight;
			
		}

		if (docHeight < document.documentElement.clientHeight) {
			docHeight = document.documentElement.clientHeight;
		}
		docHeight += 89;
		document.images.button_play.src = '/images/iconPlayerPlay_20x20.gif';
		document.images.button_stop.src = '/images/iconPlayerStopG_20x20.gif';
		$(".selectField").hide();
		$("#overDiv1").css({display: "block", height: docHeight, background: "color: black"}).show();
		$("#gallery_menu").css({top: $(document).scrollTop()}).slideDown();;	
		loadImage(picturesfull[galleryId][pictureId], "main");
			
		lastId = last_id;
		
		displayPicture(0, 0);
	}
	
	function mapInit(gall_id, last_id, state, pic_id) {
		pictureId = pic_id - 1;
		galleryId = gall_id;
		if (typeof document.height != "undefined") {
			docHeight = document.height;
		} else if (document.body && typeof document.body.scrollHeight != "undefined") {
			docHeight = document.body.scrollHeight;
		}
		if (docHeight < document.documentElement.clientHeight) {
			docHeight = document.documentElement.clientHeight;
		}
		
		$("#overDiv1").css({display: "block", height: docHeight, background: "color: black"}).show();
		$("#gallery_menu").css({top: $(document).scrollTop()}).slideDown();	
		loadImage(picturesfull[galleryId][pictureId], "main");
		lastId = last_id;
			
		displayPicture(0, 0);
	}

	function pictureAction(action, state) {
		
		if (action == "next" && pictureId < lastId-1) {
			pictureId++;
		} else if(action == "prev" && pictureId > 0) {
			pictureId--;
		} else if (action == "play" && pictureId < lastId-1) {
			document.images.button_stop.src = '/images/iconPlayerStop_20x20.gif';
			document.images.button_play.src = '/images/iconPlayerPlayG_20x20.gif';
						
			if (loadedPicture["main"].complete == true) {
				pictureId++;
				action = 'play';
				timeId = setTimeout("pictureAction(\""+action+"\",\""+state+"\");",4000);
			} else {
				action = 'play';
				timeId = setTimeout("pictureAction(\""+action+"\",\""+state+"\");",4000);
				action = 'stop';
			}
		} else if (action == "stop") {
			clearTimeout(timeId);
			document.images.button_play.src = '/images/iconPlayerPlay_20x20.gif';
			document.images.button_stop.src = '/images/iconPlayerStopG_20x20.gif';
		} else {
			closeGallery();		
			pictureId = 0;
			return true;
		}
		
		if (action != 'stop') {
			$("#close_obj").slideUp("fast", function() {
				$("#picture").fadeOut("slow", function(){
					displayPicture(1, 0);
				});
			});
		}
	}
	
	function closeGallery() {
		if(timeId != null) {
			clearTimeout(timeId);
		}
		$(".selectField").show();
		$("#overDiv1").hide();
		$("#picture_canvas").fadeOut();
		$("#close_obj").hide();
		$("#desc").hide();
		$("#gallery_menu").slideUp();
	}
	
	var tab_name = new Array(); 
	var tab_price = new Array(); 
	var tab_desc = new Array();


	function showMiddle(midSrc, id, imgNr) {
		currentPicture = imgNr+1;
		$("#midPic_"+id).fadeOut("fast", function() {
		document.images["midPic_"+id].src = midSrc;
		$("#midPic_"+id).fadeIn("slow");
		});
	}
	
	function infoShow(info, type) {
		$("#insideOverdiv").css({margin: 25}).text(info);
		if (type == 1) {
			$("#overDiv").css({position: "absolute", top: (screen.height/2)-125, left: (screen.width/2)-220, width: 440, height: 70, "font-size": 16, background: "#dff3dc", "border": "1px solid #45ab34", "text-align": "center", color: "#105305", "font-weight": "bold", "z-index": 20}).show();
		} else {
			$("#overDiv").css({position: "absolute", top: (screen.height/2)-125, left: (screen.width/2)-220, width: 440, height: 70, "font-size": 16, background: "#eacfc7", "border": "1px solid #e12405", "text-align": "center", color: "#e12405", "font-weight": "bold", "z-index": 20}).show();
		}
		setTimeout("$('#overDiv').fadeOut();",3000);
		
	}
	
	
	
	function startAnim() {
	
	//	$("#part_33").fadeIn(1000, function(){
			$("#part_11").fadeIn(1200, function(){
				$("#part_13").fadeIn(1200, function(){
					//$("#part_33").fadeIn(1000, function(){
						$("#part_23").fadeIn(1200, function(){
							$("#part_22").fadeIn(1200, function(){
								//$("#part_31").fadeIn(1000, function(){
									$("#part_21").fadeIn(1200, function(){
										$("#part_12").fadeIn(1200, function(){
										//	$("#part_32").fadeIn(1000, function(){
												$("#animBanner").css({"border-bottom": "2px solid white"}).slideUp(2000, function(){
													$("#slogan_top").hide().css({color: "white"}).fadeIn();
												});
											});
										});
					//				});
					//			});
					//		});
					//	});
					});
				});
			});
		})
	}
// ]]>
