var refInterval = new Number();
var curcnt = -1;
$(document).ready(function (){
initimg();
refInterval = setInterval(buildimg, 9000);
});
$(window).resize(function () {
initimg();
});
function initimg () {
var visimg = Math.floor(($("#ys").width() - 340) / 45);
var outp = 'Share your Stories
';
for(var x = 0; x < (visimg + 1); x++){
outp += '- <\/li>';
}
outp += '<\/ul>';
document.getElementById('ys').innerHTML = outp;
buildimg(true);
}
function buildimg (isfirst) {
$('li.ys').each(function (){
var fadeinterval=Math.floor(Math.random()*2300) + 1000;
var thisrnd =Math.floor(Math.random()*10);
if(thisrnd > 3 || isfirst){
curcnt++;
if(curcnt > ysimg.length || ysimg[curcnt] == undefined){
curcnt = 0;
}
var x = curcnt;
$(this).animate({ 'opacity': 0 }, fadeinterval, function () {
$(this).html('
');
$(this).animate({ 'opacity' : 1}, 3500 - fadeinterval);
});
}
});
}