﻿function SearchFundTool()
{            
    
       var strKey = document.getElementById('fundSearchText').value;

        if(strKey == "" || strKey == "請輸入基金名稱")
        {
            alert('請輸入基金名稱'); 
            return false;
        }            
        else
        {            
              
               var httpRequest = AjaxRequest() ;
               httpRequest.abort(); 
               
               var getValue1=document.getElementById("fundSearchText").value;
               
               var url="http://fund.cnyes.com/Search_Tool.aspx?searchValue="+encodeURI(getValue1) + "&R=" + Math.random();
                                     
               if (httpRequest) 
               {
                  httpRequest.onreadystatechange = function()
                   {
               
                    if (httpRequest.readyState == 4 && httpRequest.status == 200)
                    {
                       var result = httpRequest.responseText;
                     
                    }                    
                  }
                  
                  httpRequest.open("GET",url,true);
                  httpRequest.send(null);   
                  
                
               
              }                      
             var url2='/page/searchValue.aspx?fName1=' + encodeURI(document.getElementById("fundSearchText").value) ;  
             //alert(url2) ;               
             window.open(url2);
           //window.top.location.href= url2;   
           //document.getElementById("fundSearchText").value='請輸入基金名稱';    
  }                    
 }
 
 
   function AjaxRequest()
    { 
	    var A=null;

	    // Internet Explorer
	    try
	    {
		    A=new ActiveXObject("Msxml2.XMLHTTP");
	    }
	    catch(e)
	    {
		    try
		    {
			    A=new ActiveXObject("Microsoft.XMLHTTP");
		    }
		    catch(oc)
		    {
			    A=null;
		    }
	    }

	    // Mozilla
	    if ( !A && typeof XMLHttpRequest != "undefined" ) 
	    {
		    A=new XMLHttpRequest();
	    }
	    return A;
    }
 
 
