@model Nop.Web.Models.Common.LanguageSelectorModel
@if (Model.AvailableLanguages.Count > 1)
{
    if (Model.UseImages)
    {
    <ul class="languagelist">
        @foreach (var lang in Model.AvailableLanguages)
        {
            <li>
                <img title='@lang.Name' alt='@lang.Name' @(lang.Id == Model.CurrentLanguage.Id ? " class=selected" : null)
                 src="@Url.Content("~/Content/Images/flags/" + @lang.FlagImageFileName) " onclick="setLocation('@(@Url.Action("LanguageSelected", "Common", new { customerlanguage = lang.Id }))')" />
            </li>
        }
    </ul>
    }
    else
    {

        using (Ajax.BeginForm("LanguageSelected", "Common", new AjaxOptions { OnComplete = "onLanguageChangedRequestCompleted();" }, new { id = "form-languageselector" }))
        {
            var languages = Model.AvailableLanguages.Select(x => new SelectListItem
            {
                Text = x.Name,
                Value = x.Id.ToString(),
                Selected = x.Id.Equals(Model.CurrentLanguage.Id)
            });
    
    @Html.DropDownList("customerlanguage",
            languages,
            new { onChange = "onLanguageChanged();" })
            
    <script type="text/javascript">
        function onLanguageChanged() {
            $("#form-languageselector").submit();
        }
        function onLanguageChangedRequestCompleted() {
            location.reload();
        }
    </script>
        }
    }
}