$.tabs = function(containerId, start) {
var ON_CLASS = 'on';
var id = '#' + containerId;
var i = (typeof start == "number") ? start - 1 : 0;
$(id + '>div.tab-content div:eq(' + i + ')').css({display:"block"});
// $(id + '>ul>li:nth-child(' + (i+1) + ')').addClass(ON_CLASS);
$(id + '>ul>li>a').click(function() {
var re = /([_\-\w]+$)/i;
var target = $('#' + re.exec(this.href)[1]);
if (target.size() > 0) {
$(id + '>div.access-search-tab:visible').css({display:"none"});
target.css({display:"block"});
$(id + '>ul>li').removeClass(ON_CLASS).addClass('off');
$(this.parentNode).addClass(ON_CLASS);
$(this.parentNode).removeClass('off');
}
return false;
});
};
function li_columns(selector, columns) {
var total = $(selector).length;
var num = Math.floor(total / columns);
var extras = total % columns;
var start = 0;
for(var i = 0; i < columns; i++) {
var end = start + num;
if(extras) { end += 1; extras--; }
$(selector).slice(start, end).wrapAll('
');
start = end + 1;
}
}
$(document).ready(function() {
$.tabs('access-search-container');
$.tabs('tab-things');
$.tabs('tab-restaurants');
$.tabs('tab-movies');
$('').appendTo('div#movies-title div.tab-content');
$('div#mvIncMovies select option').slice(0,1).each(function() {
$(this).text('Movies');
});
$('div#mvIncMovies select option').slice(1).each(function() {
$('div#movies-title ul').append('' + $(this).text() + '');
});
$('div#mvIncTheaters select option').slice(0,1).each(function() {
$(this).text('Theaters');
});
$('div#mvIncCity select option').slice(0,1).each(function() {
$(this).text('Neighborhoods');
});
$('').appendTo('div#movies-theatre div.tab-content');
$('div#mvIncTheaters select option').slice(1).each(function() {
$('div#movies-theatre ul').append('' + $(this).text() + '');
});
// $('div#tab-things ul.tab-list, div#tab-restaurants ul.tab-list').each(function() {
// if ($(this).children().size() > 34) {
// $(this).children().slice(34).hide();
// $(this).append('more ↓')
// }
// });
$('div#tab-movies ul.tab-list').each(function() {
if ($(this).children().size() > 14) {
$(this).children().slice(14).hide();
$(this).append('more ↓')
}
});
$('li a.more').bind('click', function() {
$(this).parent().parent().children().show();
$(this).parent().parent().append('fewer ↑');
$(this).parent().hide();
$('div.access-search-tab').css('height','auto');
$('div#tab-things li a.less, div#tab-restaurants li a.less').bind('click', function() {
$(this).parent().parent().children().hide().slice(0,34).show();
$(this).parent().parent().find('a.more').parent().show();
$(this).parent().remove();
$('div.access-search-tab').css('height','165px');
$(this).unbind();
return false;
});
$('div#tab-movies li a.less').bind('click', function() {
$(this).parent().parent().children().hide().slice(0,14).show();
$(this).parent().parent().find('a.more').parent().show();
$(this).parent().remove();
$('div.access-search-tab').css('height','165px');
$(this).unbind();
return false;
});
return false;
});
li_columns('div#things-activity ul.tab-list li', 7);
li_columns('div#things-neighborhood ul.tab-list li', 7);
li_columns('div#restaurants-cuisine ul.tab-list li', 7);
li_columns('div#restaurants-neighborhood ul.tab-list li', 7);
// li_columns('div#movies-title ul.tab-list li', 7);
// li_columns('div#movies-theatre ul.tab-list li', 7);
/*hides overlady and fades in content*/
$("#access-search-overlay").fadeOut();
$("#access-search-container .tab-content").fadeIn();
});