$(document).ready(function()
{
    $("#tabs").tabs();
    
    $(".ui-tabs-nav a").click(function()
    {
    	var mydiv = $(this).attr("href");
    	
    	switch(mydiv)
    	{
    		case "#2":
    		  tp = "exclusive";
    		break;
    		case "#3":
    		  tp = "email";
    		break;
    		case "#4":
    		  tp = "rss";
    		break;
    		case "#5":
    		  tp = "twitter";
    		break;
    	}	
    	
    	//Only run once to filter
    	if ($("div"+mydiv).html()=="")
    	{
    		  		 $("div"+mydiv).html('<ul class="results" style="border-top: 0px none; margin-top: 5px;">'+fil_ter(tp)+'</ul>');
    	}

    });
    
    
    function fil_ter(tp)
    {
    	    var myarr = "";
    			$(".results li").each(function()
          {                                   	  
              if ($(this).hasClass(tp)) 
              { 
                  myarr += '<li class="listing '+tp+'">'+$(this).html()+'</li>';
              }
                                                       	     
          });
          
          return myarr;
    }

});
