using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml;

/// <summary>
/// Summary description for Config
/// </summary>
public class Config : System.Web.UI.Page
{
    XmlDocument xdoc;
    static Config instance;

	public Config()
	{
        xdoc = new XmlDocument();
        xdoc.Load(Server.MapPath("../config/Settings.xml"));
	}
  
    public static Config getInstance()
    {
        if (instance != null)
        {
            return instance;
        }
        else
        {
            instance = new Config();
            return instance;
        }
    }

    public String getTitulo()
    {
        XmlNodeList node_list = xdoc.GetElementsByTagName("titulo");
        return node_list[0].InnerText;  
    }

    public int getTamanhoImagens()
    {
        XmlNodeList node_list = xdoc.GetElementsByTagName("imagens");
        return int.Parse(node_list[0].Attributes[0].InnerText);
    }

    public int getTamanhoFicheiros()
    {
        XmlNodeList node_list = xdoc.GetElementsByTagName("ficheiros");
        return int.Parse(node_list[0].Attributes[0].InnerText);
    }

    public int getNumeroDias()
    {
        XmlNodeList node_list = xdoc.GetElementsByTagName("n_dias");
        return int.Parse(node_list[0].Attributes[0].InnerText);
    }

    public String getTipoLetra()
    {
        XmlNodeList node_list = xdoc.GetElementsByTagName("tipo_letra");
        return node_list[0].InnerText;
    }

    public int getTamanhoLetra()
    {
        XmlNodeList node_list = xdoc.GetElementsByTagName("tamanho_letra");
        return Convert.ToInt32(node_list[0].InnerText);
    }

    public String getEmailLogin()
    {
        XmlNodeList node_list = xdoc.GetElementsByTagName("login");
        return node_list[0].InnerText;
    }

    public String getEmailPassword()
    {
        XmlNodeList node_list = xdoc.GetElementsByTagName("password");
        return node_list[0].InnerText;
    }

    public String getEmailServidor()
    {
        XmlNodeList node_list = xdoc.GetElementsByTagName("servidor");
        return node_list[0].InnerText;
    }

    public int getEmailPorto()
    {
        XmlNodeList node_list = xdoc.GetElementsByTagName("porto");
        return int.Parse(node_list[0].InnerText);
    }

    public Boolean getEmailSeguro()
    {
        XmlNodeList node_list = xdoc.GetElementsByTagName("email");
        return Boolean.Parse(node_list[0].Attributes[0].InnerText);
    }

    public String[] getExtensoesImagem()
    {
        XmlNodeList node_list = xdoc.GetElementsByTagName("imagens");
        XmlNodeList child_nodes = node_list[0].ChildNodes;

        String[] to_return = new String[child_nodes.Count];

        for (int i = 0; i < child_nodes.Count; i++)
        {
            to_return[i] = child_nodes[i].InnerText;
        }

        return to_return;
    }

    public String[] getExtensoesFicheiro()
    {
        XmlNodeList node_list = xdoc.GetElementsByTagName("ficheiros");
        XmlNodeList child_nodes = node_list[0].ChildNodes;

        String[] to_return = new String[child_nodes.Count];

        for (int i = 0; i < child_nodes.Count; i++)
        {
            to_return[i] = child_nodes[i].InnerText;
        }

        return to_return;
    }
}
