/**
 * FileStreamer
 * Copyright (c) 2006 MakProject.com. All Rights Reserved.
 * http://www.filestreamer.makproject.com
 *
 * Authors:
 *  Toni Rajkovski <rtoni@makproject.com>
 *  Vladimir Jakimov <vjakimov@makproject.com>
 */
 

var xftp = null;

function XftpBackendHelp(url){
	XftpCore.call(this, url, "frontend");
	this.initialize();
	this.setElementsVariables();
}

XftpBackendHelp.prototype = new XftpCore();
XftpBackendHelp.prototype.helpBoxFrame = "";
XftpBackendHelp.prototype.activePage = "";

XftpBackendHelp.prototype.setElementsVariables = function(){
    this.clientBoxFrame = document.getElementById("categories_frame");
    this.mainFrame = document.getElementById("main_frame");
    this.setElements(this.isCollapsed);
}

/*
 *  PAGES
 */
XftpBackendHelp.prototype.refreshClientFrame = function(){
    this.clientBoxFrame.src = this.URLBackEndHelp + "help_category/tree.php";
} 
 
XftpBackendHelp.prototype.refreshMainFrame = function(){
    if (this.mainFrame != null)
        this.mainFrame.src = this.mainFrame.src;
} 

XftpBackendHelp.prototype.refreshFrames = function(){
    this.refreshClientFrame();
    this.refreshMainFrame();
};

XftpBackendHelp.prototype.displayHomePage = function(){
    xmlDoc = this.getBasicXMLDocument();
    this.displayHtml(this.URLBackEndHelp + "home.xsl", xmlDoc, this.contentElementId);
    this.activePage = "HomePage";
};

XftpBackendHelp.prototype.displayMainFrame = function(src){
    var xmlStr = "<root><frame_src>"+src+"</frame_src></root>"
	var xmlDoc = this.returnXmlDocumentFromString(xmlStr);
	xmlDoc = this.mergeXMLDocuments(xmlDoc, this.getBasicXMLDocument());
    this.displayHtml(this.URLBackEndHelp + "main_frame.xsl", xmlDoc, this.contentElementId);
    this.mainFrame = document.getElementById("main_frame");
};

XftpBackendHelp.prototype.categoryClick = function(categoryId, link, is_page){
	this.selectedCategoryId = categoryId;

    if(is_page=="true") this.displayMainFrame(link);
    else this.clientBoxFrame.src = link;
}

XftpBackendHelp.prototype.subCategoryClick = function(subCategoryId){
    this.selectedSubCategoryId = subCategoryId;
    this.selectedItemId = 0;
    this.refreshHeader();
    this.displayMainFrame('item/list.php');
}

XftpBackendHelp.prototype.setElements = function(value){
    if(value == "false"){
        this.isCollapsed = "false";
        document.getElementById('HelpBox').style.visibility = 'hidden';
        document.getElementById('left_td').width = 20;
        document.getElementById('right_td').width = 700;
        document.getElementById('background_td').style.backgroundImage = "url(" + this.URL + "images/skins/" + this.skin + "back_collapsed.jpg)";
        document.getElementById('button_collapse').src = this.URL + "images/skins/" + this.skin + "button_expand.jpg";
        document.getElementById('button_collapse').hspace = 1;
    }
    else{
        this.isCollapsed = "true";
        document.getElementById('HelpBox').style.visibility = 'visible';
        document.getElementById('left_td').width = 253;
        document.getElementById('right_td').width = 463;
        document.getElementById('background_td').style.backgroundImage = "url(" + this.URL + "images/skins/" + this.skin + "back_expanded.jpg)";
        document.getElementById('button_collapse').src = this.URL + "images/skins/" + this.skin + "button_collapse.jpg";
        document.getElementById('button_collapse').hspace = 2;
    }
}

XftpBackendHelp.prototype.revertSite = function(){
    if (this.isCollapsed == "true") this.setElements("false");
    else this.setElements("true");
}
