(function($){
$.fn.shuffle = function() {
var allElems = this.get(),
getRandom = function(max) {
return Math.floor(Math.random() * max);
},
shuffled = $.map(allElems, function(){
var random = getRandom(allElems.length),
randEl = $(allElems[random]).clone(true)[0];
allElems.splice(random, 1);
return randEl;
});
this.each(function(i){
$(this).replaceWith($(shuffled[i]));
});
return $(shuffled);
};
})(jQuery);
function padZeros(theNumber, max) {
var numStr = String(theNumber);
while (numStr.length < max) {
numStr = '0' + numStr;
}
return numStr;
}
function mysqlTimeStampToDate(timestamp) {
//function parses mysql datetime string and returns javascript Date object
//input has to be in this format: 2007-06-05
var regex=/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9])$/;
var parts=timestamp.replace(regex,"$1 $2 $3").split(' ');
return new Date(parts[0],parts[1]-1,parts[2]);
}
function setEventDays(date) {
var mysqldate = date.getFullYear() + '-' + padZeros(date.getMonth() + 1, 2) + '-' + padZeros(date.getDate(), 2);
if (jQuery.inArray(mysqldate, scheduledDays) >= 0)
return [true, ''];
else
return [false, ''];
}
function dateSelected(dateText, inst) {
window.location = "/listings.php?spec_date=" + dateText;
}
function swapfeatured() {
var showing = $('.featured-block').find('div.featuredevent:visible');
$(showing).hide();
if ($(showing).next('div').length)
$(showing).next('div').fadeIn(350);
else
$('.featuredevent').eq(0).fadeIn(350);
// make sure that atleast one div is visible for the second one
if (!$('.featured-block').eq(1).find('.featuredevent:visible').length) {
$('.featured-block').eq(1).find('.featuredevent').eq(0).fadeIn(350);
}
}
$(function() {
if (navigator.geolocation) {
$('.right #box-1 h1').append('
');
$('#browserloc').click(function() {
navigator.geolocation.getCurrentPosition(function(position) {
var lat = position.coords.latitude;
var lon = position.coords.longitude;
// Do a post and store location info in session for nearby locations
$.post('lalo-session.php', { lat: lat, lon: lon }, function() { window.location = '/'; } );
});
});
}
$jScroller.add("#home-events-wrapper", "#home-events", "up", 1.2);
$jScroller.start();
$('#testimonials').cycle({timeout: 10000, speed: 2500});
$('#connectfb').click(function(e) {
e.preventDefault();
FB.login(
function() {
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
location.href='/connect-facebook.php?a=callback';
}
});
},
{scope: 'email,publish_actions'}
);
});
//$('div.featuredevent').hide().shuffle().eq(0).show();
var timer = null;
if ($('div.featuredevent').length > 1) {
timer = setInterval("swapfeatured()", 9000);
$('.featured-block').append('
');
$('.nextfeatured').hide().click(function() {
clearInterval(timer);
console.log($(this).parent());
$(this).parent().find('div.featuredevent:visible').stop();
var showing = $(this).parent().find('div.featuredevent:visible').hide();
if ($(showing).next('div').length)
$(showing).next('div').fadeIn(350);
else
$(this).parent().find('div.featuredevent').eq(0).fadeIn(350);
//swapfeatured(this);
timer = setInterval("swapfeatured()", 9000);
});
$('.featured-block').hover(
function() {
$(this).find('.nextfeatured').fadeIn(350);
},
function() {
$(this).find('.nextfeatured').fadeOut(350);
}
);
}
});