var themes = {
	list: new Array(),			
	
	init: function() 
	{
		$.ajax({
			type: "GET",
			url: "themes/main.xml",
			dataType: "xml",
			success: function(xml) 
			{
				$(xml).find("theme").each(function(i,e) 
				{
					var id = $(e).attr('id');
					themes.list[id] = $(e).find('css').text();
				});
			}
		});
	},
	
	showbox: function() 
	{
		var s = $("#canvas_options").css('left');
		if (s == "0px") 
		{
			if (navigator.userAgent.indexOf("Firefox")!=-1)
				$("body").animate({backgroundPosition: "50% 10px"});
			else
				$("body").animate({'background-position-y': "10px"});
			
			$("#wrapper").animate({marginTop: "10px"});
			$("#canvas_options").animate({'left': '-10000px'});
		} else 
		{
			if (navigator.userAgent.indexOf("Firefox")!=-1)
				$("body").animate({backgroundPosition: '50% 125px'});
			else
				$("body").animate({'background-position-y': "125px"});
			
			$("#wrapper").animate({marginTop: "+=110px"});
			$("#canvas_options").animate({'left': '0px'});
		}
	},
	
	set: function(tid) 
	{
		div_id = tid;
		tid = tid.replace(/^t_/, '');
		
		var file = this.list[tid];	
		var file = 'themes/css/' + file;
							
		$("#theme_css").attr('href', file);
		
		$("#canvas_options #themes .theme").removeClass('selected');
		$("#canvas_options #themes #"+div_id).addClass('selected');
		
		// save cookie
		this.save(tid);
	},
	
	save: function(tid) 
	{
		$.cookie("pj-theme", tid, { expires: 30 });
	}
};

