$().ready(function()
{ 	
    QuickBranchLocator.init();					 
})

QuickBranchLocator=
{
    init:function()
    {        
        QuickBranchLocator.setEventHandlers();
    },
    
   setEventHandlers: function()
   {                                      											    
        /* optDiv.hide('fast');  */
        $(".btnSearchRegion").unbind().click(QuickBranchLocator.changeRegion);  
        $(".btnSearchBranches").unbind().click(QuickBranchLocator.changeBranch);  
   },   
    
   changeRegion:function()
   {
        try
        {
            optDiv=$(".jsDDLQuickBLRegions");
            optSelect=optDiv.children("select");
            var CurrentRegion =  optSelect[0].options[optSelect[0].selectedIndex].text;
            
            if (optSelect[0] != null && optSelect[0].options[optSelect[0].selectedIndex].value != "0")            
            {
		        WSK.OffAng.ClientServices.QuickBranchLocator.UpdateQuickBranchLocator(oListName, CurrentRegion, QuickBranchLocator.LoadDDLBranches.bind(this));                            
                $(".ddlBranchesList")[0].disabled = false;
            }     
            else
            {
                $(".ddlBranchesList")[0].disabled = true;
            }
        }
        catch(e){alert(e);}
                
        return false;
   },
   
   changeBranch:function()
   {
        try
        {
            if ($(".ddlBranchesList")[0].value != "0")
            {
                window.location.href = oURLQuickBL + "?IDBranch=" + $(".ddlBranchesList")[0].value + "&TypeWP=QBL";
            }
        }
        catch(e){alert(e)}
                
        return false;
   },
      
   LoadDDLBranches:function(res)
   {
        optSelect=$(".ddlBranchesList");
        optSelect.html(res.value);
        optSelect.attr("contentHTML",optSelect.get(0).outerHTML);   
        
        return false;
   }  
}