var USER_HINTS_ITEMS;
var GEO_HINTS_ITEMS;
var userHints;
var geoHints;

function getUserHint(login, userImg, name, articlesCount, photoCount, videoCount, contextPath) {
	var profileUrl = contextPath + 'profile/' + login;
	var blogUrl = contextPath + 'blogs/' + login;
	var photoUrl = contextPath + 'gallery/' + login;
	var videoUrl = contextPath + 'video/' + login;
	var avatarUrl = contextPath + userImg;
	var addMsgUrl = contextPath + 'my/messages/' + login;
	var addMsgIco = contextPath + 'img/ico_email.gif';
	return '<div class="picArea"><a href="' + profileUrl + '" class="titleLink"><img src="' + avatarUrl + '" class="bordered" alt="" /></a></div>'
		+ '<div class="dataArea"><a href="' + profileUrl + '" class="titleLink">' + name + '</a><br />'
		+ '  <a href="' + blogUrl + '" class="dataLink">Статей: ' + articlesCount + '</a><br />'
		+ '  <a href="' + photoUrl + '" class="dataLink">Фото: ' + photoCount + '</a><br />'
		+ '  <a href="' + videoUrl + '" class="dataLink">Видео: ' + videoCount + '</a><br />'
		+ '  <a href="' + addMsgUrl + '" class="dataLink">Написать:&nbsp;<img src="' + addMsgIco + '" alt="сообщение" /></a>'
		+ '</div>'
}

function getLocationHint(level, placeId, caption, usersCount, photoCount, videoCount, articlesCount, canAdd, canEdit, contextPath) {
	var placeUrl = contextPath + 'place/'+level+'/' + placeId;
	var inhibitantsUrl = contextPath + 'inhibitants/'+level+'/' + placeId;
	var blogUrl = contextPath + 'articles/'+level+'/' + placeId;
	var photoUrl = contextPath + 'photos/'+level+'/' + placeId;
	var videoUrl = contextPath + 'videos/'+level+'/' + placeId;

	var shortContextPath;
	var index = contextPath.indexOf('/c/');
	if (index != -1) {
		shortContextPath = contextPath.substring(0, index + 1);
	} else {
		shortContextPath = contextPath;	
	}	
	var addArticleLink = '';
	var addPhotoLink = '';
	var addVideoLink = '';
	if (canAdd) {
		var plusImgUrl = shortContextPath + 'img/ico_add.gif';
		var baseJsStart = "showAddToLocationForm('my/ajax/showupload?placeId=" + placeId + "&levelId=" + level;
		var baseJsEnd = "', '" + contextPath + "');";	
		var addArticleJs = baseJsStart + "&formType=article" + baseJsEnd;
		var addPhotoJs = baseJsStart + "&formType=photo" + baseJsEnd;
		var addVideoJs = baseJsStart + "&formType=video" + baseJsEnd;		
		addArticleLink = '  <td><a href="#addResourceForm" onclick="' + addArticleJs + '" title="Добавить статью"><img src="' + plusImgUrl + '" class="icon" alt="Добавить статью" /></a></td>';
		addPhotoLink = '  <td><a href="#addResourceForm" onclick="' + addPhotoJs + '" title="Добавить фото"><img src="' + plusImgUrl + '" class="icon" alt="Добавить фото" /></a></td>';
		addVideoLink = '  <td><a href="#addResourceForm" onclick="' + addVideoJs + '" title="Добавить видео"><img src="' + plusImgUrl + '" class="icon" alt="Добавить видео" /></td>';
	}	
	var html = '';
	var editLink = '';
	var delLink = '';
	if (level==1) {
		html = html + '<div class="picArea"><img src="' + shortContextPath +'img/country/'+placeId+'.gif" border="1" alt="" /></div>';
	}
	if (canEdit) {
		var editLocJs = baseJsStart + "&formType=place&mode=edit" + baseJsEnd;
		var editImgUrl = shortContextPath + 'img/ico_edit.gif';	
		editLink = '  <a href="javascript:void(0)" onclick="' + editLocJs + '" title="Редактировать"><img src="' + editImgUrl + '" class="icon" alt="Редактировать место" /></a>';
		var delLocJs = "return Gallery.performAction('delete', 'location', 'my/ajax/dellocation?placeId=" + placeId + "&levelId=" + level + "', '" + contextPath + "', 'Вы уверены, что хотите удалить это место? Все связаные ресурcы будут удалены!');";
		var delImgUrl = shortContextPath + 'img/ico_remove.gif';			
		delLink = '  <a href="javascript:void(0)" onclick="' + delLocJs + '" title="Удалить"><img src="' + delImgUrl + '" class="icon" alt="Удалить место" /></a>';
	}
	return html 	
		+ '<div class="dataArea"><a href="' + placeUrl + '" class="titleLink">' + caption + '</a>' 
		+ editLink
		+ delLink
		+ '<br />'
		+ '  <a href="' + inhibitantsUrl + '" class="dataLink">Жителей: ' + usersCount + '</a><br />'
		+ '  <table><tr>'
		+ '  <td><a href="' + blogUrl + '" class="dataLink">Статей: ' + articlesCount + ' </a></td>'
		+ addArticleLink
		+ '  </tr><tr>'
		+ '  <td><a href="' + photoUrl + '" class="dataLink">Фото: ' + photoCount + '</a></td>'
		+ addPhotoLink
		+ '  </tr><tr>'
		+ '  <td><a href="' + videoUrl + '" class="dataLink">Видео: ' + videoCount + '</a></td>'
		+ addVideoLink
		+ '  </tr></table>'
		+ '</div>';
}

function getGeoHint(currentLevel, countryId, countryName, usersCount, articlesCount, photoCount, videoCount, contextPath, cityId, cityName) {
	var countryUrl = contextPath + 'place/1/' + countryId;	
	var cityStr = '';
	var level = 1;
	var id = countryId;
	if (cityId != null) {
		var cityUrl = contextPath + 'place/' + currentLevel + '/' + cityId;
		cityStr = '<a href="' + cityUrl + '" class="titleLink">' + cityName + '</a><br />';
		level = currentLevel;
		id = cityId;
	}
	var inhibitantsUrl = contextPath + 'inhibitants/' + level + '/' + id;
	var blogUrl = contextPath + 'articles/' + level + '/' + id;
	var photoUrl = contextPath + 'photos/' + level + '/' + id;
	var videoUrl = contextPath + 'videos/' + level + '/' + id;
	
	var shortContextPath;
	var index = contextPath.indexOf('/c/');
	if (index != -1) {
		shortContextPath = contextPath.substring(0, index + 1);
	} else {
		shortContextPath = contextPath;	
	}	
	var result = '';
	if (currentLevel != 4) {
		result = '<div class="picArea"><img src="' + shortContextPath +'img/country/'+countryId+'.gif" border="1" alt="" /></div>';
	}
	return result
		+ '<div class="dataArea">'
		+ cityStr
		+ '	 <a href="' + countryUrl + '" class="titleLink">' + countryName + '</a><br />'
		+ '  <a href="' + inhibitantsUrl + '" class="dataLink">Жителей: ' + usersCount + '</a><br />'
		+ '  <a href="' + blogUrl + '" class="dataLink">Статей: ' + articlesCount + ' </a><br />'
		+ '  <a href="' + photoUrl + '" class="dataLink">Фото: ' + photoCount + '</a><br />'
		+ '  <a href="' + videoUrl + '" class="dataLink">Видео: ' + videoCount + '</a><br />'
		+ '</div>';
}