function $id(id){ return document.getElementById(id); }


var xmlhttp = HttpAXObj();
function HttpAXObj(){
  var xmlhttp = null;
  try{
    xmlhttp= new ActiveXObject('Msxml2.XMLHTTP');
  }catch(e){
    try{
      xmlhttp= new ActiveXObject('Microsoft.XMLHTTP');
    }catch(e){
      try{
        xmlhttp= new XMLHttpRequest();
      }catch(e){
        try{
          xmlhttp= window.createRequest();
        }catch(e){}
      }
    }
  }
  if (xmlhttp) return xmlhttp;
}

function LoadAjaxData(strUrl,sid) {
  var xmlhttp = HttpAXObj();
  try{
    xmlhttp.onreadystatechange=function(){
      if(xmlhttp.readyState==4){
        if(xmlhttp.status==200){
          var response = xmlhttp.responseText;
          if (!sid){
            eval(response);
          }else{
            var innerEl = document.getElementById(sid);
            if(typeof(innerEl)=='object'){
              innerEl.innerHTML = response;
              innerEl.style.display='';
            }
          }
        }else{}
      }
    }
    xmlhttp.open("GET",strUrl.replace("&&","&"),true);
    //xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    xmlhttp.send("");
  }catch(e){}
  delete xmlhttp;
}

function LoadContent(strUrl,e,sid) {
  if (!e) return false;
  var xmlhttp = HttpAXObj();
  try{
    xmlhttp.onreadystatechange=function(){
      if(xmlhttp.readyState==4){
        if(xmlhttp.status==200){
          var response = xmlhttp.responseText;
          if (!sid){
            sid='mainContent';
          }
          var innerEl = document.getElementById(sid);
          if(typeof(innerEl)=='object'){
            innerEl.innerHTML = response;
            innerEl.style.display='';
          }
        }
      }
    }
    xmlhttp.open("GET",strUrl.replace("&&","&"),true);
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    xmlhttp.send("");
  }catch(e){}
  delete xmlhttp;
}





//--文章内容字体控制
function fzoom(obj,size){ $id(obj).style.fontSize=size+'px' }
function hsgood_fontsize(type,objname){
  var initial_fontsize   = 10;
  var initial_lineheight = 18;
  var whichEl = document.getElementById(objname);
  if (whichEl!=null) {
    if (type==1){
      if(initial_fontsize<64){
        whichEl.style.fontSize=(++initial_fontsize)+'pt';
        whichEl.style.lineHeight=(++initial_lineheight)+'pt';
      }
    }else {
      if(initial_fontsize>8){
        whichEl.style.fontSize=(--initial_fontsize)+'pt';
        whichEl.style.lineHeight=(--initial_lineheight)+'pt';
      }
    }
  }
}

//图片自动调整的模式，1为按比例调整 ，2 按大小调整。
function imgzoom(img, maxsize){
  var a = new Image();
  a.src = img.src
  if(a.width > maxsize * 4){
    img.style.width = maxsize;
  }
  else if(a.width >= maxsize){
    img.style.width = Math.round(a.width * Math.floor(4 * maxsize / a.width) / 4);
  }
  return false;
}

var resizemode = 1
function imgresize(o){
  if (resizemode == 2 || o.onmousewheel){
    if(o.width > 500 ){
      o.style.width = '500px';
    }
    if(o.height > 800){
      o.style.Height = '800px';
    }
  }
  else{
    var parentNode = o.parentNode.parentNode
    if (parentNode){
      if (o.offsetWidth >= parentNode.offsetWidth) o.style.width='98%';
    }
    else{
      var parentNode = o.parentNode
      if (parentNode){
        if (o.offsetWidth >= parentNode.offsetWidth) o.style.width='98%';
      }
    }
  }
}
