
var smf_themeInfo = {
	2851: {
		name: 'Alpha Centauri',
		desc: 'Alpha Centauri is a theme I have worked on before - but this time its only the theme left, no special features added. On the other hand its a modern theme with&nbsp; sci-fi inspired graphics and colors, and its HTML5/CSS3 based with responsive layout as well.<br /><br />16.jul.2016 - v203: shrinked the menu buttons for mobile devices, updated source file for buttons + the css is changed to better suit the buttons.<br />05.07.2017 - v20rev4 - various css fixes for mobile view.<br />07.07.2017 - v20rev5 - more fixes.',
		file: 'alphacentauri20rev5.zip',
		author: 'BHKristiansen'
	},
	2925: {
		name: 'South Theme',
		desc: '<div align="center"><a href="http://vaveyla.net/smf/index.php" class="bbc_link" target="_blank"><img src="https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fvaveyla.net%2Fdemo.png&hash=0042e933d70a9a3e2c432a79d67cdf78" alt="" class="bbc_img" /></a></div>',
		file: 'south.zip',
		author: '[S.W.T]'
	},
	2924: {
		name: 'Cloudy',
		desc: 'Cloudy is a simple blue theme using css3 to bring it to life, creating a soft look that works for most forums.<br /><br />Terms of use :<br /><br />This theme is free for personal and commercial use. You are allowed to use it in your projects, change it and adapt for your purposes. You are not allowed to remove the authors copyright.',
		file: 'cloudy.zip',
		author: 'BryanD'
	},
	2923: {
		name: 'Badem Smf 2.0 bootstrap Themes',
		desc: 'Badem is a fully featured, Smf template built with Bootstrap 4, HTML5, CSS3 and JQuery. Badem is also available in&nbsp; PHP and Ajax version. It’s a minimal responsive.<br /><br />FEATURES: <br /><br /><ul class="bbc_list"><li>Responsive layout (desktops, tablets, mobile devices)</li><li>Built with Bootstrap 4.1.3</li><li>Font Awesome 5.3.1</li><li>HTML5 &amp; CSS3</li></ul><br />Responsive list<br />-----------------------<br />.Board Template<br />.Display Template<br />.Members List<br />.Profile Template<br />.Calendar.template<br />.Admin Panel<br /><br /><img src="https://i.imgur.com/jcRfp8C.png" alt="" width="600" height="283" class="bbc_img resized" /><br /><br /><img src="https://i.imgur.com/ZITI5Vv.png" alt="" width="600" height="264" class="bbc_img resized" />',
		file: 'Badem.zip',
		author: 'gecitli'
	},
	2674: {
		name: 'Habbingo',
		desc: '<div align="center"><img src="https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fdemo.smftricks.com%2FThemes%2FHabbingo%2Fimages%2Flogo.png&hash=4eddef526d2abb025c175cfed0e78396" alt="" class="bbc_img" /><br /><hr /><br /><img src="https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FBrYyE.png&hash=b4a4904d25c4e04dedc417bca094faf4" alt="" width="400" height="345" class="bbc_img resized" /><br /><br /><hr /><strong>Attention:</strong> This theme uses CSS3, not support for some browsers.<br /><span style="font-size: 12pt;" class="bbc_size"><a href="http://demo.smftricks.com/" class="bbc_link" target="_blank">Demo</a></span></div>',
		file: 'Habbingo.zip',
		author: 'Daniiel'
	}
};
var smf_featured = 2851;
var smf_random = 2674;
var smf_latestThemes = [2925, 2924, 2923];
function smf_themesMoreInfo(id)
{
	window.smfLatestThemes_temp = document.getElementById("smfLatestThemesWindow").innerHTML;

	// !!! Why not just always auto?
	document.getElementById("smfLatestThemesWindow").style.overflow = "auto";
	setInnerHTML(document.getElementById("smfLatestThemesWindow"),
	'\
		<h3 style="margin: 0; padding: 4px;">' + smf_themeInfo[id].name + '</h3>\
		<h4 style="margin: 0;padding: 4px;"><a href="https://custom.simplemachines.org/themes/index.php?lemma=' + id + '">View Theme Now!</a></h4>\
		<div style="overflow: auto;">\
			<img src="https://custom.simplemachines.org/themes/index.php?action=download;lemma='+id+';image=thumb" alt="" style="float: right; margin: 10px;" />\
			<div style="padding:8px;">' + smf_themeInfo[id].desc.replace(/<a href/g, '<a href') + '</div>\
		</div>\
		<div style="padding: 4px;" class="smalltext"><a href="javascript:smf_themesBack();void(0);">(go back)</a></div>');
}

function smf_themesBack()
{
	document.getElementById("smfLatestThemesWindow").style.overflow = "";
	setInnerHTML(document.getElementById("smfLatestThemesWindow"), window.smfLatestThemes_temp);
	window.scrollTo(0, findTop(document.getElementById("smfLatestThemesWindow")) - 10);
}

window.smfLatestThemes = '\
	<div id="smfLatestThemesWindow">\
		<div>\
			<img src="https://www.simplemachines.org/smf/images/themes.png" width="102" height="98" style="float: right; margin: 0 0 10px 10px;" alt="(package)" />\
			<ul style="list-style: none; padding: 0; margin: 0 0 0 5px;">';
for(var i=0; i < smf_latestThemes.length; i++)
{
	var id_theme = smf_latestThemes[i];
	window.smfLatestThemes += '\
				<li style="list-style: none;"><a href="javascript:smf_themesMoreInfo(' + id_theme + ');void(0);">' + smf_themeInfo[id_theme].name + ' by ' + smf_themeInfo[id_theme].author + '</a></li>';
}

window.smfLatestThemes += '\
			</ul>';
if ( smf_featured !=0 || smf_random != 0 )
{

	if ( smf_featured != 0 )
		window.smfLatestThemes += '\
				<h4 style="padding: 4px 4px 0 4px; margin: 0;">Featured Theme</h4>\
				<p style="padding: 0 4px; margin: 0;">\
					<a href="javascript:smf_themesMoreInfo('+smf_featured+');void(0);">'+smf_themeInfo[smf_featured].name + ' by ' + smf_themeInfo[smf_featured].author+'</a>\
				</p>';
	if ( smf_random != 0 )
		window.smfLatestThemes += '\
				<h4 style="padding: 4px 4px 0 4px;margin: 0;">Theme of the Moment</h4>\
				<p style="padding: 0 4px; margin: 0;">\
					<a href="javascript:smf_themesMoreInfo('+smf_random+');void(0);">'+smf_themeInfo[smf_random].name + ' by ' + smf_themeInfo[smf_random].author+'</a>\
				</p>';
}
window.smfLatestThemes += '\
		</div>\
	</div>';

function findTop(el)
{
	if (typeof(el.tagName) == "undefined")
		return 0;

	var skipMe = in_array(el.tagName.toLowerCase(), el.parentNode ? ["tr", "tbody", "form"] : []);
	var coordsParent = el.parentNode ? "parentNode" : "offsetParent";

	if (el[coordsParent] == null || typeof(el[coordsParent].offsetTop) == "undefined")
		return skipMe ? 0 : el.offsetTop;
	else
		return (skipMe ? 0 : el.offsetTop) + findTop(el[coordsParent]);
}

function in_array(item, array)
{
	for (var i in array)
	{
		if (array[i] == item)
			return true;
	}

	return false;
}