function SpdtSitePlayer() {
    this.siteXSL = null;
    this.bodyContent = null;
    this.siteXML = null;
    this.siteFileName = null;
    this.xslParamPage = null;
    this.siteElm = null;
    this.curPageElm = null;
    this.curPageLayout = null;
    
}
SpdtSitePlayer.prototype.config = function (language,xslFile) {
    var data = new Date();
    this.siteFileName = "site_"+language+".xml";
    this.siteXSL = _SpdtAJAX.getXML(baseUrl+xslFile+".xml?"+data.getTime());
    this.siteXML = _SpdtAJAX.getXML(baseUrl+"xml/"+this.siteFileName+"?"+data.getTime());
    this.siteTpt = _SpdtAJAX.getXML(baseUrl+"templates.xml?"+data.getTime());
    this.bodyContent = document.getElementById("body");
    this.xslParamPage = _SpdtAJAX.getElement(this.siteXSL,"xsl:param[@name='page']","http://www.w3.org/1999/XSL/Transform");
    this.siteElm = _SpdtAJAX.getElement(this.siteXML,"site","http://www.fiasul.com.br/SITE");
    this.curPageElm = _SpdtAJAX.getElement(this.siteXML,"page[@name='index']","http://www.fiasul.com.br/SITE");
    this.curPageLayout = _SpdtAJAX.getElement(this.curPageElm,"layout","http://www.fiasul.com.br/SITE");
    this.bodyContent.innerHTML = "";
    _SpdtAJAX.transform(this.siteXSL,this.siteXML,this.bodyContent);
}
SpdtSitePlayer.prototype.showPage = function (pagName) {
    this.xslParamPage.firstChild.nodeValue = pagName;
    this.bodyContent.innerHTML = "";
    this.curPageElm = _SpdtAJAX.getElement(this.siteXML,"page[@name='"+pagName+"']","http://www.fiasul.com.br/SITE");
    this.curPageLayout = _SpdtAJAX.getElement(this.curPageElm,"layout","http://www.fiasul.com.br/SITE"); 
    _SpdtAJAX.transform(this.siteXSL,this.siteXML,this.bodyContent);
}
SpdtSitePlayer.prototype.parse = function (node,level) {
    if (node.attributes) {
        var attValue = null;
        var funcName = null;
        var newValue = null;
        for (var nAtr = 0; nAtr < node.attributes.length; nAtr++) {
            attValue = node.attributes[nAtr].value; 
            if (attValue.indexOf("{") > -1) {
                attValue = attValue.split("{");
                newValue = null;
                for (var nToken = 0; nToken < attValue.length; nToken++) {
                    if (attValue[nToken].indexOf("}") > -1) {
                        funcName = attValue[nToken].substring(0,attValue[nToken].indexOf("}"));
                        newValue = eval("this."+funcName);
                    }
                }
                node.attributes[nAtr].value =  newValue;
            }
        }
    }
    for (var n = 0; n < node.childNodes.length; n++) {
        this.parse(node.childNodes[n],level+1);
    }
}
SpdtSitePlayer.prototype.getNewPageName = function () {
    var nPag = parseInt(this.siteElm.getAttribute("pagCounter"));
    nPag ++;
    this.siteElm.setAttribute("pagCounter",nPag+"");
    return "pag"+nPag;
}
SpdtSitePlayer.prototype.getNewId = function () {
    var nId = parseInt(this.siteElm.getAttribute("idCounter"));
    nId ++;
    this.siteElm.setAttribute("idCounter",nId+"");
    return "o"+nId;
}
var _SpdtSitePlayer = new SpdtSitePlayer();