var WIDTH_WALLPAPERS = 506;
var HEIGHT_WALLPAPERS = 507;
var RESOLUCOES_DISPONIVEIS = Array();

/// <summary>
/// Cadastra as resoluções disponíveis de wallpapers
/// </summary>
/// <owner>Victor</owner>
function MapearResolucoes()
{
	RESOLUCOES_DISPONIVEIS[0] = {
		width: 1024,
		height: 768
	};
	
	RESOLUCOES_DISPONIVEIS[1] = {
		width: 1280,
		height: 1024
	};
	
	RESOLUCOES_DISPONIVEIS[2] = {
		width: 1360,
		height: 768
	};
	
	RESOLUCOES_DISPONIVEIS[3] = {
		width: 1440,
		height: 900
	};
}	

/// <summary>
/// Evento de load do script
/// </summary>
/// <owner>Victor</owner>
function Wallpapers_Load()
{
	MapearResolucoes();
	var width = screen.width;
	var isFinded = false;
	
	for(var i = 0; i < RESOLUCOES_DISPONIVEIS.length; i++)
	{
		var widthResolucao = RESOLUCOES_DISPONIVEIS[i].width;
		var textoResolucao = RESOLUCOES_DISPONIVEIS[i].width + "X" + RESOLUCOES_DISPONIVEIS[i].height;
		var targetResolucao = "imagens/wallpapers/wallpaper" + textoResolucao + ".png";
		if ((width <= widthResolucao || i == RESOLUCOES_DISPONIVEIS.length - 1) && !isFinded)
		{
			$("#labelResolucao").text(textoResolucao);
			$("#labelResolucao").attr("href", targetResolucao);
			isFinded = true;
		}
		else
		{
			$("#divResolucoes").append("<a href='" + targetResolucao + "' target='_blank'>" + textoResolucao + "</a><br/>");
		}
	}
}

/// <summary>
/// Abre a popup de wallpapers
/// </summary>
/// <owner>Victor</owner>
function ShowWallpapers()
{
	$("#divWallpapers").css("display", "inline");
	$("#bgEscuro").css("display", "inline");
	
		$("#divWallpapers").animate(
							 {
								 width: WIDTH_WALLPAPERS,
								 height: HEIGHT_WALLPAPERS
							 }, 800, function()
							 {
								 $("#fecharWallpapers").css("display", "inline");
							 });
}

/// <summary>
/// Esconde a popup de wallpapers
/// </summary>
/// <owner>Victor</owner>
function HideWallpapers()
{
	$("#fecharWallpapers").css("display", "none");
	$("#bgEscuro").css("display", "none");
	
	$("#divWallpapers").animate(
						 {
							 width: 0,
							 height: 0
						 }, 800, function()
						 {
							$("#divWallpapers").css("display", "none");
						 });
}
