var CoverNav = { 
  buildURLAndForward : function(tabName, subTabName) {
     switch (tabName) {
     case 'popularity':
       if (typeof subTabname == 'undefined') {
	 subTabname = 'rated';
       }
       sortScope = $('coverSortScope').getValue();
       sortInterval = $('coverSortInterval').getValue();
       if (ufName.length == 0 && sortScope == 'favorites') {
	 if (pageUfName.length == 0)
	   openAjaxLogin(409);
	 else 
	   url = '/' + tabName + '/' + subTabName + '/all/' + sortInterval;
	 $('coverSortScope').value = 'all';
       } else if (sortScope == 'favorites') {
	 url = '/' + tabName + '/' + subTabName + '/favorites/' + ufName + '/' + sortInterval;
       } else {
	 url = '/' + tabName + '/' + subTabName + '/' + sortScope  + '/' + sortInterval;
       }
       // 20090414 aabelard -- having repeated /'s in the url causes SEO rewrites to fail #2516
       url = url.replace( '//', '/' );
       if (typeof url != 'undefined') {
	 window.location = url;
       }
       break;
     case 'most_recent':
     if (typeof subTabname == 'undefined') {
	 subTabname = 'posts';
       }
       sortScope = $('coverSortScope').getValue();
       if (ufName.length == 0 && sortScope == 'favorites') {
	 if (pageUfName.length == 0)
	   openAjaxLogin(409);
	 else 
	   url = '/' + tabName + '/' + subTabName + '/all';
	 $('coverSortScope').value = 'all';
       } else if (sortScope == 'favorites') {
	 url = '/' + tabName + '/' + subTabName + '/favorites/' + ufName;
       } else {
	 url = '/' + tabName + '/' + subTabName + '/' + sortScope;
       }
       if (typeof url != 'undefined') {
	 window.location = url;
       }
       break;

     case 'editors_pick':
       sortScope = $('coverSortScope').getValue();
       if (ufName.length == 0 && sortScope == 'favorites') {
	 if (pageUfName.length == 0)
	   openAjaxLogin(409);
	 else 
	   url = '/' + tabName + '/' + sortScope;
	 $('coverSortScope').value = 'all';
       } else if (sortScope == 'favorites') {
	 url = '/' + tabName + '/favorites/' + ufName;
	 url = '/' + tabName + '/' + sortScope  + '/' + ufName;
       } else {
	 url = '/' + tabName + '/' + sortScope;
       }
       if (typeof url != 'undefined') {
	 window.location = url;
       }
       break;

     }
  }
}
