﻿function CurrencySelector_OnDropDownChanged(clientID, controlID)
{    
    var currency;
    if (clientID != null)
    {
        var dropDown = $get(clientID);
        currency = dropDown.options[dropDown.selectedIndex].value;      
    }
        
    JetShop.StoreControls.Services.General.SetDisplayCurrency(currency, CurrencySelector_OnSucceeded, CurrencySelector_OnFailed, controlID);    
}

function CurrencySelector_OnRadioButtonClick(currency, controlID)
{    
    JetShop.StoreControls.Services.General.SetDisplayCurrency(currency, CurrencySelector_OnSucceeded, CurrencySelector_OnFailed, controlID);
}

// This is the event handler called after 
// the Web request returns.
function CurrencySelector_OnSucceeded(result, userContext, methodName) 
{        
	var cs = $get(userContext);
 
    CurrencySelector_ReloadPages(cs.useFrame);  
}

function CurrencySelector_OnFailed(result, userContext, methodName) 
{  
}

function CurrencySelector_ReloadPages(singleFrame)
{   
    if (singleFrame == "true")
    {        
        window.location.reload();
    }
    else
    {
        var href;
        
        for (var idx = 0; idx < window.top.frames.length; idx++)
        {
            href = window.top.frames[idx].location.href;            
            window.top.frames[idx].location.href = href;
        }       
    }
}
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();