﻿//快速分页条转
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 reloadcode()
{
	var CheckCode=document.getElementById('CheckCode');
	CheckCode.setAttribute('src','includeFile/getcode.asp?'+Math.random());
}

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 form1_onsubmit()
{
	if (checkspace(document.f.Title.value))
	{
		alert("留言主题为必须填写项");
		document.f.Title.focus();
		return false;
	}
	if (checkspace(document.f.UserName.value))
	{
		alert("您的称呼为必须填写项");
		document.f.UserName.focus();
		return false;
	}
	if (checkspace(document.f.Phone.value))
	{
		alert("联系电话为必须填写项");
		document.f.Phone.focus();
		return false;
	}
	if (checkspace(document.f.Content.value))
	{
		alert("留言内容为必须填写项");
		document.f.Content.focus();
		return false;
	}
	if (checkspace(document.f.getcode.value))
	{
		alert("验证码为必须填写项");
		document.f.getcode.focus();
		return false;
	}
}
