I finally found the solution to my problem after serching in dnn source code so I will publish the code here in case that someone else needs to know how to do it. I have one LinkButton for each language and the equivalent events which will handle the language change. In order to make it simple I will type use a simple example with text instead of images but you can replace the word of the langue with an img tag.
The HTML Part
<asp:LinkButton ID="btnGreek" runat="server" OnClick="btnGreek_Click">Greek</asp:LinkButton>
<asp:LinkButton ID="btnEnglish" runat="server" OnClick="btnEnglish_Click">English</asp:LinkButton>
The VB.NET code
Private Function getQSParams(ByVal newLanguage As String) As String()
Dim returnValue As String = ""
Dim coll As NameValueCollection = HttpContext.Current.Request.QueryString
Dim arrKeys(), arrValues() As String
arrKeys = coll.AllKeys
For i As Integer = 0 To arrKeys.GetUpperBound(0)
If arrKeys(i) IsNot Nothing Then
Select Case arrKeys(i).ToLowerInvariant()
Case "tabid", "ctl", "language"
'skip parameter
Case Else
If (arrKeys(i).ToLowerInvariant = "portalid") And PortalSettings.ActiveTab.IsSuperTab Then
'skip parameter
'navigateURL adds portalid to querystring if tab is superTab
Else
arrValues = coll.GetValues(i)
For j As Integer = 0 To arrValues.GetUpperBound(0)
If returnValue <> "" Then returnValue += "&"
returnValue += arrKeys(i) + "=" + HttpUtility.HtmlEncode(arrValues(j))
Next
End If
End Select
End If
Next
Dim settings As PortalSettings = PortalController.GetCurrentPortalSettings
If (Not settings.ContentLocalizationEnabled) AndAlso _
LocaleController.Instance.GetLocales(settings.PortalId).Count > 1 AndAlso _
(settings.EnableUrlLanguage = False) Then
'because useLanguageInUrl is false, navigateUrl won't add a language param, so we need to do that ourselves
If returnValue <> "" Then returnValue += "&"
returnValue += "language=" + newLanguage
End If
'return the new querystring as a string array
Return returnValue.Split("&"c)
End Function
Private Function GetURL(ByVal newLanguage As String) As String
Dim objSecurity As New PortalSecurity
Dim newLocale As Locale = LocaleController.Instance().GetLocale(newLanguage)
'Ensure that the current ActiveTab is the culture of the new language
Dim tabId As Integer = PortalSettings.ActiveTab.TabID
Dim localizedTab As DotNetNuke.Entities.Tabs.TabInfo = New TabController().GetTabByCulture(tabId, PortalSettings.PortalId, newLocale)
If localizedTab IsNot Nothing Then
tabId = localizedTab.TabID
End If
Return objSecurity.InputFilter(NavigateURL(tabId, PortalSettings.ActiveTab.IsSuperTab, PortalSettings, HttpContext.Current.Request.QueryString("ctl"), newLanguage, getQSParams(newLanguage)), PortalSecurity.FilterFlag.NoScripting)
End Function
Protected Sub btnEnglish_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect(GetURL("en-US"))
End Sub
Protected Sub btnGreek_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect(GetURL("el-GR"))
End Sub