if (window.XMLHttpRequest) {
  var BroserIE=false;
  }
else {
  var BroserIE=true;
  }

String.prototype.Trim=function() {return this.replace(/(^\s*)|(\s*$)/g, "");}

function Get_ttt() {
  var QAnyQDate=new Date();
  var ttt=QAnyQDate.getTime();
  return ttt;
  }

function createXmlHttp() {
  var xmlHttp;  
  if (window.XMLHttpRequest) {
    xmlHttp=new XMLHttpRequest();
    }
  else {
    if (window.ActiveXObject) {
      var prefixes=["Msxml2","Microsoft","Msxml","Msxml3"];
      for (var i=0;i < prefixes.length;i++) {
        try {
          xmlHttp=new ActiveXObject(prefixes[i]+".XMLHTTP");
          }
        catch (e) {
          }
        }
      }
    }

  if (!xmlHttp) {
    alert("您正使用的浏览器不支持创建 XMLHttpRequest 对象。");
    }
  else {
    return xmlHttp;
    }
  }

ChatInfoDoNow=setTimeout("doChatInfo()",1000000);

function LoadPage(n) {
  clearTimeout(ChatInfoDoNow);

  if (arrayMenuPage[n]=='') {
    var xmlHttp=createXmlHttp();  
    xmlHttp.onreadystatechange=function() {
      if (xmlHttp.readyState==4 && xmlHttp.status==200) {
        arrayMenuPage[n]=xmlHttp.responseText.Trim();
        $("main").innerHTML=arrayMenuPage[n];
        if (n==3) {
          doChatInfo();
          }
        }
      }

    xmlHttp.open("GET","mibiao/include/page_"+n+".php?ttt="+Get_ttt(),true);
    xmlHttp.send("");  

    $("main").innerHTML="<img src='images/ajax-loader.gif' />";
    }
  else {
    $("main").innerHTML=arrayMenuPage[n];
    if (n==3) {
      doChatInfo();
      }
    }

  $("menu"+varMenuNow).style.backgroundImage="url(images/menux.png)";
  $("menu"+varMenuNow).style.color="#336699";
  $("menu"+n).style.backgroundImage="url(images/menub.png)";
  $("menu"+n).style.color="#ffffff";

  arrayMenuBack[varMenuNow]='x';
  arrayMenuBack[n]='b';

  arrayMenuColor[varMenuNow]='#336699';
  arrayMenuColor[n]='#ffffff';

  varMenuNow=n;

  }

var photoTime      = 0;
var photoMicroTime = 0;

function doChatInfo() {
  var xmlHttp=createXmlHttp();  
  xmlHttp.onreadystatechange=function() {
    if (xmlHttp.readyState==4 && xmlHttp.status==200) {

      var temp = xmlHttp.responseText.Trim();

      if (temp=="") {

        $("main").innerHTML='数据库连接故障。';

        }
      else {

        var tempS = temp.split("&");

if ((photoTime != parseInt(tempS[0])) || (photoMicroTime != parseInt(tempS[1]))) {

        photoTime      = parseInt(tempS[0]);
        photoMicroTime = parseInt(tempS[1]);

        $("main").innerHTML=arrayMenuPage[3];  // 排除 innerHTML='数据库连接故障 。'


        var row,cell;


        for (var i=2; i < tempS.length; i++) {
         row  = document.createElement("tr");
            cell = document.createElement("td");
            cell.width="10px";
if (BroserIE==true) {
  cell.style.background="#fff";
}
            cell.innerHTML="";
            row.appendChild(cell);


          sArray = tempS[i].split(",");

//          cell = document.createElement("td");
//          cell.width="30px";             
//          cell.innerHTML='图像';//sArray[3];
//          row.appendChild(cell);

          cell = document.createElement("td");
            cell.width="15px";
//cell.style.background="#fff";
cell.className="pngX";
//          cell.innerHTML="<img onclick='vvv();' title='违章图像 pself_"+sArray[0]+"_"+sArray[1]+".jpg' style='cursor:pointer' src='mibiao/image/photo.png' />";
          cell.innerHTML="";
cell.style.cursor="pointer";
cell.title="显示违章图像";
cell.setAttribute("onclick","vvv('"+tempS[i]+"')");
          row.appendChild(cell);

            cell = document.createElement("td");
            cell.width="8px";
            cell.innerHTML="";
            row.appendChild(cell);

          cell = document.createElement("td");
          cell.width="100px";             
          cell.innerHTML=sArray[3];
          row.appendChild(cell);

          cell = document.createElement("td");
          cell.width="115px";             
          cell.innerHTML=sArray[2];
          row.appendChild(cell);

          cell = document.createElement("td");
          cell.width="80px";             
          cell.innerHTML="车位 "+sArray[6];
          row.appendChild(cell);

          cell = document.createElement("td");
//          cell.width="50px";             
          cell.innerHTML="( "+sArray[5]+" ) "+sArray[7];
cell.title=sArray[4];
          row.appendChild(cell);

//          cell = document.createElement("td");
//          cell.innerHTML=sArray[7];
//          row.appendChild(cell);

        $("PselfTable").insertBefore(row,$("PselfTable").childNodes[0]);
row.setAttribute("onmouseover","m_over(this)");
row.setAttribute("onmouseout","m_out(this)");
          }


        arrayMenuPage[3]=$("main").innerHTML;

        $("main").innerHTML=arrayMenuPage[3];

        }

}

      }
    }

  xmlHttp.open("GET","mibiao/include/ChatBack.php?ttt="+Get_ttt()+"&photo="+photoTime+"&micro="+photoMicroTime,true);
  xmlHttp.send("");  

  ChatInfoDoNow=setTimeout("doChatInfo()",10000);
  ChatInfoDoNow;
  }

function vvv(sFilename) {
          createWinPopup(' ',380,155,sFilename);
  }

function m_over(o) {
  o.style.background="#cfc";
  }

function m_out(o) {
  o.style.background="none";
  }
function QAnyQWindow(title,y,width,varHTML) {
	
  this.title=title;
  this.width=width;
  this.x=(document.body.clientWidth-780)/2+(780-width-200)/2+210;
  this.y=y;
  this.id='WinPopup';
  this.bgcolor="#ffffff";
	
  this.oTable=document.createElement("table");
  this.oTable.id="Window WinPopup";
  this.oTable.style.width=this.width+"px";
  this.oTable.style.borderLeft="1px solid #999999";
  this.oTable.style.borderRight="1px solid #999999";
  this.oTable.style.borderBottom="1px solid #999999";
  this.oTable.style.borderTop="0px solid #999999";
  this.oTable.cellSpacing=0;
  this.oTable.cellPadding=0;
  this.oTable.border=0;
  this.oTable.style.backgroundColor="#ffffff";

  this.oTable.style.position="absolute";
  this.oTable.style.left=this.x+"px";
  this.oTable.style.top=this.y+"px";

  this.oTable.qPlus=this;

  document.body.appendChild(this.oTable);

  var oTR=this.oTable.insertRow(0);
	
  oTD=oTR.insertCell(0);
  oTD.innerHTML=title;
  oTD.qPlus=this;
  oTD.style.textAlign='Left';
  oTD.style.color='#fff';
  oTD.style.borderBottom="1px solid #000000";
  oTD.style.backgroundImage="url(images/menux.png)";
  oTD.height="20";
  var varWidth=width-18;
  oTD.width=varWidth+"px";
  oTD.style.paddingLeft="2px";
  oTD.style.paddingTop="2px";
  oTD.style.color="#888";
  oTD.innerHTML="违章图像";
	
  oTD=oTR.insertCell(1); 

  oTD.qPlus=this;
  oTD.onmousedown=QAnyQWindow.prototype.onClose;
  oTD.title="关闭";
  oTD.style.borderBottom="1px solid #000000";
  oTD.width="18px";
if (BroserIE==true) {
  oTD.style.paddingTop="2px";
} else {
  oTD.style.paddingTop="3px";
}
  oTD.style.backgroundImage="url(images/menux.png)";
  oTD.innerHTML="<img style='cursor:pointer' align='top' src='image/pop_title_close_new.gif' />";
	
  oTR = this.oTable.insertRow(1);
	
  this.oContentTD=oTR.insertCell(0);
  this.oContentTD.colSpan=13;
  this.oContentTD.style.textAlign='Left';
  this.oContentTD.style.paddingLeft="8px";
  this.oContentTD.style.backgroundColor="#ffffcc";
  this.oContentTD.style.color='#669966';
 
          sArray = varHTML.split(",");
  this.oContentTD.innerHTML="<br /><br /><span style='padding-left:60px;'><img src='admin/pro/photo/"+"pself_"+sArray[0]+"_"+sArray[1]+".jpg' width='120' height='160' /></span><br /><br />"+sArray[2]+" 车位 "+sArray[6]+" ( "+sArray[5]+" ) "+sArray[7]+"<br />";
  }



QAnyQWindow.prototype.close=function() {	
  this.oTable.parentNode.removeChild(this.oTable);
  }

QAnyQWindow.prototype.onClose=function() {
  this.qPlus.close();
  }


function createWinPopup(title,width,y,varHTML) {
  if (document.getElementById('Window WinPopup')) {
    WinPopup.close();
    }

  WinPopup=new QAnyQWindow(title,y,width,varHTML); 
  document.getElementById('Window WinPopup').style.zIndex="999999";
  }

function closeWinPopup() {
  if (document.getElementById('Window WinPopup')) {
    WinPopup.close();
    }
  }



function LoadHTML(url,obj,varPOST) {
  var xmlHttp=createXmlHttp();  
  xmlHttp.onreadystatechange=function() {
    if (xmlHttp.readyState==4 && xmlHttp.status==200) {
      var Result=xmlHttp.responseText.Trim();
      $(obj).innerHTML=Result;
      }
    }

  xmlHttp.open("GET","mibiao/include/"+url+".php?ttt="+Get_ttt(),true);
  xmlHttp.send(varPOST);  
  }


function pageAppend(n) {
  switch (n) {
    case 0:
      $("LinkToUs").style.height="230px";
      $("LinkToUs").innerHTML="<span style='padding-left:44px'><img src='images/ajax-loader.gif' /></span>";
      LoadHTML("LinkToUs","LinkToUs","");
      break;
    case 1:
      $("Law").style.height="280px";
      $("Law").innerHTML="<span style='padding-left:44px'><img src='images/ajax-loader.gif' /></span>";
      LoadHTML("Law","Law","");
      break;
    }
  }

