<?php 
    $flagUrl = Yii::app()->request->getBaseUrl(true).'/img/flags/16x11/'.$currentLang.'.png';
    //echo CHtml::image(Yii::app()->request->getBaseUrl(true).'/img/flags/16x11/'.$currentLang.'.png', '', array('class'=>'currentLangFlag')); ?>
<div class="btn-group" style="margin:0">
      <a id="languageSelectToggle" class="dropdown-toggle" data-toggle="dropdown" href="#" style="background-image:url('<?php echo $flagUrl;?>')">
        <?php //echo CHtml::image(Yii::app()->request->getBaseUrl(true).'/img/flags/16x11/'.$currentLang.'.png', '', array('class'=>'currentLangFlag')); ?>
      </a>
      <ul class="dropdown-menu">
        
        <?php echo CHtml::beginForm('','',array('class'=>'nm'));?>

        <?php
            foreach($languages as $key=>$lang) {
                    /*if($key == $currentLang) {
	               continue;
	            };*/
	            
	            $flagPicture = CHtml::image(Yii::app()->request->getBaseUrl(true).'/img/flags/16x11/'.$key.'.png', $lang);
	            $switchLink = CHtml::link($flagPicture . $lang, '',
	        	  array(
	        		 'class' => 'addessFlag',
	        		 'submit' => '',
	        		 'params' => array('language' => $key)
	        		)
	            );
	            $currentLangCell = $key == $currentLang ? ' class="active"' : '';
	            
	            echo '<li'.$currentLangCell.'>'.$switchLink.'</li>';	            
	       }
        ?>
        <?php echo CHtml::endForm();?>
    </ul>
</div>


