﻿function poptopic (url,title,size) {
	this.url = url; 
	this.title = title; 
	this.size = size; 
	this.anchor = function() { 
		return '<a href="'+url+'" class="poptopic'+size+'">'+title+'</a>&nbsp;';	
	};
};

function shuffletopics (v) {
	for(var j, x, i = v.length; i; j = parseInt(Math.random() * i), x = v[--i], v[i] = v[j], v[j] = x);    
	return v;
};

function writepoptopics (arrpoptopic,targetdiv) {
	arrpoptopic = shuffletopics(arrpoptopic);
	var max = (arrpoptopic.length > 15) ? 15 : arrpoptopic.length;
	for(var i = 0 ; i < max ; i++) {
		$('#'+targetdiv).html($('#'+targetdiv).html()+arrpoptopic[i].anchor() + '&nbsp;');
	}
};
