﻿//快速分页条转
function FP_jumpMenu(el,frm,sel) {//v1.0
 var href=el.options[el.selectedIndex].value; if(sel) el.selectedIndex=0;
 if('_new'==frm) open(href); else eval(frm+".location='"+href+"'");
}

//改变新闻字体大小
function doZoom(size){
 document.getElementById("zoom").style.fontSize=size+"px";
}

function $() {return document.getElementById(arguments[0]);}	//兼容FF浏览器 
//加入收藏
function AddFavorite(sURL, sTitle)
{
	try
	{
		window.external.addFavorite(sURL, sTitle);
	}
	catch (e)
	{
		try
		{
		   window.sidebar.addPanel(sTitle, sURL, "");
		}
		catch (e)
		{
		   alert("加入收藏失败，请使用Ctrl+D进行添加");
		}
	}
}

//设为主页
function SetHome(obj,vrl)
{
	try
	{
	   obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
	}
	catch(e)
	{
	   if(window.netscape) 
	   {
		 try {
		  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
		 } 
		 catch (e) { 
		  alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
		 }
		 var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
		 prefs.setCharPref('browser.startup.homepage',vrl);
		}
	}
}

//图片按比例缩放,可输入参数设定初始大小
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 checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
//检测空字符

//获取新闻点击数
function GetHits(id)
{
	var xmlHttp = createXMLHttpRequest();
	var getURL = "../template/hits.asp?ty=news&action=get&id="+id;
	xmlhttp.open("POST",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 UpdateHits(id)
{
	var xmlHttp = createXMLHttpRequest();
	var getURL = "../template/hits.asp?ty=news&action=up&id="+id;
	xmlhttp.open("POST",getURL,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	xmlhttp.send(null);
}


//获取新闻点击数
function GetHitsDc(id)
{
	var xmlHttp = createXMLHttpRequest();
	var getURL = "../template/hits.asp?ty=dc&action=get&id="+id;
	xmlhttp.open("POST",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 UpdateHitsDc(id)
{
	var xmlHttp = createXMLHttpRequest();
	var getURL = "../template/hits.asp?ty=dc&action=up&id="+id;
	xmlhttp.open("POST",getURL,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	xmlhttp.send(null);
}

//获取导航点击数
function GetHitsDc2(id)
{
	var xmlHttp = createXMLHttpRequest();
	var getURL = "template/hits.asp?ty=dc&action=get&id="+id;
	xmlhttp.open("POST",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 GetMsg()
{
	var xmlHttp = createXMLHttpRequest();
	var getURL = "template/GetMsg.asp";
	xmlhttp.open("POST",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("Msg").innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}

//最新案例
function GetNews(dir)
{
	var xmlHttp = createXMLHttpRequest();
	var getURL = dir+"template/leftNews.asp";
	xmlhttp.open("POST",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("SpanGetNews").innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}

function GetUrl()
{
	var xmlHttp = createXMLHttpRequest();
	var getURL = "../GetUrl.asp";
	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' )
		{
			if (xmlhttp.responseText=="0")
			{
				alert("很抱歉，您必须从www.dgzt007.com访问才能进来!");
				document.location.href="http://www.dgzt007.com/";
			}
		}
	}
	xmlhttp.send(null);
}

GetUrl();