Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as JavaScript by aaaa ( 15 years ago )
var background = (function() {
var
$obj = $('body:first'),
dir = 'photos/',
size = backgrounds.length || 0,
current = 0,
cookie_vars = {
path: '/',
domain: 'localhost'
};
go = function(i) {
if (i === size) current = 0;
else if (i < 0) current = size-1;
else current = i;
var id = $obj.hasClass('subsite') ? 1 : 0;
$obj.css('background-image', 'url(' + dir + backgrounds[current][id] + ')');
$.cookie('bg_id', current, cookie_vars);
},
randomImage = function() {
return Math.round(Math.random() * (size -1));
}
return {
isInit: function() {
var result = (typeof backgrounds == 'object');
if (result) {
if ($.cookie('bg_id') != null) {
go( parseInt($.cookie('bg_id')) );
} else {
go( randomImage() );
}
}
return result;
},
previous: function() {
go(--current);
return false;
},
next: function() {
go(++current);
return false;
}
};
}());
Revise this Paste