﻿// JScript File

var msg_val = 'Search...' ;
function set_textbox(obj)
{
    var txt = obj.value ;
    if (txt == msg_val){ obj.value = '' ; }
} 

function clear_textbox(obj)
{
    var txt = obj.value ;
    if (txt == ''){ obj.value = msg_val ; }
} 

//============= Advertise Stat Click ==============
function AdsClick(ids)
{   
    jQuery.ajax({
    type:"GET" ,
    url:"Ajax/AdvClick.aspx?aid="+ ids  ,
    success:function(msg){  
       if(msg != "")
       {}
       },
    fail: function(msg){ alert(' failed'); }
    }) ;

}

//============= Search Funds ==============

$id = function(obj){ return document.getElementById(obj) ; }
var pth_wait = "<img src='Images/loading.gif' hspace='260' vspace='50' />" ;
var pre = "ctl00_UcSearchFund_" ;

function ChangeSeachFunds(callid , obj)
{  
    var house_ = obj;
    var fundid_ = $id(pre + "DlFunds") ; 

    var Gid_ = $id("Hid_Gid").value ;
    var house = house_.options[house_.selectedIndex].value ; 
//     if(house_.selectedIndex == -1 || house == -1 || house == 0){
//        for(var i = fundid_.length-1; i>0 ; i--){
//            fundid_.options[i]=null;
//        }
//      } 
    
    var qrys = "cid="+ callid +"&gid="+ Gid_ +"&parent_id="+ house ;
    jQuery.ajax({
    type:"GET" ,
    url:"Ajax/AjxDropdown.aspx" ,
    data:qrys ,
    success:function(msg){  
    
       for(var i=fundid_.length-1;i>=0;i--)
	   {   fundid_.options[i]=null;    }
	   
       if(msg != "")
       {
            eval('var namevalue='+msg);
	        if(namevalue!=null)
	        {
                if(fundid_)
                {
	                  for(var i=0;i<namevalue.length;i++)
	                  {   var opt = new Option(namevalue[i].name,namevalue[i].value);
		                  fundid_.options[fundid_.length] = opt;
	                  }
                }
            }
          }
	    },
    fail: function(msg){ alert(' failed'); }
    }) ;
}

function GetSearchData(qry)
{   $id('Search_Content').innerHTML = pth_wait ;
     var qrys = "" ;
     if (qry == null)
     {  
        var txt = $id(pre + "txtSearch").value ;
        if (txt == "Search...") txt = "" ;
        var Gid_ = $id("Hid_Gid").value ;
        var house_ = $id(pre + "DlHouse") ;
        //var fundid_ = $id(pre + "DlFunds") ; 
        var curr_ = $id(pre + "DlCurr") ; 
        var asset_ = $id(pre + "DlAsset") ; 
        var region_ = $id(pre + "DlRegion") ; 
       // var core_ = $id(pre + "DlCore") ; 
            
        var house = house_.options[house_.selectedIndex].value ; 
        //var fundid = fundid_.options[fundid_.selectedIndex].value ; 
        var curr = curr_.options[curr_.selectedIndex].value ; 
        var asset = asset_.options[asset_.selectedIndex].value ;
        var region = 0;  // region_.options[region_.selectedIndex].value ; 
      //  var core = core_.options[core_.selectedIndex].value ; 

        //qrys = "gid="+ Gid_ +"&house="+ house +"&fundid="+ fundid +"&curr="+ curr +"&asset="+ asset +"&region="+ region +"&core="+ core ;
        qrys = "txt="+txt+"&gid="+ Gid_ +"&house="+ house +"&curr="+ curr +"&asset="+ asset +"&region="+ region ;
     }   
     else
     {
        qrys = qry ;
     }
       
        jQuery.ajax({
        type:"GET" ,
        cache: false,
        url:"Ajax/AjaxSearchFunds.aspx" ,
        data:qrys ,
        async : false ,
        success:function (msg)
            {   $id('Search_Content').innerHTML = msg ; } ,
        fail: function(msg){ alert(' failed'); }
        }) ;
        
}
// -------------- SearchProduct ----------------

var pth_wait_p = "<img src='Images/loading.gif' hspace='260' vspace='50' />" ;
var pre_p = "ctl00_UcSearchProduct_" ;

function GetSearchProduct(qry)

{       
        $id('Search_Content').innerHTML = pth_wait_p ;
     var qrys = "" ;
     if (qry == null)
     
     {  
        var Gid_ = $id("Hid_Gid").value ;
        var rdo_ =  ""
       
        //document.getElementById['ctl00_UcSearchProduct_rdo_0'];
       
        var Frequency_ = $id(pre_p + "DlFrequency") ; 
        var curr_ = $id(pre_p + "DlCurr") ; 
        var length_ = $id(pre_p + "DlLength") ; 
        var expected_ = $id(pre_p + "DlExpected") ;         
        var national_ = $id(pre_p + "DlNational") ;
        var city_ = $id(pre_p + "DlCity") ;       
        var na_ = $id(pre_p + "DlNa") ;      
        var do_ = $id(pre_p + "DlDo") ;        
        var Ini_ = $id(pre_p + "DlIni") ; 
        var Acc_ = $id(pre_p + "DlAcc") ;
        var Ab_ = $id(pre_p + "DlAb") ; 
        var upon_ = $id(pre_p + "Dlupon") ;
        var look_ = $id(pre_p + "Dllook") ;
        var In_ = $id(pre_p + "DlIn") ;
       //var rdo = rdo_.options[rdo_.selectedIndex].value ;
       
       
        var curr = curr_.options[curr_.selectedIndex].value ; 
         var city = city_.options[city_.selectedIndex].value ; 
        var na = na_.options[na_.selectedIndex].value ; 
         var Invest = In_.options[In_.selectedIndex].value ; 
         var Acc = Acc_.options[Acc_.selectedIndex].value ; 
         //--------------------- 0
        var Frequency = Frequency_.options[Frequency_.selectedIndex].value ; 
        var length = length_.options[length_.selectedIndex].value ; 
       var look = look_.options[look_.selectedIndex].value ; 
        //var national = national_.options[national_.selectIndex].value ;
        //var nation = "0"
        //----------------------- 1
        var expected = expected_.options[expected_.selectedIndex].value ; 
        var Doyou = do_.options[do_.selectedIndex].value ;
        var Ini = Ini_.options[Ini_.selectedIndex].value ;           
        var upon = upon_.options[upon_.selectedIndex].value ;       
        var Ab = Ab_.options[Ab_.selectedIndex].value ; 
        
         if (document.getElementById("ctl00_UcSearchProduct_rdo_0").checked == true)
        {
        qrys = "gid="+ Gid_ +"&nation="+ na +"&city="+ city +"&Invest="+ Invest +"&curr="+ curr  +"&Acc="+ Acc +"&Frequency="+ Frequency +"&length="+ length +"&look="+look ;
         
        }
        else if (document.getElementById("ctl00_UcSearchProduct_rdo_1").checked == true)
        {
        qrys = "gid="+ Gid_ +"&nation="+ na +"&city="+ city +"&Invest="+ Invest +"&curr="+ curr  +"&Acc="+ Acc +"&expected="+ expected +"&Doyou="+ Doyou +"&Ini="+Ini +"&upon="+ upon +"&Ab="+Ab;         
        }
        else
        {
        qrys = "gid="+ Gid_ +"&nation="+ na +"&city="+ city +"&Invest="+ Invest +"&curr="+ curr  +"&Acc="+ Acc ;
        }

       
     }   
     else
     {
        qrys = qry ;
     }
       
        jQuery.ajax({
        type:"GET" ,
        cache: false,
        url:"Ajax/AjaxSearchProduct.aspx" ,
        data:qrys ,
        async : false ,
        success:function (msg)
            {   $id('Search_Content').innerHTML = msg ; } ,
        fail: function(msg){ alert(' failed'); }
        }) ;
        
}

// -------------- SearchPopupProduct ----------------

var pre_s = "PopupProduct_" ;

function GetSearchPopupProduct(qry)

{       
     $id('Search_Content').innerHTML = pth_wait_p ;
     var qrys = "" ;
     if (qry == null)
     
     {  
                      
        var Frequency_ = $id(pre_s + "DlFrequency") ; 
        var curr_ = $id(pre_s + "DlCurr") ; 
        var length_ = $id(pre_s + "DlLength") ; 
        var expected_ = $id(pre_s + "DlExpected") ;         
        var national_ = $id(pre_s + "DlNational") ;
        var city_ = $id(pre_s + "DlCity") ;       
        var na_ = $id(pre_s + "DlNa") ;      
        var do_ = $id(pre_s + "DlDo") ;        
        var Ini_ = $id(pre_s + "DlIni") ; 
        var Acc_ = $id(pre_s + "DlAcc") ;
        var Ab_ = $id(pre_s + "DlAb") ; 
        var upon_ = $id(pre_s + "Dlupon") ;
        var look_ = $id(pre_s + "Dllook") ;
        var In_ = $id(pre_s + "DlIn") ;
    
       
        var curr = curr_.options[curr_.selectedIndex].value ; 
         var city = city_.options[city_.selectedIndex].value ; 
        var na = na_.options[na_.selectedIndex].value ; 
         var Invest = In_.options[In_.selectedIndex].value ; 
         var Acc = Acc_.options[Acc_.selectedIndex].value ; 
         //--------------------- 0
        var Frequency = Frequency_.options[Frequency_.selectedIndex].value ; 
        var length = length_.options[length_.selectedIndex].value ; 
       var look = look_.options[look_.selectedIndex].value ;        
        //----------------------- 1
        var expected = expected_.options[expected_.selectedIndex].value ; 
        var Doyou = do_.options[do_.selectedIndex].value ;
        var Ini = Ini_.options[Ini_.selectedIndex].value ;           
        var upon = upon_.options[upon_.selectedIndex].value ;       
        var Ab = Ab_.options[Ab_.selectedIndex].value ; 
        
         if (window.location.hash == "#1" )
        {
        qrys = "&nation="+ na +"&city="+ city +"&Invest="+ Invest +"&curr="+ curr  +"&Acc="+ Acc +"&Frequency="+ Frequency +"&length="+ length +"&look="+look ;
         
        }
        else if (window.location.hash == "#2" )
        {
        qrys = "&nation="+ na +"&city="+ city +"&Invest="+ Invest +"&curr="+ curr  +"&Acc="+ Acc +"&expected="+ expected +"&Doyou="+ Doyou +"&Ini="+Ini +"&upon="+ upon +"&Ab="+Ab;         
        }
        else
        {
        qrys = "&nation="+ na +"&city="+ city +"&Invest="+ Invest +"&curr="+ curr  +"&Acc="+ Acc ;
        }        
       
     }   
     else
     {
        qrys = qry ;
     }
                
        jQuery.ajax({
        type:"GET" ,
        cache: false,
        url:"Ajax/AjaxSearchProduct.aspx" ,
        data:qrys ,
        async : false ,
        success:function (msg)
            {   $id('Search_Content').innerHTML = msg ; } ,
        fail: function(msg){ alert(' failed'); }
        }) ;
        
}

function showhide(obj)
{
    $id(obj).style.display = "" ; 
}