function initMainMenu()
{
	hideMainMenu(1000);
	$('#mainMenu').mouseover(function() {
 	 	showMainMenu(2000);
	});
	
	$('#mainMenu').mouseout(function() {
 	 	hideMainMenu(2000);
	});
}

function loadStaticSection(name)
{
	hideMainMenu(2000);
	showStaticSection(name);
	$.address.title(unescape(title + " - " + name));
	$("#titleSectionStatic").find("span").css("display","none");
	$("#titleSectionStatic").html(unescape(name.toUpperCase()));
	$("#titleSectionStatic").css("display","block");
	closeInfoPanel();
}

function loadHome()
{
	hideStaticSections();
	getDataPreviewForHome();
	hideMainMenu(2000);
	closeInfoPanel();
}

function loadSection(name, type, id, category)
{
	hideStaticSections();
	$.address.title(unescape(title + " - " + name));
	getDataPreview(name, type, id, category);
	hideMainMenu(2000);
	closeInfoPanel();
}

function showMainMenu(time)
{
	$('#mainMenu').stop();
	$('#mainMenu').animate({
    top:"0px"
    }, time, 'easeOutExpo');
}

function hideMainMenu(time)
{
	$('#mainMenu').stop();
	$('#mainMenu').animate({
    top:(-parseFloat($("#mainMenu").innerHeight()) + 30 ) + "px"
    }, time, 'easeOutExpo');
}

function getDataPreviewForHome()
{
	var request = $.ajax(
	{
 		url: "assets/php/getInfo.php",
  		type: "POST",
  		data: {home : "yes"},
 		dataType: "html"
	});
	
	request.done(function(msg)
	{
  			$("#hiddenList").html(msg);
  			hidePreview(msg);
			$("#totPreview").html((parseInt($("#hiddenList li").length)));
			$("#actualNumber").html((1));
			
	  		showBigImage($("#hiddenList li:eq("+(0)+")").find("img").attr("rel"));
	});

	request.fail(function(jqXHR, textStatus)
	{
  		alert( "Request failed: " + textStatus );
	});

}

function getDataPreview(name, type, id, category, home)
{
	
	$("#titlePreview").find("span").css("display","none");
	if(type == "category")
	{
		$("#titleCategory").html(unescape(name.toUpperCase()));
		$("#titleCategory").css("display","block");
	}
	else
	{
		$("#titlePreview").find("span").css("display","block");
		$("#titleCategory").html(unescape(category.toUpperCase()));
		$("#titleGallery").html(unescape(name.toUpperCase()));
	}

	var request = $.ajax(
	{
 		url: "assets/php/getInfo.php",
  		type: "POST",
  		data: {name : name, type : type, category : category},
 		dataType: "html"
	});
	
	request.done(function(msg)
	{
  		if(id == "")
  		{
  			$("#listPreview").html(msg);
	  		showPreview();
	  	}
  		else if(id != "")
  		{
  			$("#hiddenList").html(msg);
  			hidePreview(msg);
			$("#totPreview").html((parseInt($("#hiddenList li").length)));
			$("#actualNumber").html((parseInt(id)));
	  		showBigImage($("#hiddenList li:eq("+(id - 1)+")").find("img").attr("rel"));
	  	}
	});

	request.fail(function(jqXHR, textStatus)
	{
  		alert( "Request failed: " + textStatus );
	});
}
