
	function videoSorting(){
	            
	            // DOMContentLoaded
	            //function() {
	
	              // bind radiobuttons in the form
	
	              var $filterAlphabet = $('ul#alphabet li');
	              var $filterChannel = $('a.channels');
	              var $filterCategory = $('div.filter_form a');
	
	              var $channel='';
	              var $category='';
	              var $currentType='';
	              var $active_type='';
	              var $channelName='';
	              var $channelLink='';
	              //var $channelFrom='';
	
	              // get the video collection
	              var $data = $('#video_films');
	              
	              
	           
	
	              channelChange();
	
	              function channelChange(){
	              $channel='';
	              $category='';
	
	                 $channel=$filterChannel.filter('[class*=H]').attr("href");
	                 $channelName=$('a.channels[class*=H] span[class="center"]').text();
	                 $channelLink=$('a.channels[class*=H] span[class="namePat"]').text();
	                 $channel=$channel.substring(1);
	
	                    $category=$('div#'+ $channel + ' div.filter_form a.activeCategory');
	                    $data.find('li[class*=myfilms]').css("display","none");
	                    
	                    if(($channel==='tabAll'))
	                        {
	                            if($category.hasClass('activeCategory'))
	                                {
	                                    var $categoryId=$category.attr('class');
	                                    $categoryId=$categoryId.substring(0,$categoryId.length-15);
	
	                                    if($currentType =='')
	                                        {
	                                        var $filteredData = $data.find('li[class*=myfilms]').filter('[id*=b' + $categoryId  + ']').css("display","block");
	                                            // set class for alphabet filter
	
	                                             $filterAlphabet.addClass('noData');
	                                            $filteredData.each(function(index) {
	                                                    $active_type=$(this).attr('id');
	                                                    $active_type=$active_type.substring(0,1);
	                                                    $filterAlphabet.filter('[id=' + $active_type  + ']').removeClass('noData');
	
	                                                });
	                                        }
	                                    else
	                                        $data.find('li[class*=myfilms]').filter('[id*=b' + $categoryId  + ']').filter('[id^=' + $currentType +']').css("display","block");
	
	                               }
	                           else
	                               {
	
	                                    if($currentType =='')
	                                        {
	                                      var $filteredData = $data.find('li[class*=myfilms]').css("display","block");
	                                
	                                           // set class for alphabet filter
	                                           $filterAlphabet.addClass('noData');
	                                            $filteredData.each(function(index) {
	                                                $active_type=$(this).attr('id');
	                                                $active_type=$active_type.substring(0,1);
	                                                $filterAlphabet.filter('[id=' + $active_type  + ']').removeClass('noData');
	
	                                            });
	                                        }
	                                    else
	                                        $data.find('li[class*=myfilms]').filter('[id^=' + $currentType +']').css("display","block");
	
	
	                                }
	                    }
	                else if (($channel!=='tabAll'))
	                   {
	
	                            if($category.hasClass('activeCategory'))
	                                {
	                                    var $categoryId=$category.attr('class');
	
	                                    $categoryId=$categoryId.substring(0,$categoryId.length-15);
	
	                                    if($currentType =='')
	                                        {
	                                           var $filteredData = $data.find('li[class*=myfilms]').filter('[id*=' + $channel  + ']').filter('[id*=b' + $categoryId  + ']').css("display","block");
	
	                                            // set class for alphabet filter
	
	                                             $filterAlphabet.addClass('noData');
	                                            $filteredData.each(function(index) {
	                                                    $active_type=$(this).attr('id');
	                                                    $active_type=$active_type.substring(0,1);
	                                                    $filterAlphabet.filter('[id=' + $active_type  + ']').removeClass('noData');
	
	                                                });
	                                        }
	                                    else
	                                        $data.find('li[class*=myfilms]').filter('[id*=' + $channel  + ']').filter('[id*=b' + $categoryId  + ']').filter('[id^=' + $currentType +']').css("display","block");
	
	                               }
	                           else
	                               {
	
	                                    if($currentType =='')
	                                        {
	
	                                         var $filteredData = $data.find('li[class*=myfilms]').filter('[id*=' + $channel  + ']').css("display","block");
	
	                                            // set class for alphabet filter
	                                           $filterAlphabet.addClass('noData');
	                                            $filteredData.each(function(index) {
	                                                $active_type=$(this).attr('id');
	                                                $active_type=$active_type.substring(0,1);
	                                                $filterAlphabet.filter('[id=' + $active_type  + ']').removeClass('noData');
	                                            });
	                                        }
	                                    else
	                                        $data.find('li[class*=myfilms]').filter('[id*=' + $channel  + ']').filter('[id^=' + $currentType +']').css("display","block");
	
	
	                                }
	                    }
	
	                 /*Button More channels*/
	                 if($channel==="tabAll")
	                 {
	                    $('div.menu.tabJQList.bgBlack').remove();
	                    //$('#filter_box').after('<img id="video_top_line" alt="Top" src="/extension/tvdesign/design/tvdesign/images/borderOrangeTop_white_roundFull.gif">');
	                 }
	                 else
	                    {
	                       //$('#video_top_line').remove();
	                       $('div.menu.tabJQList.bgBlack').remove();
	                        $('#filter_box').after('<div class="menu tabJQList bgBlack"><a class="chanels H" href="/' + $channelLink + '"><span class="left"></span><span class="center">' + $channelName + '</span><span class="right"></span></a><a class="moreCircle" href="/' + $channelLink + '"></a></div>');
	                    }
	                 
	                 
	
	              }
	
	              $filterChannel.click(function(event){
	                  $filterAlphabet.removeClass('current_type');
	                  $('div.filter_form a').removeClass('activeCategory');
	                  $currentType='';
	                  //$filterAlphabet.trigger('click');
	                  channelChange();
	
	                  // filter logo
	                  var channel_id = $(this).attr('href');
	                  channel_id = channel_id.replace('#', '');
	                  logoSwitcher.filter(channel_id, '#slider7');
	            });
	
	            $filterCategory.click(function(event){
	            event.preventDefault();
	            //var $currentId=$(this).attr('id');
	            var $currentClass=$(this).attr('class');
	
	                  if( $(this).hasClass('activeCategory'))
	                      {
	
	                      $(this).removeClass('activeCategory');
	                      }
	                  else
	                      {
	                           $filterCategory.removeClass('activeCategory');
	                          $(this).addClass('activeCategory');
	
	                      }
	                  channelChange();
	            });
	
	            // attempt to call Alphabet filter on every from change
	            $filterAlphabet.click(function(event){
	                  if ($(this).hasClass('noData')) {
	                      event.preventDefault();
	                      return;
	                  }
	                  //console.log(event.currentTarget);
	                  //$filterAlphabet.removeClass('current_type');
	
	                  $filterAlphabet.not(event.currentTarget + ".current_type");
	                  if($(event.currentTarget).hasClass('current_type'))
	                      {
	                          $(event.currentTarget).removeClass('current_type');
	                          $currentType='';
	                      }
	                  else
	                      {
	                          $filterAlphabet.removeClass('current_type');
	                          $(event.currentTarget).addClass('current_type');
	
	                          $currentType=$(event.currentTarget).attr('id');
	                      }
	
	                  channelChange();
	            });                      
	
	};

