//高亮行
function mOver(obj){
    obj.style.backgroundColor='#f2f2f2';
}
function mOut(obj){
    obj.style.backgroundColor='#ffffff';
}
function doGuestbookSubmit(){
      if(form1.guest_name.value==""){return alert("姓名不能为空！");}
	  if(form1.guest_name.value.length>=200){return alert("姓名不能超过200字符！");}

      if(form1.guest_email.value==""){return alert("E-mail不能为空！");}
      if(!isEmail(form1.guest_email.value))return alert("E-Mail地址格式不正确！");
	  if(form1.guest_email.value.length>=200){return alert("邮箱不能超过200字符！");}

      if(form1.guest_subject.value==""){return alert("标题不能为空！");}
	  if(form1.guest_subject.value.length>=200){return alert("标题不能超过200字符！");}

      if(form1.guest_content.value==""){return alert("内容不能为空！");}
      if(form1.guest_content.value.length>=4096){return alert("内容不能超过4096字符！");}
      var obj=new JSPSoftCallBack();

      obj.callback=function(){
            postRequest(
            {action:"post_guestbook",subject:form1.guest_subject.value,guest_name:form1.guest_name.value,guest_email:form1.guest_email.value,guest_content:form1.guest_content.value,column_code:form1.column_code.value},//默认为顶
            function(responseData1){
				 if(responseData1=="OK") {alert("留言发送成功！"); top.location.reload();}
				 else alert("留言发送失败，请稍候重试！");
            }
            );
      }
     if(confirm("填写好了吗，真的要提交吗？"))obj.sendData();   
  }
  
function show(objli,index){
 if(objli.id=="current")return;
 var obj_ul=document.all("objul");
   for(var i=0;obj_ul&&obj_ul.children&&obj_ul.children.length&&i<obj_ul.children.length;i++){
     if(obj_ul.children[i].id){
         obj_ul.children[i].removeAttribute("id");
	   break;
	 }
   }
   if(objli.id!="current"){objli.setAttribute("id","current");}
   var kind=document.all("kind");
   for(var i=0;kind&&kind.length&&i<kind.length;i++){
     kind[i].style.display=(parseInt(kind[i].tab_index)==index?"":"none"); 
   }
}

function justClear(){
	form1.guest_name.value="";
	form1.guest_email.value="";
	form1.guest_subject.value="";
	form1.guest_content.value="";
}



function doApplyFormSubject(column_code){
	if(column_code==null||column_code=="")return alert("建设中....未指定归属栏目");
	if($("apply_username").value==""){
		alert("申请人不能为空！");
		return $("apply_username").focus();
	}
	if($("apply_project_name").value==""){
		alert("项目名称不能为空！");
		return $("apply_project_name").focus();
	}

	var obj=new JSPSoftCallBack();

      obj.callback=function(){
			var contentx=replaceEx(applyForm.innerHTML," class=\"apply_input\""," class=\"apply_input_disabled\" disabled readonly");
			contentx=replaceEx(contentx," class=apply_input"," class=\"apply_input_disabled\" disabled readonly");
			contentx=replaceEx(contentx," class='apply_input'"," class=\"apply_input_disabled\" disabled readonly");
			contentx=replaceEx(contentx," style=\"display: none\"","");
			contentx=replaceEx(contentx," style='display: none'","");
            postRequest(
            {action:"post_news",subject:$("apply_username").value+" - "+$("apply_project_name").value,is_pub:0,content:contentx,column_code:column_code,path_url:location.pathname,article_author:applyForm.apply_username.value},//默认为顶
            function(responseData1){
				 if(responseData1=="OK") {alert("恭喜你，你的项目申请发送成功！请等待审核结果公布！"); top.location.reload();}
				 else alert("申请发送失败，请稍候重试！");
            }
            );
      }
     if(confirm("填写好了吗，真的要提交吗？"))obj.sendData();   
}




function doSiteSearch(surl,target_name){
 	var qstr =search_form.search.value;
 	if(qstr=="")return  alert("请输入要搜索的关键字");
	var stype="1";
	if(search_form.search_type[0].checked)stype="1";
	else if(search_form.search_type[1].checked)stype="2";
	else if(search_form.search_type[2].checked)stype="3";
	else return alert("请正确选择搜索类别");

	top.open(surl+"?q="+qstr+"&t="+stype,target_name?target_name:"_blank");
}


/*  弹出式菜单
name           对象的 id 值                           
offsetLeft     定位：左-偏移量                        
offsetTop      定位：顶部-偏移量                      
alignment      对齐方式{-1: left; 0: center; 1: right}
anyIter        显示方式(<=0: 普通样式; >0: 缩放样式)  
anyTime        动画时间间隔                           
staticHover    鼠标覆盖时的样式                       
popupHover     显示内容鼠标覆盖时的样式               
popupLatency   显示内容延时                           
hideLatency    隐藏内容延时                           
onInit         初始化                                 
onPopup        显示内容时行为                         
onHide         隐藏内容时行为                         
*/
function TFly_Init(name, offsetLeft,offsetTop,alignment,anyIter,anyTime,staticHover,popupHover,popupLatency,hideLatency,onInit,onPopup,onHide){
	var TFly=document.getElementById(name);
	TFly.DT=document.getElementById(name+"_Popup");  //    显示内容对象
	TFly.F=document.getElementById(name+"_Anim");    //    动画效果对象
	TFly.oX=offsetLeft;
	TFly.oY=offsetTop;
	TFly.alignment=alignment;
	TFly.AnyIter=anyIter;
	TFly.AnyTime=anyTime;
	TFly.popupLatency=popupLatency;
	TFly.hideLatency=hideLatency;
	TFly.onPopup=onPopup;
	TFly.onHide=onHide;
	TFly.onmouseover=function(){
		if(staticHover!=''){					   //    替换样式，并储存原来的样式
			TFly.className_=TFly.className;
			TFly.className=staticHover;
		}
		TFly_Popup(TFly,true);
	}
	TFly.onmouseout=function(){
		if(staticHover!=''){						//    恢复原来的样式
			TFly.className=TFly.className_;
		}
		TFly_Popup(TFly,false);
	}
	if(document.all){
		TFly.onactivate=TFly.onmouseover;
		TFly.ondeactivate=TFly.onmouseout;
	}else{
		TFly.onfocus=TFly.onmouseover;
		TFly.onblur=TFly.onmouseout;
	}
	TFly.DT.onmouseover=function(){
		if(popupHover!=''){
			TFly.DT.className_=TFly.DT.className;
			TFly.DT.className=popupHover;
		}
		TFly_Popup(TFly,true);
	}
	TFly.DT.onmouseout=function(){
		if(popupHover!=''){
			TFly.DT.className=TFly.DT.className_;
		}
		TFly_Popup(TFly,false);
	}
	TFly_CallClientFunction(onInit,TFly);
}
//    调用初始化程序
function TFly_CallClientFunction(name,TFly){
	if(name!=null&&name!="")eval(name+"(TFly);");
}
//    定位
function TFly_SetPosition(TFly,obj){
	obj.style.top=TFly.oY+TFly.offsetHeight+"px";
	obj.style.left=TFly.oX+(TFly.offsetWidth-obj.offsetWidth )*(1+TFly.alignment)/2+"px";
}
function TFly_Popup(TFly,value){
	if(TFly.timer!=null)window.clearTimeout(TFly.timer);    //    清除超时
	if(value){    //    判断状态
		if(TFly.status=="on") return;
		//    如果 popup 已经显示，则显示延时为 0
		//    例如从一个菜单移动到另外一个菜单
		var timeout=(TFly.status=="active")?0:TFly.popupLatency;
		if(TFly.AnyIter>0 && TFly.AnyTime>0)
			TFly.timer=window.setTimeout(function(){TFly_AnimateStart(TFly,true,TFly.F.curIter);},timeout);
		else
			TFly.timer=window.setTimeout(function(){TFly_SetVisibility(TFly,true);},timeout);
	}else{
		if(TFly.status=="off") return;
		var timeout=(TFly.status=="active")?0:TFly.hideLatency;
		if(TFly.AnyIter>0 && TFly.AnyTime>0)
			TFly.timer=window.setTimeout(function(){TFly_AnimateStart(TFly,false,TFly.F.curIter);},timeout);
		else
			TFly.timer=window.setTimeout(function(){TFly_SetVisibility(TFly,false);},timeout);
	}
}
//设置弹出内容的可见性
function TFly_SetVisibility(TFly,value){
	if(value==true){
		TFly_SetPosition(TFly,TFly.DT);
		TFly.DT.style.visibility="visible";
		TFly.style.zIndex="999";
	}else{
		TFly.DT.style.visibility="hidden";
		TFly.style.zIndex="0";
		TFly.DT.style.left="-10000px";
	}
}
function TFly_AnimateStart(TFly,inout,curIter){
	if(TFly.F.timer!=null) window.clearTimeout(TFly.F.timer);
	if(curIter==null)curIter=0;
	if(TFly.status!="active"){
		TFly.status="active";
		TFly.F.style.visibility="visible";
		TFly.DT.style.visibility="hidden";
	}
	if(curIter<0||curIter>TFly.AnyIter){
		TFly.F.curIter=(curIter<1)?0:TFly.AnyIter;
		TFly.status=(TFly.F.curIter==TFly.AnyIter)?"on": "off";
		TFly.F.style.visibility="hidden";
		TFly_SetPosition(TFly,TFly.DT);
		TFly.style.zIndex=(TFly.F.curIter==TFly.AnyIter)?"999":"0";
		if(TFly.F.curIter==TFly.AnyIter){
			TFly.status="on";
			TFly_SetVisibility(TFly,true);
			TFly_CallClientFunction(TFly.onPopup,TFly);
		}else{
			TFly.status="off";
			TFly_SetVisibility(TFly,false);
			TFly_CallClientFunction(TFly.onHide,TFly);
		}
	}else{
		var per=curIter*(95/TFly.AnyIter)+5;
		TFly.F.style.visibility="hidden";
		TFly.F.style.width=TFly.DT.offsetWidth/100*per+"px";
		TFly.F.style.height=TFly.DT.offsetHeight/100*per+"px";
		TFly_SetPosition(TFly,TFly.F);
		TFly.F.style.visibility="visible";
		var timeout=(per==100 )?0:TFly.AnyTime-(TFly.AnyTime/(TFly.AnyIter)*(curIter));
		curIter +=(inout)?1:-1;
		TFly.F.timer=window.setTimeout(function(){TFly_AnimateStart(TFly,inout,curIter)},timeout);
		TFly.F.curIter=curIter;
	}
}

function AotoScrollToView(){
        var yMenuFrom, yMenuTo, yButtonFrom, yButtonTo, yOffset, timeoutNextCheck;

	yButtonFrom = parseInt (divMenu.style.top, 10);
	yButtonTo   = document.body.scrollTop + document.body.clientHeight - 108;
   
        timeoutNextCheck = 500;

        if(Math.abs (yButtonFrom - (yMenuTo + 152)) < 6 && yButtonTo < yButtonFrom){
                setTimeout ("AotoScrollToView()", timeoutNextCheck);
                return;
        }

        if(yButtonFrom != yButtonTo){
		yOffset = Math.ceil( Math.abs( yButtonTo - yButtonFrom )/10 );
		if(yButtonTo < yButtonFrom )yOffset = -yOffset;
		divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;
		timeoutNextCheck = 10;
        }
        if(yMenuFrom != yMenuTo){
		yOffset = Math.ceil( Math.abs( yMenuTo - yMenuFrom )/20 );
		if(yMenuTo < yMenuFrom )yOffset = -yOffset;
		divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;
		timeoutNextCheck = 10;
        }

        setTimeout ("AotoScrollToView()", timeoutNextCheck);
}
function goTop(){
       var y;
       var divMenu=null;
       var win_height=document.body.scrollHeight;
       var local_width=document.body.offsetWidth-(document.body.offsetWidth-975)/2-18;
      // alert(local_width);
       if(divMenu==null){
          document.body.insertAdjacentHTML("beforeEnd",'<DIV id=divMenu style="VISIBILITY: hidden; left:974; WIDTH: 17px; POSITION: absolute"><a href="#top" onclick="this.blur();"><img src="/resource/home/images/top.gif" border="0"></a></DIV>');
          divMenu=document.all("divMenu");
       }
       divMenu.style.top = document.body.scrollTop + document.body.clientHeight - 108;
     //alert( document.body.scrollHeight);
     // alert(window.screen.availHeight);//可工作区域的高
      if(document.body.scrollHeight-window.screen.availHeight>300){
           divMenu.style.visibility = "visible";
           AotoScrollToView();
       }
}

function Marquee()
{
	this.ID = document.getElementById(arguments[0]);
	if(!this.ID)
	{
		alert("您要设置的\"" + arguments[0] + "\"初始化错误\r\n请检查标签ID设置是否正确!");
		this.ID = -1;
		return;
	}
	this.Direction = this.Width = this.Height = this.DelayTime = this.WaitTime = this.CTL = this.StartID = this.Stop = this.MouseOver = 0;
	this.Step = 1;
	this.Timer = 30;
	this.DirectionArray = {"top":0 , "up":0 , "bottom":1 , "down":1 , "left":2 , "right":3};
	if(typeof arguments[1] == "number" || typeof arguments[1] == "string")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();
}

Marquee.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.HalfHeight = Math.round(this.Height / 2);
	this.BakStep = this.Step;
	this.ID.style.width = this.Width + "px";
	this.ID.style.height = this.Height + "px";
	if(typeof this.ScrollStep != "number")this.ScrollStep = this.Direction > 1 ? this.Width : this.Height;
	var templateLeft = "<table cellspacing='0' cellpadding='0' style='border-collapse:collapse;display:inline;'><tr><td noWrap=true style='white-space: nowrap;word-break:keep-all;'>MSCLASS_TEMP_HTML</td><td noWrap=true style='white-space: nowrap;word-break:keep-all;'>MSCLASS_TEMP_HTML</td></tr></table>";
	var templateTop = "<table cellspacing='0' cellpadding='0' style='border-collapse:collapse;'><tr><td>MSCLASS_TEMP_HTML</td></tr><tr><td>MSCLASS_TEMP_HTML</td></tr></table>";
	var msobj = this;
	msobj.tempHTML = msobj.ID.innerHTML;
	if(msobj.Direction <= 1)
	{
		msobj.ID.innerHTML = templateTop.replace(/MSCLASS_TEMP_HTML/g,msobj.ID.innerHTML);
	}
	else
	{
		if(msobj.ScrollStep == 0 && msobj.DelayTime == 0)
		{
			msobj.ID.innerHTML += msobj.ID.innerHTML;
		}
		else
		{
			msobj.ID.innerHTML = templateLeft.replace(/MSCLASS_TEMP_HTML/g,msobj.ID.innerHTML);
		}
	}
	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 / 2 : msobj.ID.scrollHeight / 2;
			if((msobj.Direction <= 1 && msobj.ClientScroll <= msobj.Height + msobj.Step) || (msobj.Direction > 1 && msobj.ClientScroll <= msobj.Width + msobj.Step))			{
				msobj.ID.innerHTML = msobj.tempHTML;
				delete(msobj.tempHTML);
				return;
			}
			delete(msobj.tempHTML);
			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);
}

Marquee.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;
	}
}

