﻿function $get(str)
{
	return document.getElementById(str);
}

 function checkName() { 
    document.forms["formsearch"].submit();
    }

//专题首页广告

function PageOnLoad() {
	window.setTimeout("CloseInLineAD()", 20000);
}
function CloseInLineAD() {
	var obj = document.getElementById("InLineAD");
	obj.style.display = 'none';
	//window.open("http://www.bjrd.gov.cn/zhuanti/2009rdh/index.htm", "rdh2009");
}




//滚动显示代表风采
function Scrollpic(){
		showStr = document.getElementById(scrolls[percent]);
		show.filters[0].apply();
		show.innerHTML = showStr.innerHTML;
		show.filters[0].play();
	if (percent == (scrolls.length-1))
	{
		percent = 0
	}else{
		percent++;
	}
	setTimeout("Scrollpic()",6000)
}

//检查用户输入是否为空

//controlId 控件id
//wenzi:提示文字
function getInput(controlId,wenzi)
{
	var getId=$get(controlId);
	if(getId.value.length<3)
	{
	alert(wenzi);
	//getId.select();
	//getId.focus();
	return true;
	}
	return false;
}

// stepcount 需要的步数
// curentstep 当前步数
function stepsubmit(stepcount,curentstep)
{
  for(var i=0;i<stepcount;i++)
  {
	  if(curentstep==i)
	  {
		 $get("step"+curentstep).style.display="block";
		 if(i==1){initStep0();}
	  }
	  else
	  {
	     $get("step"+i).style.display="none";
	  }
	     
  }
}


//检查输入是否是数字
//controlId:控件ID
//numLen   数字长度
//wenzi     出错文字提示
function isnum(controlId,numLen, wenzi)
{
	var getId=$get(controlId);
	if(isNaN(getId.value) || (getId.value.length<numLen))
	{
	alert(wenzi);
	return true;
    }
	return false;
}

//得到选择值
function GetValue(controllId)
{
	return $get(controllId).value;
}

function initStep0()
{  
   if( getInput('txaddr','通讯地址不能为空'))
     {
     stepsubmit(2,0);
	 return false;
	 //break;
	 }
	$get('addr').innerText=GetValue('txaddr');
	
	 if( isnum('postcode',6,'请输入有效的邮政编码'))
     {
     stepsubmit(2,0);
	 return false;
	 }
	 $get('code').innerText=GetValue('postcode');
	 
	 if( isnum('tel',7,'请输入有效的联系方式'))
     {
     stepsubmit(2,0);
	  return false;
	 }
	  $get('tele').innerText=GetValue('tel');
	  
	 if( getInput('jytm','请填写建议题目'))
     {
     stepsubmit(2,0);
	 return false;
	 //break;
	 }
	  $get('disJytm').innerText=GetValue('jytm');
	  
	 if( getInput('jycontent','请填写建议内容'))
     {
	 stepsubmit(2,0);
	 return false;
	 //break;
	 }
	  $get('disJyContent').innerText=GetValue('jycontent');

}


//动态显示用户输入字数

function disCount(getId)
{    
    //alert($get(getId).value);
	$get('disTextNum').innerText=$get(getId).value.ByteCount();
}
//得到用户输入字的长度
String.prototype.ByteCount = function()
{
 txt = this.replace(/(<.*?>)/ig,'');
 txt = txt.replace(/([u0391-uFFE5])/ig, '11');
 var count = txt.length;
 return count;
}

//检查用户输入是否为空

function checkUserInput(controlId,wenzi)
{
	var getId=$get(controlId);
	if(getId.value.length<3)
	{
	alert(wenzi);
	getId.select();
	getId.focus();
	return false;
	}
	return true;
}
//播放音频文件
//frameid:框架id

//getid: 得到音频ID
function audioPlay(frameid,getid)
{
	$get(frameid).src='audio_play.asp?id='+getid;
}
function openwindow( url, winName, width, height)
{
xposition=0; yposition=0;
if
((parseInt(navigator.appVersion) >= 4 ))
{
xposition = (screen.width - width) / 2;
yposition =
(screen.height - height) / 2;
}
theproperty= "width=" + width + ","
+ "height=" + height + ","
+
"location=0,"
+ "menubar=0,"
+ "resizable=1,"
+ "scrollbars=0,"
+ "status=0,"
+ "titlebar=0,"
+
"toolbar=0,"
+ "hotkeys=0,"
+ "screenx=" + xposition + "," //仅适用于Netscape
+ "screeny=" +
yposition + "," //仅适用于Netscape
+ "left=" + xposition + "," //IE
+ "top=" + yposition; //IE
window.open( url,winName,theproperty );
}

//轮播广告
    var time = 500;
    var h = 0;
    function addCount()
    {
		  document.getElementById("InLineAD").style.display = "block";
        if(time>0)
        {
            time--;
            h = h+5;
        }
        else
        {
            return;
        }
        if(h>500)  //高度
        {
            return;
        }
        document.getElementById("InLineAD").style.display = "";
        document.getElementById("InLineAD").style.height = h+"px";
        setTimeout("addCount()",30); 
    }
    
    var T = 500;
    var N = 500; //高度
    function noneAds()
    {
        if(T>0)
        {
            T--;
            N = N-5;
        }
        else
        {
            return;
        }
        if(N<0)
        {
            document.getElementById("InLineAD").style.display = "none";
            return;
        }
        
        document.getElementById("InLineAD").style.height = N+"px";
        setTimeout("noneAds()",30); 
    }


