// array of past polls; contains (in 2nd dimension): // 0 = poll id // 1 = question // 2 = total number of votes // 3 = string w/ start-end date period // 4 = answer array; contains: // the answers array contains an array for each possible answer to the poll. // the indexes of the 2nd dim. arrays correspond to the following values: // 0 = the answer itself // 1 = the number of votes for that answer // 2 = the percentage of all votes that this comprises // 3 = the id of the answer, in the database var polls = new Array(); polls[0] = new Array( 470, "Is the American Century ending?", 35, 'Nov 5th 2008 - Dec 5th 2008', "single-choice", new Array( new Array( "Yes", 23, '65.7%', 1977 ), new Array( "No", 11, '31.4%', 1978 ) )); polls[1] = new Array( 443, "Should biofuels and the renewables be critical components of U.S. energy policy?", 92, 'Apr 2nd 2008 - Apr 30th 2008', "single-choice", new Array( new Array( "Yes", 65, '70.7%', 1848 ), new Array( "No", 27, '29.3%', 1849 ) )); polls[2] = new Array( 413, "Can stricter law enforcement at the border and the workplace solve the U.S. immigration problem?", 61, 'Nov 7th 2007 - Dec 7th 2007', "single-choice", new Array( new Array( "Yes", 32, '52.5%', 1697 ), new Array( "No", 29, '47.5%', 1698 ) )); polls[3] = new Array( 353, "Does Affirmative Action in higher education really benefit minorities?", 95, 'Apr 4th 2007 - May 16th 2007', "single-choice", new Array( new Array( "Yes", 45, '47.4%', 1427 ), new Array( "No", 49, '51.6%', 1428 ) )); polls[4] = new Array( 294, "Should the U.S. "Stay the Course" for victory in Iraq?", 134, 'Nov 1st 2006 - Dec 1st 2006', "single-choice", new Array( new Array( "Yes", 52, '38.8%', 1150 ), new Array( "No", 81, '60.4%', 1151 ) )); polls[5] = new Array( 251, "Should the U.S. promote democracy in the Islamic world?", 253, 'Apr 4th 2006 - May 10th 2006', "single-choice", new Array( new Array( "Yes", 186, '73.5%', 966 ), new Array( "No", 64, '25.3%', 967 ) )); polls[6] = new Array( 208, "Should public schools teach Intelligent Design along with Evolution?", 532, 'Nov 2nd 2005 - Dec 1st 2005', "single-choice", new Array( new Array( "Yes", 150, '28.2%', 766 ), new Array( "No", 381, '71.6%', 767 ) )); var site = 'http://www.bu.edu/com/'; var no_cookies_msg = 'Sorry, you must have cookies enabled to view this page.'; //'; var selected_pid; // check site if (window.location.href.indexOf(site) == -1) { document.writeln( '

Error

This page is not authorized to show past polls for this account.

' ); } // check cookies if (cookietest()) { selected_pid = getCookie('QP-pid'); delCookie('QP-pid'); } else { document.writeln( '

'+no_cookies_msg+'

' ); } document.writeln( '' ); // if there is a selected poll, show it if (selected_pid != null) { var selected; // find the poll in the array for (var i = 0; i < polls.length; i++) { if (polls[i][0] == selected_pid) { selected = i; break; } } var question = polls[selected][1]; var vote_count = polls[selected][2]; var dates = polls[selected][3]; var poll_type = polls[selected][4]; var answers = polls[selected][5]; // array var multi_choice_msg = "Bar graphs show percent of "+vote_count+" multiple-choice responses"; document.writeln( '' ); document.writeln( '' ); document.writeln( ''); } else { document.writeln( '
'+question+'
This poll ran '+dates+'. '+vote_count+' votes were collected.
' ); // show each answer, as on regular polls page for (var j = 0; j < answers.length; j++) { var answer_text = answers[j][0]; var answer_votes = answers[j][1]; var answer_pct = answers[j][2]; var answer_id = answers[j][3]; document.writeln( '' ); document.writeln( '' ); if (j < answers.length - 1) { document.writeln( '' ); } } if (poll_type == 'multiple-choice') { document.writeln( '
'+answer_text+' - '+answer_votes+' vote'+(answer_votes==1?'':'s')+' / '+answer_pct+'
 
 
'+multi_choice_msg+'
 
' ); } } document.writeln( '
' ); // show list of polls for (var i = 0; i < polls.length; i++) { var pid = polls[i][0]; var question = polls[i][1]; var dates = polls[i][3]; document.writeln( '' ); } document.writeln( '
'+question+' ('+dates+')
' ); // functions // cookie get and set functions, from http://www.echoecho.com/jscookies02.htm function getCookie(NameOfCookie) { if (document.cookie.length > 0) { begin = document.cookie.indexOf(NameOfCookie+"="); if (begin != -1) { begin += NameOfCookie.length+1; end = document.cookie.indexOf(";", begin); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(begin, end)); } } return null; } function setCookie(NameOfCookie, value, expiredays, poll_type_handle) { var ExpireDate = new Date (); ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000)); document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()); } function delCookie (NameOfCookie) { if (getCookie(NameOfCookie)) { document.cookie = NameOfCookie + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } } // cookietest: tests if cookies are enabled function cookietest() { setCookie('QP_test', 'true', .25); if (getCookie('QP_test') == 'true') { delCookie('QP_test'); return true; } else return false; } // select poll: set pid cookie and reload page function select_poll( pid ) { setCookie( 'QP-pid', pid, '.04167' ); // set pid cookie; approx. 1 hour expiry window.location.reload(true); }