﻿var ifr;
var map;
var info;
var scale;
var toolInfo;
function pL(){
    ifr=new CFrame();
    map=new CMap($("map"));
    var iC=document.createElement("iframe");
    iC.id="infocontent";
    iC.name="infocontent";
    iC.src="tool/";
    iC.frameBorder="no";
    if(nav()==1) iC.scrolling="auto";
    $("infocon").appendChild(iC);
    scale=new CScale($("scale"));
    scale.init();
    disData();
    fit();
    map.init();
    map.onresize=fit;
    $("h").style.visibility="visible";
    $("f").style.visibility="visible";
    $("main").style.visibility="visible";
    var panorama=$("panorama");
	var schmap=$("schmap");
    createFlashMove(panorama,"cubicvr","http://www.6dxy.com/xml/Main.swf",322,240,"1","1");
    createFlashMove($("schchinamap"),"6dChinaMap","http://www.6dxy.com/schmap/6dChinaMap.swf",600,480,"1","0");
	var mapclose=document.createElement("img");
	mapclose.src=static+"map/image/mapclose.gif";
	mapclose.width="58";
	mapclose.height="22";
	mapclose.style.cssText="cursor:pointer;position:absolute;left:400px;top:450px;";
	CEvent.addListener(mapclose,"click",srhmapHI);
	schmap.appendChild(mapclose);
    if($("menuChg")) setTimeout(function(){menuRes();},0);
	toolInfo=new ToolZoom($("infocon"),[$("info"),$("infocon"),$("infocontent"),$("infobg")],48);
    CEvent.addListener($("infoct"),"click",infozoom);
    if(!$("login")){
        if(getCookie("hnit")!=1){
            uhimtVi();
        }
        else{
            $("hnitb").checked=true;
        }
        var url=location.href.toLowerCase();
        var d=url.substr(url.indexOf("?d=")+3);
        if("http://"+location.hostname.toLowerCase()+location.pathname.toLowerCase()+"?d="+d==location.href && /^-?\d+$/.test(d)){
            _Map.DebugValue(d,map.config.areaid,onsucceededdebug);
        }
    }
}
function fit(){
    var h=$("h");
    var f=$("f");
    var srh=$("srh");
    var info=$("info");
    var infobg=$("infobg");
    var infocon=$("infocon");
    var iC=$("infocontent");
	var schbg=$("schbg");
    var login=$("login");
    if((document.documentElement.clientWidth)>ifr.config.width){
        h.style.width=document.documentElement.clientWidth+"px";
        f.style.width=document.documentElement.clientWidth+"px";
        map.holder.style.width=document.documentElement.clientWidth+"px";
        srh.style.left=(document.documentElement.clientWidth-ifr.config.infoWidth)+"px";
        info.style.left=(document.documentElement.clientWidth-ifr.config.infoWidth)+"px";
        schbg.style.width=document.documentElement.clientWidth+"px";
        if(login) login.style.width=document.documentElement.clientWidth+"px";
    }
    else{
        h.style.width=ifr.config.width+"px";
        f.style.width=ifr.config.width+"px";
        map.holder.style.width=ifr.config.width+"px";
        srh.style.left=(ifr.config.width-ifr.config.infoWidth)+"px";
        info.style.left=(ifr.config.width-ifr.config.infoWidth)+"px";
        schbg.style.width=ifr.config.width+"px";
        if(login) login.style.width=ifr.config.width+"px";
    }
    scale.holder.style.left=(map.holder.offsetWidth-scale.config.width-ifr.config.infoWidth)+"px";
    if(document.documentElement.clientHeight>ifr.config.height){
        map.holder.style.height=(document.documentElement.clientHeight-ifr.config.headHeight)+"px";
        schbg.style.height=document.documentElement.clientHeight+"px";
        if(login) login.style.height=document.documentElement.clientHeight+"px";
    }
    else{
        map.holder.style.height=(ifr.config.height-ifr.config.headHeight)+"px";
        schbg.style.height=ifr.config.height+"px";
        if(login) login.style.height=ifr.config.height+"px";
    }
	if(infocon.style.visibility!="hidden"){
        if(document.documentElement.clientHeight>ifr.config.height){
            info.style.height=(document.documentElement.clientHeight-info.offsetTop)+"px";
            infobg.style.height=(document.documentElement.clientHeight-info.offsetTop-48)+"px";
            infocon.style.height=(document.documentElement.clientHeight-info.offsetTop-48)+"px";
            iC.style.height=(document.documentElement.clientHeight-info.offsetTop-48)+"px";
        }
        else{
            info.style.height=(ifr.config.height-info.offsetTop)+"px";
            infobg.style.height=(ifr.config.height-info.offsetTop-48)+"px";
            infocon.style.height=(ifr.config.height-info.offsetTop-48)+"px";
            iC.style.height=(ifr.config.height-info.offsetTop-48)+"px";
        }
	    if(toolInfo){
	        toolInfo.zoomin();
	    }
	}
}
window.onload=pL;