﻿ var ab=new Object();
 var bb=new Object();
 var bb2=new Object();
 var cb=db();
 var eb=0;
 var timer=new Object();
 var auto_reload=1;var fb=new Object();
 var	is_opera=window.opera!==undefined;
 var	is_ie=document.all!==undefined&&window.opera===undefined;
 var is_ie6p=document.compatMode!==undefined&&document.all!==undefined&&window.opera===undefined;
 var is_ie7=document.documentElement!==undefined&&document.documentElement.style.maxHeight!==undefined;
 var is_ie6=is_ie6p&&!is_ie7;
 var is_ff2p=window.Iterator!==undefined;
 var is_ff3p=document.getElementsByClassName!==undefined;
 var is_ff2=is_ff2p&&!is_ff3p
function start(){
   setNav();
mb("l1");mb("l2");mb("l3");mb("l4");
initCounter();
   if(typeof init_local=='function'){
   init_local();
   }
if(quest.number===null){qst_handle();}
 setABHeight("leftbar","map");
qst_getreports();
 
}
function setNav()
{
 for(var i=1;i<7;i++)
 {
    var nav=$('img_header_btn_0'+i);
    if(nav)
     {
      nav.i_i=i;
      
       // if(nav.alt!='up'){
       nav.onmouseover=function(){ this.src='images/btn/top_btn_0'+this.i_i+'_up.gif';  }
       nav.onmouseout=function(){this.src='images/btn/top_btn_0'+this.i_i+'_down.gif';}
     //  }
     }
 }
}
 function qst_getreports()
{
md={'val':1};
jd(lg(),function(wg){},'POST',md);
  window.setTimeout('qst_getreports()',30000);
}
function lg(){var mg='ajax.ashx?f=qst';var ig=(Math.abs(quest.number)+1)/(Math.abs(quest.last)+1);   return mg+'&cr='+hg(4,ig);}
function now(){  return new Date().getTime();}
function db(){return Math.round(now()/1000);}
function ob(pb){p=pb.innerHTML.split(":");qb=p[0]*3600+p[1]*60+p[2]*1;return qb;}
function rb(s){var sb,tb,ub;if(s>-2){sb=Math.floor(s/3600);tb=Math.floor(s/60)%60;ub=s%60;t=sb+":";if(tb<10){t+="0";}
t+=tb+":";if(ub<10){t+="0";}
t+=ub;}
else
{t="<a href=\"#\" onClick=\"return Popup(2,5);\"><span class=\"c0 t\">0:00:0</span>?</a>";}
return t;}
function $(s){return document.getElementById(s);}
function executeCounter(){
  for(var i in ab){
     vb=db()-cb;wb=rb(ab[i].counter_time+vb);ab[i].node.innerHTML=wb;
  }
for(i in bb){
vb=db()-cb; xb=bb[i].counter_time-vb
if(eb==0&&xb<1){eb=1;if(auto_reload==1)
{setTimeout("document.location.reload()",1000);}
else if(auto_reload==0){setTimeout("mreload()",1000);}
}
else
{}

wb=rb(xb);bb[i].node.innerHTML=wb;}

for(i in bb2){
vb=db()-cb; xb=bb2[i].counter_time-vb
if(eb==0&&xb<1){eb=1;if(auto_reload==1)
{setTimeout("document.location.reload()",1000);}
else if(auto_reload==0){setTimeout("mreload()",1000);}
}
else
{}

wb=rb(xb);bb2[i].node.innerHTML=wb;}

if(eb==0){window.setTimeout("executeCounter()",1000);}
}
//重载入页面
function mreload(){param='reload=auto';url=window.location.href;if(url.indexOf(param)==-1){if(url.indexOf('?')==-1){url+='?'+param;}
else
{url+='&'+param;}
}
document.location.href=url;}
function mb(yb){
pb=document.getElementById(yb);
if(pb!=null){
fb[yb]=new Object();
var zb=pb.innerHTML.match(/(\d+)\/(\d+)/);
element=zb[0].split("/");
$b=parseInt(element[0]);
_b=parseInt(element[1]);
ac=pb.title;
if(ac!=0){
    bc=now();
    timer[yb]=new Object();
    timer[yb].start=bc;
    timer[yb].production=ac;
    timer[yb].start_res=$b;
    timer[yb].max_res=_b;
    timer[yb].ms=3600000/ac;
    cc=100;
if(timer[yb].ms<cc){
timer[yb].ms=cc;
}
timer[yb].node=pb;executeTimer(yb);}
else
{timer[yb]=new Object();fb[yb].value=$b;}
}
}
function executeTimer(yb){
vb=now()-timer[yb].start;
   if(vb>=0){dc=Math.round(timer[yb].start_res+vb*(timer[yb].production/3600000));
   if(dc>=timer[yb].max_res){dc=timer[yb].max_res;}
    else if(dc<-1000) dc=0;
    else
    {window.setTimeout("executeTimer('"+yb+"')",timer[yb].ms);}
fb[yb].value=dc;timer[yb].node.innerHTML=dc+'/'+timer[yb].max_res;}
}

function initCounter(){
for(var i=1;;i++){pb=document.getElementById("tp"+i);if(pb!=null){ab[i]=new Object();ab[i].node=pb;ab[i].counter_time=ob(pb);}
else{break;}
}
for(i=1;;i++){pb=document.getElementById("timer"+i);if(pb!=null){bb[i]=new Object();bb[i].node=pb;bb[i].counter_time=ob(pb);}
else{break;}
}

for(i=1;;i++){pb=document.getElementById("btimer"+i);if(pb!=null){bb2[i]=new Object();bb2[i].node=pb;bb2[i].counter_time=ob(pb);}
else{break;}
}
executeCounter();
//qst_getreports();
}
var quest={'anmstep':false}
var ec=new Array(0,0,0,0,0);


function add_res(fc)
{gc=fb['l'+(5-fc)].value;hc=haendler*carry;ec[fc]=ic(ec[fc],gc,hc,carry);document.getElementById('r'+fc).value=ec[fc]; }
function upd_res(fc,jc){gc=fb['l'+(5-fc)].value;hc=haendler*carry;if(jc){kc=gc;}
else
{kc=parseInt(document.getElementById('r'+fc).value);}
if(isNaN(kc)){kc=0;}
ec[fc]=ic(parseInt(kc),gc,hc,0);document.getElementById('r'+fc).value=ec[fc];}
function ic(lc,mc,nc,oc){pc=lc+oc;if(pc>mc){pc=mc;}
if(pc>nc){pc=nc;}
if(pc==0){pc='';}
return pc;}
function qc(n,d){var p,i,x;if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}
if(!(x=d[n])&&d.all)x=d.all[n];for(var i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n];for(var i=0;!x&&d.layers&&i<d.layers.length;i++)x=qc(n,d.layers[i].document);return x;}


function pop(ad){bd=window.open(ad,"map","top=100,left=25,width=975,height=550");bd.focus();return false;}
var cd=document.getElementById?1:0;var dd=document.all?1:0;var ed=(navigator.userAgent.indexOf("Mac")>-1)?1:0;var fd=(dd&&(!ed)&&(typeof(window.offscreenBuffering)!='undefined'))?1:0;var gd=fd;var hd=fd&&(window.navigator.userAgent.indexOf("SV1")!=-1);function changeOpacity(id,opacity){if(fd){id.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity='+(opacity*100)+')';}
else if(cd){id.style.MozOpacity=opacity;}
}
function jd(url,kd,ld,md){if(ld===undefined){ld='GET';}
var nd;if(window.XMLHttpRequest){nd=new XMLHttpRequest();}
else if(window.ActiveXObject){try{nd=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){try{nd=new ActiveXObject("Microsoft.XMLHTTP");}
catch(e){}
}
}
else{throw'Can not create XMLHTTP-instance';}
nd.onreadystatechange=function(){if(nd.readyState==4){if(nd.status==200)
{var od=nd.getResponseHeader('Content-Type');od=od.substr(0,od.indexOf(';'));
switch(od){case'application/json':kd((nd.responseText==''?null:eval('('+nd.responseText+')')));
break;case'text/plain':kd(nd.responseText);break;
default:;}
}
else{throw'An error has occurred during request';}
}
}
;nd.open(ld,url,true);if(ld=='POST'){nd.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=utf-8');var pd=qd(md);}
else{var pd=null;}
nd.send(pd);}
function qd(rd){var sd='';var td=true;for(var ud in rd){sd+=(td?'':'&')+ud+'='+window.encodeURI(rd[ud]);if(td){td=false;}
}
return sd;}
function hg(length,ig){if(length===undefined){length=8;}
if(ig===undefined){ig=0.5;}
var jg='0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';var hg='';for(var i=0;i<length;i++){var kg=Math.floor((Math.random()+ig)*0.5*jg.length);hg+=jg.substring(kg,kg+1);}
return hg;}
function setmsgtip(v1,v2)
{ 
if(v1==true)
{
var dh=$('img_header_btn_05');
if(dh)
{dh.src='images/btn/top_btn_05_s.gif';
 
}

}
if(v2==true)
{
var dh=$('img_header_btn_06');
if(dh)dh.src='images/btn/top_btn_06_s.gif';;
}
//alert(url);
}
 
// JavaScript Document
function setABHeight(eABa,eABb) {
    var colHeightNeed = this.document.getElementById(eABa);
    if (!colHeightNeed){}
    else
    {
        var colABaH = this.document.getElementById(eABa).scrollHeight;
        var colABbH = this.document.getElementById(eABb).scrollHeight;
        if (colABaH > colABbH)
        {
            this.document.getElementById(eABb).style.height=this.document.getElementById(eABa).scrollHeight+"px";
        }
        else if (colABbH > colABaH)
        {
            this.document.getElementById(eABa).style.height=this.document.getElementById(eABb).scrollHeight+"px"
        }
    }
};


function Allmsg(){for(var x=0;x<document.msg.elements.length;x++){var y=document.msg.elements[x];if(y.name!='s10')y.checked=document.msg.s10.checked;}
}
 



function gb(){return hb('height');}
function ib(){return hb('width');}
function hb(jb){var kb=0,lb=0;if(typeof(window.innerWidth)=='number'){kb=window.innerWidth;lb=window.innerHeight;}
else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){kb=document.documentElement.clientWidth;lb=document.documentElement.clientHeight;}
else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){kb=document.body.clientWidth;lb=document.body.clientHeight;}
 setABHeight("leftbar","proxy");
 setABHeight("proxy","map");
  setABHeight("leftbar","map");
if(jb=='height')return lb;if(jb=='width')return kb;}
function Close(){pb=document.getElementById("proxy");if(pb!=null){pb.innerHTML='';}
if(quest.anmstep!==false){quest.anmstep=false;}
}
function AddObjEvent(obj,eventName, eventHandler){	if (obj.attachEvent != null)	{		obj.attachEvent('on' + eventName, eventHandler);	}	else	{		obj.addEventListener(eventName, eventHandler, false);	}} 
 