var timeId=null;

   function startAnimationDown()
      {timeId=setInterval("animateDown()",220);}

    //定义愿望div向下飘移的函数
   function animateDown()
      {     
       var div2=document.getElementById("div2");
       var top=eval(div2.style.top.replace("px",""));
         
       div2.style.visibility="visible"; 
       if(top<document.body.scrollHeight-250)
          {
         div2.style.left=Math.random()*50+370;
         div2.style.top=top+10;
          }
      else
         {
        clearInterval(timeId); 
         }
     } 
   //定义搜索愿望时使用xmlhttprequest对象实现局部刷新的函数
  function searchWish(id)
    { 
   var form=document.getElementById(id);
   var wishSearch=form.wishSearch.value;
   var url="searchRespond.php";
   var data="wishSearch="+wishSearch;
   var http=false;
   try
    {http= new XMLHttpRequest();}
   catch(trymicrosoft)
    {try 
      {http = new ActiveXObject("Msxml2.XMLHTTP");}
     catch (othermicrosoft) 
       {try 
         {http = new ActiveXObject("Microsoft.XMLHTTP");}
        catch (failed) 
             {http = false;}
          }
     }

  if(!http) 
   {alert("浏览器出现问题");}
  else
   {
     
     http.open("post",url,true);
     http.onreadystatechange=function responseMode(){
             if(http.readyState==4&&http.status==200) 
                    {
                      var searchDiv=document.getElementById('searchDiv');
                      var img2=document.getElementById('img2');
                      var  imgUrl=http.responseText.substring(http.responseText.indexOf("|")+1,http.responseText.length);

                      imgUrl=imgUrl.replace(/(^\s*)|(\s*$)/g,"");
                      if(imgUrl=="null")
                               {
                      searchDiv.innerHTML="<font color=red>不存在此愿望！</font>";
                               }
                      else
                              {
                      img2.src=imgUrl;
                      searchDiv.innerHTML=http.responseText.substring(1,http.responseText.indexOf("|"));  
                              
                              }
                    }
                   }
    http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");  
    http.send(data); 
    }
   form.wishSearch.value="";
   form.wishSearch.focus();   
   }

