$(document).ready( function() {
	wss.init({
		logging: true
	});
	
	$('select.uniform').uniform();

	$('.deffered-display .image-box').live('mouseenter', function() {$(this).find('.play-show').fadeOut(120);});
	$('.deffered-display .image-box').live('mouseleave', function() {$(this).find('.play-show').fadeIn(840);});
	
	
	$.getFeed({
		// Le lien doit être changé
        url: GLOBAL_base_url + "proxy.php?PROXY_URL=http://www.allomatelas.com/allomatelastv/?feed=rss2",
        success: function(feed) {
            var html = '';
            
            for(var i = 0; i < feed.items.length && i < 4; i++) {
            	var random = getRandom(feed.items.length);
            	// wss.log(random);
                var item = feed.items[random];
                // wss.log(item.category);
                html += '<li class="deffered-display tv-spot"> \
                   <div class="image-box" style="cursor:pointer"><a target="_blank" href="' + item.link + '" class="tv-spot-title" rel="nofollow"><img src="http://www.allomatelas.com/allomatelastv/wp-content/uploads/' + item.comments.split(" ")[0]  + '.jpg" alt=" ' + item.title + '" /><img class="play-show" src="' + GLOBAL_img_url + 'home/tv-play-show.png" /></div><a> \
                   <a target="_blank" href="' + item.link + '" class="tv-spot-title">' + item.title + '</a> \
                   <em>' + item.category + '</em> \
                </li>';
            }
            
            jQuery('.allomatelas-tv-box div ul').html(html);
        }    
    });
    
    var used = [];
    window.used = used;
    var getRandom = function(max) {
    	this.max = max;
    	var random = Math.floor(Math.random()*11);
    	
    	if(used.indexOf(random) < 0 && random < this.max) {
    		used.push(random);
    		return random;
    	} else {
    		// wss.log('recursive');
    		return getRandom(this.max);
    	}
    }
});


