/***************************************************************************
*
* IMPORTANT: This is a commercial product made by AntonLV and cannot be modified for other than personal usage. 
* This product cannot be redistributed for free or a fee without written permission from AntonLV. 
* This notice may not be removed from the source code.
*
***************************************************************************/

function alv_adv_displayProfile(iIndex) {			
	var oThumbnail = document.getElementById('alvAdvThumbnail');
	var oDescription = document.getElementById('alvAdvDescription');

	if(alv_adv_isArray(aAdvSysProfiles[iIndex])) {
		var oProfile1 = document.getElementById('alvAdvProfile1');
		var oProfile2 = document.getElementById('alvAdvProfile2');
		var oMainInfo = document.getElementById('alvAdvMainInfo');
		var oViewsCount = document.getElementById('alvAdvViewsCount');

		//--- Display Values ---//
		var aProfileInfo = aAdvSysProfiles[iIndex];
		oProfile1.href = aProfileInfo['page'];
		oProfile1.innerHTML = aProfileInfo['nick'];
		oProfile2.href = aProfileInfo['page'];
		oThumbnail.src = aProfileInfo['thumbnail'];
		var sMainInfo = sAlvAdvInfoTmpl;
		for(sVariable in aProfileInfo)
			sMainInfo = sMainInfo.replace('#' + sVariable + '#', aProfileInfo[sVariable]);
		oMainInfo.innerHTML = sMainInfo;	
		oDescription.innerHTML = "<textarea class=\"sDescription\" readonly>" + aProfileInfo['description'] + "</textarea>";
		oViewsCount.innerHTML = sAlvAdvViewsTmpl.replace('#views#', aProfileInfo['views']);

		//--- Update system pointer ---//
		iIndex = ++iIndex >= aAdvSysProfiles.length ? 0 : iIndex;		
		alv_adv_displayInterval();
	}
	else {
		oThumbnail.src = sAdvEmptyImgUrl;
		oDescription.innerHTML = "<div class='sEmpty'>" + sAdvEmptyDescription + "</div>";
		if(bAdvBuy) 
			oDescription.innerHTML += "<div class='sEmpty' style='font-size: 16px;'><a href='membership.php'>" + sAdvBuy + "</a></div>";

		alv_adv_displaySleep();
	}

	return iIndex;
}
function alv_adv_displaySleep() {
	window.setTimeout('iAdvSysIndex = alv_adv_displayProfile(iAdvSysIndex);', 1000 * iAdvDisplaySleep);
}
function alv_adv_displayInterval() {
	window.setTimeout('iAdvSysIndex = alv_adv_displayProfile(iAdvSysIndex);', 1000 * iAdvDisplayInterval);
}

alv_adv_executeRequest('profiles', '', alv_adv_onProfiles);