﻿//IE6下png背景透明解决方法
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 
          } 
       } 
    }     
} 
window.attachEvent("onload", correctPNG); 


//图片预先加载
function LoadImage(ImgD,id)
{ 
	var image=new Image(); 
	image.src=ImgD.src; 
	if(ImgD.readyState=="complete" || ImgD.complete == true)
	{
		document.getElementById("ImgLoadId-"+id).style.display="none";
		ImgD.style.display="block";
	}
}

//检测空字符
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
//检测空字符

function CheckEmail(email)
{
	var RegExpStr = /^([\w\_\-\.]{1,})(@)([\w\-\.]{1,})(\.)([a-zA-Z\.]{1,})$/;
	return RegExpStr.test(email);
}

//重新加载验证码，这里必须加入随机数不然地址相同我发重新加载
function reloadcode()
{
	var CheckCode=document.getElementById('CheckCode');
	CheckCode.setAttribute('src','../includeFile/getcode.asp?'+Math.random());
}

//图片按比例缩放,可输入参数设定初始大小
function resizeimg(ImgD,iwidth,iheight) {
     var image=new Image();
     image.src=ImgD.src;
     if(image.width>0 && image.height>0)
	 {
        if(image.width/image.height>= iwidth/iheight)
		{
           if(image.width>iwidth){
               ImgD.width=iwidth;
               ImgD.height=(image.height*iwidth)/image.width;
           }else{
                  ImgD.width=image.width;
                  ImgD.height=image.height;
                }
               //ImgD.alt="宽×高:"+image.width+"×"+image.height;
        }
        else
		{
                if(image.height>iheight){
                       ImgD.height=iheight;
                       ImgD.width=(image.width*iheight)/image.height;
                }else{
                        ImgD.width=image.width;
                        ImgD.height=image.height;
                     }
                //ImgD.alt="宽×高:"+image.width+"×"+image.height;
         }
    }
}

//图片按比例缩放,可输入参数设定初始大小 

// JavaScript Document
function createXMLHttpRequest()  //针对不同浏览器设置XMLHttpRequest方式
{ 
    xmlhttp = false; 
     
    if(window.XMLHttpRequest)
	{        //for Mozilla 
        xmlhttp = new XMLHttpRequest(); 
        if(xmlhttp.overrideMimeType)
		{ 
            xmlhttp.overrideMimeType("text/xml"); 
        } 
    } 
    else if(window.ActiveXObject)
	{   //for IE 
        try
		{ 
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
        }
		catch(e)
		{ 
            try
			{ 
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
            }
		catch(e)
		{} 
        } 
    } 
}

//获取新闻点击数
function GetNewsHits(id)
{
	var xmlHttp = createXMLHttpRequest();
	var getURL = "../template/hits.asp?ty=news&action=get&id="+id;
	xmlhttp.open("GET",getURL,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	xmlhttp.onreadystatechange=function() 
	{
		if ( xmlhttp.readyState==4 || xmlhttp.readyState=='complete' )
		{
			document.getElementById("hits").innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}

//更新新闻点击数
function UpdateNewsHits(dir,id)
{
	var xmlHttp = createXMLHttpRequest();
	var getURL = dir+"template/hits.asp?action=up&ty=news&id="+id;
	xmlhttp.open("GET",getURL,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	xmlhttp.send(null);
}


//获取案例点击数
function GetCaseHits(id)
{
	var xmlHttp = createXMLHttpRequest();
	var getURL = "../template/hits.asp?ty=case&action=get&id="+id;
	xmlhttp.open("GET",getURL,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	xmlhttp.onreadystatechange=function() 
	{
		if ( xmlhttp.readyState==4 || xmlhttp.readyState=='complete' )
		{
			document.getElementById("hits").innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}

//更新案例点击数
function UpdateCaseHits(dir,id)
{
	var xmlHttp = createXMLHttpRequest();
	var getURL = dir+"template/hits.asp?action=up&ty=case&id="+id;
	xmlhttp.open("GET",getURL,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	xmlhttp.send(null);
}

//获取软件点击数
function GetSoftHits(id)
{
	var xmlHttp = createXMLHttpRequest();
	var getURL = "../template/hits.asp?ty=soft&action=get&id="+id;
	xmlhttp.open("GET",getURL,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	xmlhttp.onreadystatechange=function() 
	{
		if ( xmlhttp.readyState==4 || xmlhttp.readyState=='complete' )
		{
			document.getElementById("hits").innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}

//更新软件点击数
function UpdateSoftHits(dir,id)
{
	var xmlHttp = createXMLHttpRequest();
	var getURL = dir+"template/hits.asp?action=up&ty=soft&id="+id;
	xmlhttp.open("GET",getURL,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	xmlhttp.send(null);
}
