﻿// JScript 文件

var showorder_init=false; //是否已经显示主界面
var divmax=7; //div最大数,要和Flash中数字同步
var divcur=-1;//当前索引

//旧位置
var otop
var oleft 
var owidth
var oheight

//检查系统所使用的对象			
//if(testobj('Msxml2.XMLHTTP')==false){alert('您的浏览机器不支持Msxml2.XMLHTTP.请降低IE的安全设置,如果还不行就请联系开发商.');};
//if(testobj('MSXML2.DOMDocument')==false){alert('您的浏览机器不支持MSXML2.DOMDocument.请降低IE的安全设置,如果还不行就请联系开发商.');};
//=====================================================


//主显示控件位置
function showorder(itop,ileft,iwidth,iheight)
{
    //alert('ex showorder');
    //alert(itop + " " + ileft + " " + iwidht + " " +iheight);
    otop=itop;
    oleft=ileft;
    owidth=iwidth;
    oheight=iheight;
  
    var tdiv=document.getElementById("div" +divcur);
    var tfrm=document.getElementById("iframe" +divcur);
    if(tfrm!=null)//这些代码是为刷新div_content中的子iframe,不然会导致高度刷新不及时
    {
        tdiv.style.top=otop;
        tdiv.style.left=oleft;
        tdiv.style.width=owidth;
        tdiv.style.height=oheight;
    
        tfrm.style.top=0;
        tfrm.style.left=0;
        tfrm.style.width=owidth;
        tfrm.style.height=oheight;
    }
}







function flash_showpage(index,url)
{
   //alert('ex showpage');
   divcur=index;
   
   var tdiv=document.getElementById('div'+index);
   tdiv.style.top=otop;
   tdiv.style.left=oleft;
   tdiv.style.width=owidth;
   tdiv.style.height=oheight;
   //tdiv.innerHTML='<iframe scrolling=\"auto\" id=\"iframe'+divcur+'\" src=\"'+url+'\" style=\"top:0;left:0;height:100%;width:100%;\" frameborder=\"0\" allowTransparency=\"true\" />';
   var s='<iframe allowTransparency=\"true\" scrolling=\"auto\" frameborder=\"0\" id=\"iframe'+divcur+'\" src=\"'+url+'\" style=\"background-color:transparent;position: absolute; top:0; left:0; height:'+oheight +'; width:'+ owidth +';\" ></iframe>';
   tdiv.innerHTML=s;
   
   //alert(s);
    
   //document.getElementById("iframe" +divcur).style.top=0;
   //document.getElementById("iframe" +divcur).style.left=0;
   //document.getElementById("iframe" +divcur).style.height=oheight;
   //document.getElementById("iframe" +divcur).style.width=owidth;
   
   //alert(tdiv.innerHTML);

}	

//============================================================================================
//隐藏所有html层 sfindex为要释放的层索引
function flash_hideall(sfindex)
{
    flash_showdivbyindexhide(-1); //隐藏所有临时这样用了。
    flash_cleardivbyid(sfindex); //不知为何此方法不能用
}

//显示指定索引的的div 其他的全部隐藏
function flash_showdivbyindexhide(index)
{
    //alert('显示:'+index);
    divcur=index;
    
    for(var i=0;i<divmax;i++)
    {
        if(index==i)
        {
            document.getElementById('div'+i).style.display='';
            divcur=i;
        }
        else
        {
            document.getElementById('div'+i).style.display='none';
        }
    }
    showorder(otop,oleft,owidth,oheight); //重新位置
}


//通过id 这里其实是index清除div
function flash_cleardivbyid(index)
{
     document.getElementById('div'+index).innerHTML=''; 
}


//刷新index的 div
function flash_refreshcurdiv(index)
{
    var tfrm=document.getElementById("iframe" +index).contentWindow.document;
    if(tfrm!=null)
    {
       tfrm.location.reload();
    }
}

//退出前的步骤
function exits()
{
   flash_hideall(-1); //隐藏所有
    for(var i=0;i<divmax;i++) //清理所有
    {
        flash_cleardivbyid(i);
    }
}

//==========================================================================================

//启动后默认显示,偶尔会出现页面没有显示出来就执行了这个
function viewinit(def_modulei,def_title,def_url)
{
    index_left.onChange(def_modulei);
    viewPage(def_title,def_url);
}

//===========================================

//显示对话框框
function debug(str)
{
    alert(str);
}


//================================================
   
    //初始化
    function init()
    {
        //当是其他浏览器改变div的层 z-index 已兼容到最顶层
        if (navigator.appName.indexOf("Microsoft") != -1) //当是IE
        {
            for(var i=0;i<divmax;i++)
            {
                document.writeln('<div id=\"div' +i+ '\" style=\"background-color:transparent;position:absolute;display:none;top:0px;left:0px;width:0px;height:0px;z-index:-1;\"></div>');
            }
        }
        else //当是标准
        {
            for(var i=0;i<divmax;i++)
            {
                document.writeln('<div id=\"div' +i+ '\" style=\"background-color:transparent;position:absolute;display:none;top:0px;left:0px;width:0px;height:0px;\"></div>');
            }
        }
    }


	//设置主舞台尺寸 (暂无用)
	function resizeSWF(w,h) 
	{
        document.getElementById("framem_main").style.width = w;
        document.getElementById("framem_main").style.height = h;
        window.scrollTo(0,0);
    }
    
    
    init()//初始化

