/* FUNKCJE ZWIĄZAENE Z WYŚWIETLANIEM OBRAZKÓW W OFERTACH */


/* Preloading zdjęć profilu */

function pushPic(strURL, title, maxPic){
	img = new Image();
	img.src = strURL;
	picArray.push(img);
	titleArray.push(title);
	maxPicArray.push(maxPic);
	maxIndex += 1;
}

/* opis animacji przejścia zdjęcia w zdjęcie */

function StartAnimation(div) {
    var group = mint.fx.Group(null, 40, 1000, null, null);
    group.Add("profilPhoto_"+div, "opacity", 0, 100);
    group.Run();
}

/* Funkcja zapewnia wczytanie po kliknięciu "w prawo" kolejnego zdjęcia w profilu */

function clickLeft(div) {

	currIndex = currIndex - 1;
	if (currIndex == -1){
		currIndex = maxIndex - 1;
	}	
	
	strPicText = "zdjęcie " + (currIndex + 1) + " / " + maxIndex;
	document.getElementById('picText_'+div).innerHTML = strPicText;
	
	document.getElementById('photoTitleKontener_'+div).style.display=(titleArray[currIndex]=="")?'none':'block';
	document.getElementById('photoTitle_'+div).innerHTML = titleArray[currIndex];

	setTimeout(
		function () {
			//$('profilPhoto').src = picArray[currIndex].src;
			document.getElementById('profilPhotoHref_'+div).href = maxPicArray[currIndex];
			document.getElementById('profilPhotoHref_'+div).title = titleArray[currIndex];
			document.getElementById('profilPhoto_'+div).src = picArray[currIndex].src;
			StartAnimation(div);
		},1);
}

/* Funkcja zapewnia wczytanie po kliknięciu "w lewo" kolejnego zdjęcia w profilu */

function clickRight(div) {

	currIndex = Math.abs(((currIndex + 1) % maxIndex));

	strPicText = "zdjęcie " + (currIndex + 1) + " / " + maxIndex;
	document.getElementById('picText_'+div).innerHTML = strPicText;
	document.getElementById('photoTitleKontener_'+div).style.display=(titleArray[currIndex]=="")?'none':'block';
	document.getElementById('photoTitle_'+div).innerHTML = titleArray[currIndex];

	
	setTimeout(
		function () {
			//$('profilPhoto').src = picArray[currIndex].src;
			document.getElementById('profilPhotoHref_'+div).href = maxPicArray[currIndex];
			document.getElementById('profilPhotoHref_'+div).title = titleArray[currIndex];
			document.getElementById('profilPhoto_'+div).src = picArray[currIndex].src;
			StartAnimation(div);
		},1);
}

/* Funkcja centruje zdjęcie osoby w profilu */

function centerProfilPhoto(div){
	picFrame = document.getElementById('profilePhotoShadow_'+div);
	pic = document.getElementById('profilPhoto_'+div);
	
	picFrame.style.left = "0px";

	if (pic.width < 253){
		offsetX = (290 - pic.width) / 2;
		picFrame.style.left = offsetX + "px";
	}
}