
var maxIndex = 0;
var currIndex = 0;
var picArray = new Array();
var titleArray = new Array();
var maxPicArray = new Array();
var picTypeArray = new Array();
var picIDArray = new Array();

/* 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() {
    var group = mint.fx.Group(null, 40, 1000, null, null);
    group.Add("profilPhoto", "opacity", 0, 100);
    group.Run();
}

/* Funkcja zapewnia wczytanie po kliknięciu "w prawo" kolejnego zdjęcia w profilu */

function clickLeft() {
	
	currIndex = currIndex - 1;
	if (currIndex == -1){
		currIndex = maxIndex - 1;
	}	
	
	strPicText = "zdjęcie " + (currIndex + 1) + " / " + maxIndex;
	document.getElementById('picText').innerHTML = strPicText;
	
	document.getElementById('photoTitleKontener').style.display=(titleArray[currIndex]=="")?'none':'block';
	document.getElementById('photoTitle').innerHTML = titleArray[currIndex];

	setTimeout(
		function () {
			//$('profilPhoto').src = picArray[currIndex].src;
			document.getElementById('profilPhotoHref').href = maxPicArray[currIndex];
			document.getElementById('profilPhotoHref').title = titleArray[currIndex];
			document.getElementById('profilPhoto').src = picArray[currIndex].src;
			StartAnimation();
		},1);
}

/* Funkcja zapewnia wczytanie po kliknięciu "w lewo" kolejnego zdjęcia w profilu */

function clickRight(place, id) {

	currIndex = Math.abs(((currIndex + 1) % maxIndex));

	strPicText = "zdjęcie " + (currIndex + 1) + " / " + maxIndex;
	document.getElementById('picText').innerHTML = strPicText;
	document.getElementById('photoTitleKontener').style.display=(titleArray[currIndex]=="")?'none':'block';
	document.getElementById('photoTitle').innerHTML = titleArray[currIndex];

	
	setTimeout(
		function () {
			//$('profilPhoto').src = picArray[currIndex].src;
			document.getElementById('profilPhotoHref').href = maxPicArray[currIndex];
			document.getElementById('profilPhotoHref').title = titleArray[currIndex];
			document.getElementById('profilPhoto').src = picArray[currIndex].src;
			StartAnimation();
		},1);
}

/* Funkcja centruje zdjęcie osoby w profilu */

function centerProfilPhoto(){
	picFrame = document.getElementById('profilePhotoShadow');
	pic = document.getElementById('profilPhoto');
	
	picFrame.style.left = "0px";

	if (pic.width < 253){
		offsetX = (241 - pic.width) / 2;
		picFrame.style.left = offsetX + "px";
	}
}

/* 
Funkacja obsługuje Podręczne menu nawigacyjne
onmouseover następuje zmiana widoczności kolejnego DIV oraz 
nadanie elementowi głownego menu atrybutu CLASS
*/

function subNavMenu(id) {
	for (var o = 0; o<6; o++) {
		if (document.getElementById('subNav_'+o)) {
			document.getElementById('subNav_'+o).style.display='none';
		}
	}
	
	document.getElementById('nav'+id).blur();
	changeOpac(0, 'subNav_'+id);
	Fade('subNav_'+id, 100, 20, 800);
	document.getElementById('subNav_'+id).style.display='block';
	
}

/* Funkcja wyzwala powtórne wysłanie emiala potwierdzającego rejestrację */

function sendConfirmationEmail(userID, div){
	if( confirm('Czy na pewno chcesz wygenerować powtórny e-mail potwierdzaj±cy rejestrację?') ){
		loading(div);	
		var req = mint.Request();
		req.retryNum = 0;
    	req.AddParam("userID", userID);
	    req.Send("includes/lib/social/ajax/email_resend.php", div);
	}
}

/* Funkcja wyzwala powtórne wysłanie emiala potwierdzającego zgłoszenie na newsletter */

function sendNewsletterConfirmationEmail(userID, div){
	if( confirm('Czy na pewno chcesz wygenerować powtórny e-mail potwierdzaj±cy zgłoszenie do newslettera?') ){
		loading(div);	
		var req = mint.Request();
		req.retryNum = 0;
    	req.AddParam("userID", userID);
	    req.Send("includes/lib/social/ajax/newsletter_email_resend.php", div);
	}
}

/* Funkcja ostrzega przy przenoszeniu wiadomości do kosza */

function moveToTrash(f){
	var status = false;
	
	with (document.forms[f]) {
		elements[0].value++
		var L = elements.length
		while (L--){
			if(elements[L].checked == true){
				status = true;
				break;
			}
		} 
	}	
	
	if(status == true){
		if (confirm('czy na pewno chcesz przesun±ć zaznaczone wiadomo¶ci do kosza?')){
			//document.forms[f].submit();
			return true;
		}
	}
	else{
		alert('należy najpierw zaznaczyć wiadomo¶ci które maj± zostać przeniesione do kosza');
		return false;
	}
	
	return false;
	
}

/* Funkcja ostrzega przy kasowaniu wiadomości z kosza */

function DeleteFromTrash(f){
	var status = false;
	
	with (document.forms[f]) {
		elements[0].value++
		var L = elements.length
		while (L--){
			if(elements[L].checked == true){
				status = true;
				break;
			}
		} 
	}	
	
	if(status == true){
		if (confirm('czy na pewno chcesz definitywnie usun±ć zaznaczone wiadomo¶ci?')){
			document.forms[f].del.value = 1;
			return true;
		}
	}
	else{
		alert('należy najpierw zaznaczyć wiadomo¶ci które maj± zostać usunięte');
		return false;
	}

	return false;
	
}


/* Funkcja wyzwala prosces kasowania z listy znajomych */

function confirmDelFromFriendList(div, id){
	
	if( confirm('czy na pewno chcesz wykonać tę czynno¶ć?') ){
		if( confirm('czy wysłać powiadomienie o tym fakcie do odł±czanego znajomego?') ){
			document.getElementById(div).href = 'odlacz_znajomego/'+id+'/powiadom/';
		}
		else{
			document.getElementById(div).href = 'odlacz_znajomego/'+id;
		}
		return true;
		
	}
	
	return false
} 