﻿    function $(id)
{
  return document.getElementById(id);
}

/// <summary>
/// Creates a XmlHttpRequest object.
/// </summary>

function GetHttpObject() 
{
    
      if (typeof XMLHttpRequest != 'undefined')
          return new XMLHttpRequest();
      
      try 
      {
          return new ActiveXObject("Msxml2.XMLHTTP");
      } 
      catch (e) 
      {
          try 
          {
              return new ActiveXObject("Microsoft.XMLHTTP");
          } 
          catch (e) {}
      }
}

// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
    	window.onload = func;
	} 
	else 
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}
function getCookieValue(name)
{
      var   aCookie = document.cookie.split("; "); 
      for(var  i=0;i<aCookie.length;i++)   
      {      
          var aCrumb = aCookie[i].split("="); 
          if(name==aCrumb[0])     
             return unescape(aCrumb[1]);   
      }  
      return null;
}

function addCookie(name,objValue,expireDays)
{
      var str =  name+"=" + objValue
      if(expireDays!=0)
      {
          var date = new Date();
          var ms = (expireDays*24)*3600*1000;
          date.setTime(date.getTime() + ms);
          str += "; expires=" + date.toGMTString();     
      }
      document.cookie = str;   
}
function loginOut()
{
    if(confirm("确定退出系统吗?"))
    {
        window.parent.location.href="LoginOut.aspx";
    }    
     else
     return false;
}
function CommonInit(e)
{
      var key = window.event ? e.keyCode : e.which;
      if(key==27)
      {
          loginOut();
          return false;
      }
}
function setDisable(ids)
{
    var arr=ids.split(',');
    for(var i=0;i<arr.length;i++)
    {
        $(arr[i]).disabled='disabled';
    }
}
function alertInfo(tipInfo)
{
//scrollHeight:对象内容的高度
//clientHeight:对象可视部分的高度
//offsetHeight :是clientHeight加上滚动条的高度

    var width = document.body.clientWidth + document.body.scrollLeft;
    var height = document.documentElement.offsetHeight;
    document.body.style.position = 'static';

    var layer = document.createElement('div');
    layer.style.zIndex = 2;
    layer.id = 'layer';
    layer.style.position = 'absolute';
    layer.style.top = '0px';
    layer.style.left = '0px';
    layer.style.height = height + 'px';
    layer.style.width = width + 'px';
    layer.style.backgroundColor = '#b4b4b4';
    layer.style.opacity = '.4';
    layer.style.filter += ("progid:DXImageTransform.Microsoft.Alpha(opacity=40)");
    document.body.appendChild(layer);

    //tip
    var div = document.createElement('div');
    div.style.zIndex = 3;
    div.id = 'tip';
    div.style.position = (navigator.userAgent.indexOf('MSIE 6') > -1) ? 'absolute' : 'fixed';
    div.style.top = '200px';
    div.style.left = (width / 2) - (400 / 2) + 'px';
    document.body.appendChild(div);

    //tipHeader
    var tipHeader = document.createElement("div")
    tipHeader.id = "tipHeader";
    var h4 = document.createElement("h4");
    h4.innerHTML = "系统提示";

    var img = document.createElement("img");
    img.setAttribute("src", "../../../Images/windowClose.gif");
    img.setAttribute("alt", "关闭");
    img.onclick = function() { document.body.removeChild($('layer')); document.body.removeChild($('tip')); document.body.style.position = ''; }
    tipHeader.appendChild(h4);
    tipHeader.appendChild(img);
    div.appendChild(tipHeader);

    //tipContent
    var tipContent = document.createElement("div")
    tipContent.id = "tipContent";
    var p = document.createElement("p");
    p.innerHTML = tipInfo;
    var img = document.createElement("img");
    img.setAttribute("src", "../../../Images/Warning.gif");
    img.style.paddingLeft="5px";

    tipContent.appendChild(img);
    tipContent.appendChild(p);
    div.appendChild(tipContent);

    //btnClose
    var btnClose = document.createElement("div")
    btnClose.id = "btnClose";
    var img = document.createElement("img");
    img.setAttribute("src", "../../../Images/tipClose.gif");
    img.setAttribute("alt", "关闭");
    img.onclick = function() { document.body.removeChild($('layer')); document.body.removeChild($('tip')); document.body.style.position = ''; }
    btnClose.appendChild(img);
    div.appendChild(btnClose);
  

  
}

function AlternateRow()
{
        if(!document.getElementById("list"))
            return false;
        var a = document.getElementById("list").getElementsByTagName("tr");
        if(a != null)
        {
            for (var i=0; i<a.length; i++) 
            { 
              a[i].style.background=(i%2==1) ? "#FFFFFF" : "#f5f5f5"; //判断奇偶行。。并赋不同的值
              if(i%2==1)
              {
                 a[i].onmouseover=function(){this.style.backgroundColor='#FEFEE9';}
                 a[i].onmouseout=function(){this.style.backgroundColor='#FFFFFF';}
              }
              else
              {
                 a[i].onmouseover=function(){this.style.backgroundColor='#FEFEE9';}
                 a[i].onmouseout=function(){this.style.backgroundColor='#f5f5f5';}
              }
            }
      }
}
function AlternateInput()
 {
      var inputs =document.getElementsByTagName("input");
      for (var i = 0; i < inputs.length; i++)
      {
          if (inputs[i].type == "text" &&inputs[i].id!=null)
	      {
	           if(inputs[i].readOnly ==true)
              {
                  inputs[i].style.backgroundColor="#EEECE7";
                  inputs[i].style.border="1px solid #ccc";
                  //inputs[i].style.height="20px"
                  inputs[i].onblur = function() { this.style.background = "#EEECE7"; this.style.border = "1px solid #7f9db9"; };
                  inputs[i].onfocus = function() { this.style.background = "#EEECE7"; this.style.border = "1px solid #97b8d4"; };
              }
              else
              {
                  inputs[i].style.backgroundColor="#fff";
                  inputs[i].style.border="1px solid #ccc";
                  //inputs[i].style.height="20px";
                  inputs[i].onblur = function() { this.style.background = "#fff"; this.style.border = "1px solid #CCC"; };
	              inputs[i].onfocus = function() { this.style.background = "#ffd"; this.style.border = "1px solid #97b8d4"; };
	           }
	      }
      }
 }
function clearText(id,text)
{
    $(id).value=text;
}
//
function openDialog(url,width,height) 
{
    var width=width==null?650:width;
    var height=height==null?480:height;
    
    var nLeft=(window.screen.availWidth-width)/2;
    var nTop=(window.screen.availHeight-height)/2;
    
    window.open(url, "NewWindow", "left="+nLeft+",top="+nTop+",width="+width+",height="+height+",toolbar=no,scrollbars=yes,menubar=no,resizable=yes")
    
}
function openModalDialog(url,dialogWidth,dialogHeight)
{
    var dialogWidth=dialogWidth==null?"700px":dialogWidth;
    var dialogHeight=dialogHeight==null?"480px":dialogHeight;

    var nLeft=(window.screen.availWidth-parseInt(dialogWidth))/2;
    var nTop=(window.screen.availHeight-parseInt(dialogHeight))/2;
    
    return  window.showModalDialog(url,"","dialogWidth="+dialogWidth+",dialogHeight="+dialogHeight+",toolbar=no,scrollbars=yes,menubar=no,resizable=yes")
}
function goHref(url)
{
    window.location.href = url;
    return false;
}
function dispaly() 
{
    if($("tbl"))
    {
        $("tbl").style.display="block";
    }
}
function disN() 
{
    if($("tbl"))
    {
        $("tbl").style.display="none";
    }
}
function setHomePage() 
{
    if (document.all) 
    {
        $("HomePage").style.behavior = 'url(#default#homepage)'; $("HomePage").setHomePage('http://www.szjakj.com');
    }
    else 
    { 
        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage', 'http://www.szjakj.com');
    }
}
function addFavor() 
{
    try
    {
        window.external.AddFavorite('http://www.szjakj.com', '甲安科技');
    }
    catch (e)
    {
            try
            {
                window.sidebar.addPanel('甲安科技', 'http://www.szjakj.com', "");
            }
           catch (e)
            {
                alert("加入收藏失败，有劳您手动添加。");
            }
    }
}
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6. 
{ 
    var arVersion = navigator.appVersion.split("MSIE") 
    var version = parseFloat(arVersion[1]) 
    if ((version >= 5.5) && (document.body.filters)) 
    { 
       for(var j=0; j<document.images.length; j++) 
       { 
          var img = document.images[j] 
          var imgName = img.src.toUpperCase() 
          if (imgName.substring(imgName.length-3, imgName.length) == "PNG") 
          { 
             var imgID = (img.id) ? "id='" + img.id + "' " : "" 
             var imgClass = (img.className) ? "class='" + img.className + "' " : "" 
             var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' " 
             var imgStyle = "display:inline-block;" + img.style.cssText 
             if (img.align == "left") imgStyle = "float:left;" + imgStyle 
             if (img.align == "right") imgStyle = "float:right;" + imgStyle 
             if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle 
             var strNewHTML = "<span " + imgID + imgClass + imgTitle 
             + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" 
             + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" 
             + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
             img.outerHTML = strNewHTML 
             j = j-1 
          } 
       } 
    }     
} 

function setNav(name,url)
{

    $("navHref").innerHTML=name;

    $("nav").innerHTML=name;

}
function setHidden()
{
    window.setTimeout(function(){$("searchTip").style.display="none";},500);
}
function setDisplay(){
$("searchTip").style.display="block";
}
function showLocale(objD)
{
	var str,colorhead,colorfoot;
	var yy = objD.getYear();
	if(yy<1900) yy = yy+1900;
	var MM = objD.getMonth()+1;
	if(MM<10) MM = '0' + MM;
	var dd = objD.getDate();
	if(dd<10) dd = '0' + dd;
	var hh = objD.getHours();
	if(hh<10) hh = '0' + hh;
	var mm = objD.getMinutes();
	if(mm<10) mm = '0' + mm;
	var ss = objD.getSeconds();
	if(ss<10) ss = '0' + ss;
	var ww = objD.getDay();
	if  ( ww==0 )  colorhead="<font color=\"#FF0000\">";
	if  ( ww > 0 && ww < 6 )  colorhead="<font color=\"#373737\">";
	if  ( ww==6 )  colorhead="<font color=\"#008000\">";
	if  (ww==0)  ww="星期日";
	if  (ww==1)  ww="星期一";
	if  (ww==2)  ww="星期二";
	if  (ww==3)  ww="星期三";
	if  (ww==4)  ww="星期四";
	if  (ww==5)  ww="星期五";
	if  (ww==6)  ww="星期六";
	colorfoot="</font>"
	str = colorhead + yy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss + "  " + ww + colorfoot;
	return(str);
}
function tick()
{
	var today;
	today = new Date();
	document.getElementById("localtime").innerHTML = showLocale(today);
	window.setTimeout("tick()", 1000);
}
