﻿

function error(message)
{
    if(message.value!="")
    {
       alert(message.value);
       message.value=""; 
    }

}

function changebackgrounde(color,tdcolor)
{
       document.getElementById(tdcolor).style.backgroundColor="#"+color;
}


function changesize(size,tdsize)
{
 document.getElementById(tdsize).style.fontSize=size+"px";
}

/*==========评论插入表情图片==============*/
function clicktext(img,text)
{
     var pa=img.src.toString().split('/');
     document.getElementById(text).value+="["+pa[pa.length-1].toString()+"]";
     var text = document.getElementById(text);
            if (text != null && text.value.length > 0)
            {
                if (text.createTextRange)
                {
                    var FieldRange = text.createTextRange();
                    FieldRange.moveStart('character', text.value.length);
                    FieldRange.collapse();
                    FieldRange.select();
                }
            }
}


/*========信心弹出文本框====================*/

function MessageBox(Message)
{
    if(Message.value!="")
    {
       alert(Message.value);
       Message.value="";
    }
    
}


/*=========用户输入Enter时候让登入按钮获得焦点===============*/

function keyDown(e)
        { 
          ns4 = (document.layers) ? true : false;
          ie4 = (document.all) ? true : false;
          if (ns4)
          { 
             var nKey=e.which; 
             if (nkey == "13")
             {
               try
               {
                  document.getElementById("ctl00_ContentPlaceHolder1_UserEnter1_ImageButton1").focus();
               }
               catch(err){return;}
             }
           } 
         if (ie4)
         { 
             var ieKey=event.keyCode; 
             if (ieKey == "13")
               { 
                  try
                  {
                   document.getElementById("ctl00_ContentPlaceHolder1_UserEnter1_ImageButton1").focus();
                  }
                  catch(err){return;}
               }
          } 
     }
  document.onkeydown = keyDown;

/*===========================================================*/

/*==========判断发布评论的文本内容不可超过限定的字符==============*/
function iftextlenth(text)
{
    var value=text.value;
       if(value.length>250)
       {
           alert("评论内容不能超过250个字符!");
            text.value=value.substring(0,250);
       }
}


   
   
    /*====================首页的7个div的显示控制===================================*/

function changetd_div_inline(td,div,count)
{
       coninline(count);
       document.getElementById(td).className="par2";
      document.getElementById(div).style.display="inline";
}

function coninline(count)
{
    for(var i=1;i<=count;i++)
      {
          document.getElementById("div"+i).style.display="none";
          document.getElementById("td"+i).className="par1";
       }
}



function changetd_div_inline2(td,div,count)
{
       coninline2(count);
       document.getElementById(td).className="par2";
      document.getElementById(div).style.display="inline";
}

function coninline2(count)
{
    for(var i=1;i<=count;i++)
      {
          document.getElementById("diva"+i).style.display="none";
          document.getElementById("tda"+i).className="par1";
       }
}



 function displaycss1(imgbnt)
 {
      imgbnt.style.width="20px";
 }
  function displaycss2(imgbnt)
 {
      imgbnt.style.width="27px";
 }



/*===============图片高度宽度限制==================================*/

 //参数1：图片对象this；
 //参数2：要求的宽度width；
 //参数3：要求的高度height；
 //参数4：布尔值为真
 
function act_resize_img(imgObj, rectWidth, rectHeight, fixIeBug)
{

	try
	{
		if(!fixIeBug) fixIeBug = true;
		//修正在IE运行下的问题
		if( (imgObj.width==0 || imgObj.height==0) && fixIeBug ) {
			var timer = setInterval(function(){
										act_resize_img(imgObj, rectWidth, rectHeight, false);
										clearInterval(timer);
									}, 1000);	
			return;
		}
		var x = imgObj.width>rectWidth ? rectWidth : imgObj.width;
		var y = imgObj.height>rectHeight ? rectHeight : imgObj.height;
		var scale	= imgObj.width/imgObj.height;
	
		if( x>y*scale ) {
			imgObj.width	= Math.floor(y*scale);
			imgObj.height	= y;
		}else {
			imgObj.width	= x;
			imgObj.height	= Math.floor(x/scale);
		}
		imgObj.style.width = imgObj.width+"px";
		imgObj.style.height = imgObj.height+"px";

		if (typeof(imgObj.onload)!='undefined')
		{
			imgObj.onload=null;
		}
	}
	catch(err)
	{
	
	}
}


/*===================设定图片加载后固定像数=======================================*/
var flag=false; 
function DrawImage(ImgD){ 
            var image=new Image(); 
            image.src=ImgD.src; 
            if(image.width>0 && image.height>0){ 
            flag=true; 
            if(image.width/image.height>= 140/150){ 
            if(image.width>140){ 
            ImgD.width=140; 
            ImgD.height=(image.height*140)/image.width; 
            }else{ 
            ImgD.width=image.width; 
            ImgD.height=image.height; 
            } 
            //ImgD.alt=image.width+"x"+image.height; 
            } 
            else{ 
            if(image.height>150){ 
            ImgD.height=150; 
            ImgD.width=(image.width*150)/image.height; 
            }else{ 
            ImgD.width=image.width; 
            ImgD.height=image.height; 
            } 
            //ImgD.alt=image.width+"x"+image.height; 
            } 
            } 
       } 


/*
     设置图片的限定宽度
      ImgD  图片对象
      Max   限定的宽度
*/
function DrawImageLore(ImgD,Max){
           var image=new Image(); 
            image.src=ImgD.src; 
            if(image.width>Max){
              ImgD.width=Max;
              ImgD.height=image.height;
            }
            else
            {
               ImgD.width=image.width;
               ImgD.height=image.height;
            }
     
}

/*
   <判断输入的导航页是否正确>
    text      ---当前输入的页数
*/
function pagego(text)
{  
       if(!isNaN(text.value))
       {
          if(parseInt(text.value)<1){
             alert("页码最低为1页,请重新输入!");
             text.value="";
          }
          
       }
       else{
       if(text.value!=""){
       alert("请输入数字!");text.value="";}
       
       }
       
}


  // FCK文本高度增加
  function FCK_Max(fck)
  {
      
     var max= document.getElementById(fck).style.height.toString().split('p');
     var value=parseInt(max[0])+100;
     document.getElementById(fck).style.height=value+"px";
  }
  // FCK文本高度减少
  function FCK_Mac(fck)
  {
     var mac=document.getElementById(fck).style.height.toString().split('p');
     var value=parseInt(mac[0]-100);
     if(value<200)
     {
       document.getElementById(fck).style.height="200px";
     }
     else
     {
       document.getElementById(fck).style.height=value+"px";
     }
  }
  
  
  /*==============打开知识提问介绍层============================*/
  function DivLoreQuizOpen(div1,div2)
  {
       var pane1= document.getElementById(div1);
       var pane2=document.getElementById(div2);
       pane1.style.visibility="visible";
       pane2.style.visibility="visible";
       pane2.style.width=document.body.scrollWidth+document.body.offsetLeft;
       pane2.style.height=document.body.scrollHeight+document.body.offsetTop;
       document.getElementById("ctl00_ContentPlaceHolder1_bntSave").focus();
       return false;
  }
  function DivLoreQuizClose(div1,div2)
  {
      document.getElementById(div1).style.visibility="hidden";
      document.getElementById(div2).style.visibility="hidden";
      
  }
  
  
  /*==============显示日期============================*/
function showDate()
{
var d = new Date();  
document.write("<div>今天是 "+d.getYear()+"年"+(d.getMonth()+1)+"月"+d.getDate()+"日");
switch(d.getDay())
{
 case 0:
  document.write("  <font color=#FF0000>星期日");
  break;
 case 1:
  document.write("  <font color=#000000>星期一");
  break;
 case 2:
  document.write("  <font color=#000000>星期二");
  break;
 case 3:
  document.write("  <font color=#000000>星期三");
  break;
 case 4:
  document.write("  <font color=#000000>星期四");
  break;
 case 5:
  document.write("  <font color=#000000>星期五");
  break;
 case 6:
  document.write("  <font color=#FF0000>星期六");
  break;
}
 document.write("</font></div>");
}



