﻿function IEHover() //IE下拉专用
 {
    var sfEls = document.getElementById("MainMenu").getElementsByTagName("li");
    for (var i=0; i<sfEls.length; i++) 
        {
          sfEls[i].onmouseover=function() {
            this.className+=" hover";
        }
        sfEls[i].onmouseout=function() {
           this.className=this.className.replace(new RegExp("( ?|^)hover\\b"),"");
        }
      }
 }

function FontZoom(Size,LineHeight,Id)
 {
   var Obj=document.getElementById(Id);
   Obj.style.fontSize=Size; 
   Obj.style.lineHeight=LineHeight; 
 }

function  ShowImage(Url)
 {
   window.open("/include/showimage.aspx?src="+Url, "newwindow", "top=50,left=50,height=550, width=850, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no") 
 }


//评论输入验证
function Check_Comments(Language)
  {  
   var C_value=Trim(document.getElementById("c_content").value);
   if(C_value=="")
    {
      if(Language=="en")
       {
        alert("Please enter a comment!");
       }
      else
       {
        alert("请输入评论内容!");
       }
      document.getElementById("c_content").focus();
      return false;
    }
   C_value=Trim(document.getElementById("c_yzm").value);
   if(C_value=="")
    {
     if(Language=="en")
       {
        alert("Please enter the verification code!");
       }
      else
       {
        alert("请输入验证码!");
       }
      document.getElementById("c_yzm").focus();
      return false;
    }

  }

//自定义表单必填项验证
 function Check_ZdyForm(formName,language,ismember)
  { 
   var sjs1,sjs2,Js1,Js2;
   if(language=="cn")
    {
      sjs1="请选择类别!";
      sjs2="请选择子类别!";
      Js1="不能为空!",
     Js2="请输入验证码!";
    }
   else
    {
      sjs1 = "Please select the category!";
      sjs2 = "Please select sub-category!";
      Js1 = " can not be empty!"
      Js2 = "Please enter the verification code!";
    }

   var obj1=document.getElementById("Sort_1");
   var obj2=document.getElementById("Sort_2");
   var obj3=document.getElementById("TBtime");
   if(obj1!=null)
    {
    if(obj1.style.display!="none")
    {
     if(obj1.value=="0")
     {
      alert(sjs1);
      obj1.focus();
      return false;
     }
   }
   if(obj2.style.display!="none")
    {
       if(obj2.value=="0")
        {
         alert(sjs2);
         obj2.focus();
         return false;
       }
    }
   }


   var Names=document.forms[formName].mustname.value;
   var Fields=document.forms[formName].mustfield.value;
   var Fieldtype=document.forms[formName].musttype.value;
   var ANames,AFields,AFieldtype,Obj;
    if(Fields!="")
     {
       ANames=Names.split(',');
       AFields=Fields.split(',');
       AFieldtype=Fieldtype.split(',');
       for(i=0;i<AFields.length-1;i++)
        {
          Obj=document.forms[formName][AFields[i]];
          if(AFieldtype[i]=="radio" || AFieldtype[i]=="checkbox")
             {
                   if(!IsChecked(Obj))
                    {
                      alert(ANames[i]+Js1);
                      return false;
                    }
             }
           else
              {
                   if(Obj.value=="" && Obj.style.display!="none")
                    {
                     alert(ANames[i]+Js1);
                     Obj.focus();
                     return false;
                   }
             }
        }
     }
    if(ismember==0)
     {
      document.forms[formName].zdyform_url.value=top.location.href;
      Obj=document.forms[formName].hscode;
      if(Obj.value=="1")
       {
         if(Trim(document.forms[formName].vcode.value)=="")
          {
            alert(Js2); 
            document.forms[formName].vcode.focus();
            return false;
          }
       }
     }

 if(obj3!=null)
  {
   if(!IsDate(obj3.value))
   {
    alert("请输入正确的发布时间!");
    obj3.focus();
    return false;
   }
  }

  }

//改变验证码
function Code_Change(Id)
 {
  Obj=document.getElementById(Id);
  if(Obj.src.indexOf("yzm.aspx")>=0)
   {
    Obj.src="/incs/yzm1.aspx";
   }
  else
   {
    Obj.src="/incs/yzm.aspx"
   }
 }

//控制pagea_control
function Go_Page(PageCount,CurrentPage)
 {
  var P1=document.getElementById("P_First");
  var P2=document.getElementById("P_Prev");
  var P3=document.getElementById("P_Next");
  var P4=document.getElementById("P_Last");
   if(CurrentPage>=PageCount)
    {
      P3.disabled="disabled";
      P3.href="#";
      P4.disabled="disabled";
      P4.href="#";
    }

    if(CurrentPage<=1)
    {
      P1.disabled="disabled";
      P1.href="#";
      P2.disabled="disabled";
      P2.href="#";
    }
   document.getElementById("P_Page").selectedIndex=CurrentPage-1;
 }


function open_calendar(Id)
 {
  var Val=window.showModalDialog("/incs/pgcalendar.html","calendar","dialogWidth:15.5em;dialogHeight:15.5em;help:no;resizable:no;status:no");
  if(Val!=null)
   {
    document.getElementById(Id).value=Val;
   }
    document.getElementById(Id).blur();
 }


//基础函数

function Trim(str)  //去除空格 
 { 
  var Astr=str.split('');
  var str1="";
  for(i=0;i<Astr.length;i++)
   {
    str1+=Astr[i].replace(" ","");
   }
  return str1;
 }


function ShowItem(id,url)
 {
    var obj=document.getElementById(id);
    if(url!="#" || obj==null)
     {
       return;
     }
    if(obj.style.display=="none")
     {
      obj.style.display="";
     }
   else
     {
      obj.style.display="none";
     }
 }

function IsChecked(obj)  //检测radid或checkbox是否有选择
{
 var k=0;
 for(k=0;k<obj.length;k++) 
  { 
   if(obj[k].checked) 
    {
     return true;
    }
  }
 return false;
} 



function IsNum(str)  //是否是数字
 {
   var str1="0123456789";
   var Astr=str.split('');
   for(i=0;i<Astr.length;i++)
    {
      if(str1.indexOf(Astr[i])<0)
       {
        return false;
       }
    }
  return true;

 }

function IsDate(str)   
 {  
 
  var reg1=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/; 
  var reg2=/^(\d{1,2})\/(\d{1,2})\/(\d{4}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/; 
  var reg3=/^(\d{1,2})\/(\d{1,2})\/(\d{4}) (\d{1,2}):(\d{1,2}):(\d{1,2}) ([a-zA-Z]{0,2})$/; 
  var reg4=/^(\d{4})-(\d{1,2})-(\d{1,2})$/;    
  var reg5=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/;   
  if(str=="")
   {
     return  false;  
   } 
  if(!reg1.test(str) && !reg2.test(str) && !reg3.test(str) && !reg4.test(str) && !reg5.test(str))
   {    
      return  false;   
   }   
   return true;   
  }   



function replaceAll(str,str1,str2)
{
  str=str.toLowerCase();
  while(str.indexOf(str1)>= 0)
  {
   str=str.replace(str1,str2);
  }
  return str;
}


//首页新闻滚动

function srcMarquee(){
this.ID = document.getElementById(arguments[0]);
if(!this.ID){this.ID = -1;return;}
this.Direction = this.Width = this.Height = this.DelayTime = this.WaitTime = this.Correct = this.CTL = this.StartID = this.Stop = this.MouseOver = 0;
this.Step = 1;
this.Timer = 30;
this.DirectionArray = {"top":0 , "bottom":1 , "left":2 , "right":3};
if(typeof arguments[1] == "number")this.Direction = arguments[1];
if(typeof arguments[2] == "number")this.Step = arguments[2];
if(typeof arguments[3] == "number")this.Width = arguments[3];
if(typeof arguments[4] == "number")this.Height = arguments[4];
if(typeof arguments[5] == "number")this.Timer = arguments[5];
if(typeof arguments[6] == "number")this.DelayTime = arguments[6];
if(typeof arguments[7] == "number")this.WaitTime = arguments[7];
if(typeof arguments[8] == "number")this.ScrollStep = arguments[8]
this.ID.style.overflow = this.ID.style.overflowX = this.ID.style.overflowY = "hidden";
this.ID.noWrap = true;
this.IsNotOpera = (navigator.userAgent.toLowerCase().indexOf("opera") == -1);
if(arguments.length >= 7)this.Start();
}
srcMarquee.prototype.Start = function(){
if(this.ID == -1)return;
if(this.WaitTime < 800)this.WaitTime = 800;
if(this.Timer < 20)this.Timer = 20;
if(this.Width == 0)this.Width = parseInt(this.ID.style.width);
if(this.Height == 0)this.Height = parseInt(this.ID.style.height);
if(typeof this.Direction == "string")this.Direction = this.DirectionArray[this.Direction.toString().toLowerCase()];
this.HalfWidth = Math.round(this.Width / 2);
this.BakStep = this.Step;
this.ID.style.width = this.Width;
this.ID.style.height = this.Height;
if(typeof this.ScrollStep != "number")this.ScrollStep = this.Direction > 1 ? this.Width : this.Height;
var msobj = this;
var timer = this.Timer;
var delaytime = this.DelayTime;
var waittime = this.WaitTime;
msobj.StartID = function(){msobj.Scroll()}
msobj.Continue = function(){
if(msobj.MouseOver == 1){
setTimeout(msobj.Continue,delaytime);
     }
     else{ clearInterval(msobj.TimerID);
msobj.CTL = msobj.Stop = 0;
msobj.TimerID = setInterval(msobj.StartID,timer);
     }
    }
msobj.Pause = function(){
msobj.Stop = 1;
clearInterval(msobj.TimerID);
setTimeout(msobj.Continue,delaytime);
    }
msobj.Begin = function(){
   msobj.ClientScroll = msobj.Direction > 1 ? msobj.ID.scrollWidth : msobj.ID.scrollHeight;
   if((msobj.Direction <= 1 && msobj.ClientScroll <msobj.Height) || (msobj.Direction > 1 && msobj.ClientScroll <msobj.Width))return;
   msobj.ID.innerHTML += msobj.ID.innerHTML;
   msobj.TimerID = setInterval(msobj.StartID,timer);
   if(msobj.ScrollStep < 0)return;
   msobj.ID.onmousemove = function(event){
       if(msobj.ScrollStep == 0 && msobj.Direction > 1){
var event = event || window.event;
if(window.event){
if(msobj.IsNotOpera){msobj.EventLeft = event.srcElement.id == msobj.ID.id ? event.offsetX - msobj.ID.scrollLeft : event.srcElement.offsetLeft - msobj.ID.scrollLeft + event.offsetX;}
else{msobj.ScrollStep = null;return;}
}
else{msobj.EventLeft = event.layerX - msobj.ID.scrollLeft;}
msobj.Direction = msobj.EventLeft > msobj.HalfWidth ? 3 : 2;
msobj.AbsCenter = Math.abs(msobj.HalfWidth - msobj.EventLeft);
msobj.Step = Math.round(msobj.AbsCenter * (msobj.BakStep*2) / msobj.HalfWidth);
}
}
msobj.ID.onmouseover = function(){
if(msobj.ScrollStep == 0)return;
msobj.MouseOver = 1;
clearInterval(msobj.TimerID);
}
msobj.ID.onmouseout = function(){
if(msobj.ScrollStep == 0){
if(msobj.Step == 0)msobj.Step = 1;
return;
}
msobj.MouseOver = 0;
if(msobj.Stop == 0){
clearInterval(msobj.TimerID);
msobj.TimerID = setInterval(msobj.StartID,timer);
}}}
setTimeout(msobj.Begin,waittime);
}
srcMarquee.prototype.Scroll = function(){
switch(this.Direction){
case 0:
this.CTL += this.Step;
if(this.CTL >= this.ScrollStep && this.DelayTime > 0){
this.ID.scrollTop += this.ScrollStep + this.Step - this.CTL;
this.Pause();
return;
}
else{
if(this.ID.scrollTop >= this.ClientScroll){this.ID.scrollTop -= this.ClientScroll;}
this.ID.scrollTop += this.Step;
}
break;
case 1:
this.CTL += this.Step;
if(this.CTL >= this.ScrollStep && this.DelayTime > 0){
this.ID.scrollTop -= this.ScrollStep + this.Step - this.CTL;
this.Pause();
return;
}
else{
if(this.ID.scrollTop <= 0){this.ID.scrollTop += this.ClientScroll;}
this.ID.scrollTop -= this.Step;
}
break;
case 2:
this.CTL += this.Step;
if(this.CTL >= this.ScrollStep && this.DelayTime > 0){
this.ID.scrollLeft += this.ScrollStep + this.Step - this.CTL;
this.Pause();
return;
}
else{
if(this.ID.scrollLeft >= this.ClientScroll){this.ID.scrollLeft -= this.ClientScroll;}
this.ID.scrollLeft += this.Step;
}
break;
case 3:
this.CTL += this.Step;
if(this.CTL >= this.ScrollStep && this.DelayTime > 0){
this.ID.scrollLeft -= this.ScrollStep + this.Step - this.CTL;
this.Pause();
return;
}
else{
if(this.ID.scrollLeft <= 0){this.ID.scrollLeft += this.ClientScroll;}
this.ID.scrollLeft -= this.Step;
}
break;
}
} 




