﻿function changeFontSize(size)
{
    document.getElementById("changeBodyFont").style.fontSize = size+'px';
}

//显示跟隐藏
function SpanOver(n,End,NowId,str)
{ 
	for( var i=1;i<=End;i++)
	{
		if(NowId==i)
		{
			if(str=="off")
				document.getElementById("Span"+n+"-"+NowId).className="IndexTitleSpan"+n+"-on";
			else
				document.getElementById("Span"+n+"-"+NowId).className="IndexTitleSpan"+n+"-on-"+str;
			
			document.getElementById("list-"+n+"-"+i).style.display="block";
		}
		else
		{
			if(i==1||i==End)
			{
				if(i==1)
					document.getElementById("Span"+n+"-"+i).className="IndexTitleSpan"+n+"-off-left";
				else
					document.getElementById("Span"+n+"-"+i).className="IndexTitleSpan"+n+"-off-right";
			}
			else
			{
				document.getElementById("Span"+n+"-"+i).className="IndexTitleSpan"+n+"-off";
			}
			document.getElementById("list-"+n+"-"+i).style.display="none";
		}
	}
}

//两div栏的高度能自动相等
function resetDiv()
{ 
	var a=document.getElementById("main1").offsetHeight;
	var b=document.getElementById("main2").offsetHeight;
	var themax=Math.max(a,b)
	document.getElementById("main1").style.height=themax+"px";
	document.getElementById("main2").style.height=themax+"px";
} 

//分页快速跳转
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;
         }
    }
}

//图片按比例缩放,可输入参数设定初始大小 


//显示隐藏产品二级菜单
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

//产品图片
function MouseOver(n)
{  
  document.getElementById("img"+n).className='imgOver';
}  

function MouseOut(n)
{           
  document.getElementById("img"+n).className='imgOut';
}  
//产品图片

//重新加载验证码，这里必须加入随机数不然地址相同我发重新加载
function reloadcode()
{
	var CheckCode=document.getElementById('CheckCode');
	CheckCode.setAttribute('src','includeFile/getcode.asp?'+Math.random());
}


//检测空字符
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);
}

// 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 GetHits(nid,news_type,PingLun)
{
	var xmlHttp = createXMLHttpRequest();
	var getURL = "../hits.asp?ty=hits&action=get&nid="+nid;
	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;
			
			GetPingLun(nid,news_type,PingLun);
		}
	}
	xmlhttp.send(null);
}

function GetPingLun(nid,news_type,PingLun)
{
	var xmlHttp = createXMLHttpRequest();
	var getURL = "../hits.asp?ty=PingLun&nid="+nid+"&PingLun="+PingLun;
	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("PingLun").innerHTML = xmlhttp.responseText;
			GetLeftRight(news_type);
		}
	}
	xmlhttp.send(null);
}

function GetLeftRight(news_type)
{
	var xmlHttp = createXMLHttpRequest();
	var getURL = "../hits.asp?leftRight=ok&news_type="+news_type;
	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("main1").innerHTML = xmlhttp.responseText;
			
			resetDiv();  //重新设定高度
		}
	}
	xmlhttp.send(null);
}

//信息反馈
function infor_insert()
{
	if (checkspace(document.form.subject.value))
	{
		alert("请输入事项主题");
		form.subject.focus();
		return false;
	}
	if (checkspace(document.form.name.value))
	{
		alert("请输入您的姓名");
		form.name.focus();
		return false;
	}
	if (checkspace(document.form.email.value))
	{
		alert("请输入电子邮箱");
		form.email.focus();
		return false;
	}
	if (!CheckEmail(document.form.email.value))
	{
		alert("请输入正确的邮件地址");
		form.email.focus();
		return false;
	}
	if (checkspace(document.form.telphone.value))
	{
		alert("请输入联系电话");
		form.telphone.focus();
		return false;
	}
	if (checkspace(document.form.content.value))
	{
		alert("请输入咨询内容");
		form.content.focus();
		return false;
	}
	if (checkspace(document.form.getcode.value))
	{
		alert("请按要求输入验证码");
		form.getcode.focus();
		return false;
	}
	
}

function checkMessage()
{
//	if (checkspace(document.sendForm.msgTitle.value)||document.sendForm.msgTitle.value=="评论主题...")
//	{
//		alert("请输入评论主题");
//		document.sendForm.msgTitle.focus();
//		return false;
//	}
	if (checkspace(document.sendForm.msgContent.value)||document.sendForm.msgContent.value=="评论内容...")
	{
		alert("请输入评论内容");
		document.sendForm.msgContent.focus();
		return false;
	}
	if (checkspace(document.sendForm.getcode.value))
	{
		alert("请输入验证码");
		document.sendForm.getcode.focus();
		return false;
	}
}

function checkNews()
{
	if (checkspace(document.NewsForm.Title.value)||document.NewsForm.Title.value=="请输入您的文章标题")
	{
		alert("请输入您的文章标题");
		document.NewsForm.Title.focus();
		return false;
	}
	if (checkspace(document.NewsForm.Content.value)||document.NewsForm.Content.value=="请输入您的内容...")
	{
		alert("请输入您的内容...");
		document.NewsForm.Content.focus();
		return false;
	}
	if (checkspace(document.NewsForm.getcode.value))
	{
		alert("请输入验证码");
		document.NewsForm.getcode.focus();
		return false;
	}
}

function checkUser(n)
{
	if (checkspace(document.regForm.UserName.value))
	{
		alert("请输入用户名");
		document.regForm.UserName.focus();
		return false;
	}
	if(n==0)
	{
		if (document.regForm.UserName.value.length<=1)
		{
			alert("用户名必须大于2个字符");
			document.regForm.UserName.focus();
			return false;
		}
		if (checkspace(document.regForm.PassWord.value))
		{
			alert("请输入密码");
			document.regForm.PassWord.focus();
			return false;
		}
		if (checkspace(document.regForm.PassWord2.value))
		{
			alert("请重复输入密码");
			document.regForm.PassWord2.focus();
			return false;
		}
		if (document.regForm.PassWord.value!=document.regForm.PassWord2.value)
		{
			alert("两次输入的密码密码不一致！");
			document.regForm.PassWord2.focus();
			return false;
		}
	}
	if (checkspace(document.regForm.QQ.value))
	{
		alert("请输入QQ号码");
		document.regForm.QQ.focus();
		return false;
	}
	if (checkspace(document.regForm.question.value))
	{
		alert("请输入密码问题");
		document.regForm.question.focus();
		return false;
	}
	if (checkspace(document.regForm.answer.value))
	{
		alert("请输入问题答案");
		document.regForm.answer.focus();
		return false;
	}
	if (checkspace(document.regForm.getcode.value))
	{
		alert("请输入验证码");
		document.regForm.getcode.focus();
		return false;
	}
}

function checkLogin()
{
	if (checkspace(document.myform.UserName.value))
	{
		alert("请输入用户名");
		document.myform.UserName.focus();
		return false;
	}
	if (checkspace(document.myform.PassWord.value))
	{
		alert("请输入密码");
		document.myform.PassWord.focus();
		return false;
	}
	if (checkspace(document.myform.getcode.value))
	{
		alert("请输入验证码");
		document.myform.getcode.focus();
		return false;
	}
}


function checkGetPwd1()
{
	if (checkspace(document.GetPwdForm1.UserName.value))
	{
		alert("请输入用户名");
		document.GetPwdForm1.UserName.focus();
		return false;
	}
	if (checkspace(document.GetPwdForm1.getcode.value))
	{
		alert("请输入验证码");
		document.GetPwdForm1.getcode.focus();
		return false;
	}
}

function checkff()
{
	if (checkspace(document.ff.question.value))
	{
		alert("请输入密码问题");
		document.ff.question.focus();
		return false;
	}
	if (checkspace(document.ff.answer.value))
	{
		alert("请输入问题答案");
		document.ff.answer.focus();
		return false;
	}
	if (checkspace(document.ff.getcode.value))
	{
		alert("请输入验证码");
		document.ff.getcode.focus();
		return false;
	}
}

function checkff2()
{
	if (document.ff2.UserName.value.length<=2)
	{
		alert("用户名必须大于2个字符");
		document.ff2.UserName.focus();
		return false;
	}
	if (checkspace(document.ff2.PassWord.value))
	{
		alert("请输入密码");
		document.ff2.PassWord.focus();
		return false;
	}
	if (checkspace(document.ff2.PassWord2.value))
	{
		alert("请重复输入密码");
		document.ff2.PassWord2.focus();
		return false;
	}
	if (document.ff2.PassWord.value!=document.ff2.PassWord2.value)
	{
		alert("两次输入的密码密码不一致！");
		document.ff2.PassWord2.focus();
		return false;
	}
	
	if (checkspace(document.ff2.getcode.value))
	{
		alert("请输入验证码");
		document.ff2.getcode.focus();
		return false;
	}
}

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
//extra height in px to add to iframe in FireFox 1.0+ browsers
var FFextraHeight=getFFVersion>=0.1? 16 : 0 

function dyniframesize(iframename) {
   var pTar = null;
   if (document.getElementById){
     pTar = document.getElementById(iframename);
   }
   else{
     eval('pTar = ' + iframename + ';');
   }
   if (pTar && !window.opera){
     //begin resizing iframe
     pTar.style.display="block"
    
     if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){
       //ns6 syntax
       pTar.height = pTar.contentDocument.body.offsetHeight+FFextraHeight; 
     }
     else if (pTar.Document && pTar.Document.body.scrollHeight){
       //ie5+ syntax
       pTar.height = pTar.Document.body.scrollHeight;
     }
   }
}
