/* poll script */
function renderPoll(id) {
var h=[];
if (id===null || id===undefined || id==='') {
id = getCookie('Sanquin_Poll');
}
if (poll.pollId == id) {
h=renderGrafic(h);
} else {
h=renderQuestion(h);
}
document.write(h.join(''));
}
function renderQuestion(h) {
var i = h.length;
h[i++] = '
';
return h;
}
function renderGrafic(h) {
var i=h.length;
h[h.length] = 'grafic not ready yet';
h[i++] = '';
h[i++] = '
';
h[i++] = poll.question;
h[i++] = '
';
h[i++] = '
';
poll.id = 0;
h[i++] = '
';
for (var n in poll.answers) {
if (poll.answers.hasOwnProperty(n)) {
var p = Math.round(100 * poll.answers[n].c / poll.total, 0);
h[i++] = '';
h[i++] = '| ';
h[i++] = poll.answers[n].q + ": ";
h[i++] = ' | ';
h[i++] = '';
h[i++] = ' ';
h[i++] = Math.round(100 * poll.answers[n].c / poll.total, 0) + "%";
h[i++] = ' | ';
h[i++] = '
';
poll.id++;
}
}
h[i++] = '
';
h[i++] = '
';
h[i++] = 'Aantal responses: ' + poll.total;
h[i++] = '
';
h[i++] = '
';
h[i++] = '
';
return h;
}
function doOnSubmitPoll() {
setCookie('Sanquin_Poll', poll.pollId);
}
function setCookie(c_name,value,expiredays) {
debugger;
var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ '=' +escape(value)+((expiredays==null) ? '' : ';expires='+exdate.toGMTString());
}
function getCookie(c_name) {
debugger;
if (document.cookie) {
var i = document.cookie.indexOf(c_name);
if (i==-1) {
return '';
} else {
var cB = document.cookie.indexOf('=', i) +1;
var cE = document.cookie.indexOf(';', cB);
if (cE==-1) {
cE = document.cookie.length;
}
return document.cookie.substring(cB, cE);
}
} else {
return '';
}
}