//显示隐藏导航窗口

function changeBar()
{
var barWidth=window.screen.width-document.body.clientWidth;
if (document.getElementById("leftView").style.display!="none" )
{
document.getElementById("leftView").style.display = "none" ;
document.getElementById("bodyBar").innerText=">";

setTabSize("tabView",window.screen.width-barWidth-10,0);
}
else
{
document.getElementById("leftView").style.display = "block" ;
document.getElementById("bodyBar").innerText="<";
setTabSize("tabView",window.screen.width-220-barWidth,0);

}
}
function init()
{
initTabs('tabView',Array('Welcome'),0,500,500,Array(false));
window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}
var barWidth=window.screen.width-document.body.clientWidth;
document.getElementById("leftView").style.display = "block" ;
document.getElementById("bodyBar").innerText="<";


setTabSize("tabView",window.screen.width-220-barWidth,0);

var xmlHttp = XmlHttp.create();
var src=filePath+"manage/xml/menu.xml?temp="+Math.floor(Math.random()*10000);
xmlHttp.open("GET", src, true);
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) { loadMenu(xmlHttp.responseXML); };
}
xmlHttp.send(null);
var xmlHttp2 = XmlHttp.create();
var src=filePath+"manage/xml/home.xml?temp="+Math.floor(Math.random()*10000);
xmlHttp2.open("GET", src, true);
xmlHttp2.onreadystatechange = function () {
if (xmlHttp2.readyState == 4) { loadHome(xmlHttp2.responseXML); };
}
xmlHttp2.send(null);

}
function loadHome(oXmlDoc)
{
if( oXmlDoc == null || oXmlDoc.documentElement == null)
{
document.getElementById("start").innerHTML="Loadding start error!";
}
else {
var root = oXmlDoc.documentElement;
var cs = root.childNodes;
var l = cs.length;
var str="<ul>";
for (var i = 0; i < l; i++) {

if (cs[i].tagName == "tree") {
var text = cs[i].getAttribute("text");
var action = cs[i].getAttribute("action");
var icon = cs[i].getAttribute("icon");
if(icon==null)
icon=filePath+"manage/images/root.gif"
else
icon=filePath+icon;
if(action!=null&&action.indexOf("javascript:")>-1)
{
str+="<li onclick=\""+action.substring(11)+"\"><img border=\"0\" width=\"16\" height=\"16\" align=\"absmiddle\" src=\""+icon+"\"/> "+text+"</li>";
}else
{
str+="<li onclick=\"newTab('"+action+"')\"><img border=\"0\" width=\"16\" height=\"16\" align=\"absmiddle\" src=\""+icon+"\"/> "+text+"</li>";
}
}
}
str+="</ul>";
document.getElementById("start").innerHTML=str;
}
}
function loadMenu(oXmlDoc)
{
if( oXmlDoc == null || oXmlDoc.documentElement == null)
{
document.getElementById("headMenu").innerHTML="Loadding menu error!";
}
else {

var root = oXmlDoc.documentElement;
var cs = root.childNodes;
var l = cs.length;
var b=false;
var str="<ul>";
for (var i = 0; i < l; i++) {

if (cs[i].tagName == "tree") {

var text = cs[i].getAttribute("text");
var src = cs[i].getAttribute("src");
var action = cs[i].getAttribute("action");
var icon = cs[i].getAttribute("icon");
var openIcon = cs[i].getAttribute("openIcon");
if(icon==null)
icon=filePath+"manage/images/root.gif"
else
icon=filePath+icon;
if(openIcon!=null)
{
openIcon=filePath+openIcon;
}else
{  openIcon=icon;
}
if(src.indexOf("?")>=0)
src=src+"&temp="+Math.floor(Math.random()*10000);
else
src=src+"?temp="+Math.floor(Math.random()*10000);
if(action!=null&&action.indexOf("javascript:")>-1)
{

str+="<li onclick=\""+action.substring(11)+"\"><img border=\"0\" width=\"16\" height=\"16\" align=\"absmiddle\" src=\""+icon+"\"/> "+text+"</li>";
}else
{
str+="<li onclick=\"navigate('"+i+"','"+text+"','"+src+"','"+action+"','"+icon+"','"+openIcon+"')\"><img border=\"0\" width=\"16\" height=\"16\" align=\"absmiddle\" src=\""+icon+"\"/> "+text+"</li>";
}
if(!b)
{
b=true;
if(action!=null&&action.indexOf("javascript:")<0)
{action="javascript:newTab('"+action+"')";
}
var tree = new WebFXLoadTree(text,src,action,null,icon,openIcon);
tree.setBehavior("explorer");
document.getElementById("naviView").innerHTML="<div id=\"naviView0\">"+tree+"</div>";

}
}
}
str+="</ul>";

document.getElementById("headMenu").innerHTML=str;
document.getElementById("start").innerHTML=str;
}
}

function navigate(index,text,src,action,icon,openIcon)
{
var tree = new WebFXLoadTree(text,src,"javascript:newTab('"+action+"')",null,icon,openIcon);
tree.setBehavior("explorer");
if(document.getElementById("naviView"+index)!=null)
{
document.getElementById("naviView"+index).innerHTML=tree;
}else
{
document.getElementById("naviView").innerHTML=document.getElementById("naviView").innerHTML+"<div id=\"naviView"+index+"\">"+tree+"</div>";
}


if(action!="")
createTabWindow('tabView',"Loadding...",action);
}

function newTab(fileUrl)
{

createTabWindow('tabView',"Loadding...",fileUrl);

}
function openTab(fileUrl)
{
openTabWindow('tabView',"Loadding...",fileUrl);
}
function openStart()
{
showTab('tabView',0);
}

//