
var com;if (!com) {com = {};} else if (typeof com != "object") {throw new Error("Non-object \"com\" is already defined.");}if (!com.civicscience) {com.civicscience = {};} else if (typeof com.civicscience != "object") {throw new Error("Non-object \"com.civicscience\" is already defined.");}if (!com.civicscience.ballotbox) {com.civicscience.ballotbox = {};} else if (typeof com.civicscience.ballotbox != "object") {throw new Error("Non-object \"com.civicscience.ballotbox\" is already defined.");}(function() {var NAMESPACE = com.civicscience.ballotbox;var Request = (function() {var reqId = 0;var handlerMap = {};var constructor = function(url, handler) {this.send = function() {reqId++;handlerMap[reqId] = handler;if (url.indexOf("?") == -1) {url += "?";} else {url += "&";}url += "reqId=" + escape(reqId);url += "&responseHandler=com.civicscience.ballotbox.Request.acceptResponse";var script = document.createElement("SCRIPT");script.type = "text/javascript";script.src = url;document.body.appendChild(script);};};constructor.acceptResponse = function(response) {if (response.reqId) {var handler = handlerMap[response.reqId];delete handlerMap[response.reqId];if (typeof handler == "function") {handler(response.data);}}};return constructor;})();NAMESPACE.Request = Request;var Events = {addListener: function(obj, type, listener) {var f = function(event) {listener.apply(obj, [event || window.event]);};if (obj.addEventListener) {obj.addEventListener(type, f, false);} else if (obj.attachEvent) {obj.attachEvent("on" + type, f);} else {var orig = obj["on" + type];obj["on" + type] = function(event) {if (typeof orig == "function") {orig.apply(obj, [event || window.event]);}f(event);};}} };NAMESPACE.Events = Events;var DOM = {addClass: function(elt, cl) {if (typeof elt.className == "string") {var classes = elt.className.split(/\s+/);var i;for (i = 0; i < classes.length && classes[i] != cl; i++);if (i == classes.length) {classes.push(cl);elt.className = classes.join(" ");}}}, removeClass: function(elt, cl) {if (typeof elt.className == "string") {var classes = elt.className.split(/\s+/);var i;for (i = 0; i < classes.length; i++) {if (classes[i] == cl) {classes.splice(i--, 1);}}elt.className = classes.join(" ");}} }; var Widget = function(containerElt, voteBtn) {var THIS = this;var bodyElt = (function() {var re = /\bpoll_body\b/;var elts = containerElt.getElementsByTagName("div");var i;for (i = 0; i < elts.length; i++) {if (re.test(elts[i].className)) {return elts[i];}}return null;})();if (!bodyElt) {return;}this.getBodyElement = function() {return bodyElt;};var progressElt = (function() {var re = /\bpoll_progress\b/;var elts = containerElt.getElementsByTagName("div");var i;for (i = 0; i < elts.length; i++) {if (re.test(elts[i].className)) {return elts[i];}}return null;})();this.getProgressElement = function() {return progressElt;};var bodyLoadingClassIsEnabled = false;this.setBodyLoadingClassIsEnabled = function(enabled) {bodyLoadingClassIsEnabled = !!enabled;}; this.setBodyIsLoading = function(loading) {if (!loading) {DOM.removeClass(bodyElt, "loading");} else if (bodyLoadingClassIsEnabled) {DOM.addClass(bodyElt, "loading");}}; this.getQuestionsUrl = "";this.getResultsUrl = "";this.putResponsesUrl = "";this.isLongForm = false;this.isOptOutUser = false;var receivedQidList = [];this.getReceivedQidList = function() {return receivedQidList;}; function receivedQuestion(qid) {receivedQidList.unshift(qid);var i;for (i = 1; i < receivedQidList.length; i++) {if (receivedQidList[i] == qid) { receivedQidList.splice(i--, 1);}}if (receivedQidList.length > 30) {receivedQidList.pop();}} var LOCAL_NAME = "__iqpbb";function getLocalId() {var id = null;if (!THIS.isOptOutUser) {try {if ("localStorage" in window) {var storage = window["localStorage"];if (storage != null) {id = storage.getItem(LOCAL_NAME);if (id == null) {function r() {return Math.floor(Math.random() * 4294967296);}id = r() + "." + r();storage.setItem(LOCAL_NAME, id);}}}} catch (e) {}}return id;} function start() {var id = getLocalId();if (id) {THIS.getQuestionsUrl
+= (THIS.getQuestionsUrl.indexOf("?") == -1 ? "?" : "&")
+ "al="
+ encodeURIComponent(id);}var qp = new QuestionPager(THIS, voteBtn);qp.addReceivedQuestionListener(receivedQuestion);qp.addFinishListener(showResults);qp.run();} var isRunning = false;this.run = function() {if (isRunning) {return;}isRunning = true;start();}; this.restart = function() {if (isRunning) { var qurl = this.getQuestionsUrl;qurl += qurl.indexOf("?") == -1 ? "?" : "&";qurl += "restart=1";this.getQuestionsUrl = qurl;this.getResultsUrl = "";this.putResponsesUrl = "";start();}}; var showResults = function() {if (THIS.getResultsUrl) {var url = THIS.getResultsUrl;if (THIS.isLongForm) {url += url.indexOf("?") == -1 ? "?" : "&";url += "form=long";}new Request(url, function(response) {THIS.setBodyIsLoading(false);if (response.results) {var pobjList = response.results.pages;if (pobjList) {var first = null;var prev = null;var i;for (i = 0; i < pobjList.length; i++) {var pobj = pobjList[i];if (pobj.html) {var prev = new ResultsPage(THIS, pobj.html, prev);if (first == null) {first = prev;}}}if (first == null) {while (bodyElt.firstChild) {bodyElt.removeChild(bodyElt.firstChild);}} else {first.show();}}}}).send();THIS.setBodyIsLoading(true);}}; };NAMESPACE.Widget = Widget;var VoteButton = function(html) {var THIS = this;var rootElt = document.createElement("div");rootElt.innerHTML = html;this.getRootElement = function() {return rootElt;};var voteBtn = null;(function() {var inputs = rootElt.getElementsByTagName("input");var i;for (i = 0; i < inputs.length && voteBtn == null; i++) {if (/\bvote\b/.test(inputs[i].className)) {voteBtn = inputs[i];}}if (voteBtn == null) {throw new Error("missing vote button control");}})();this.getButton = function() {return voteBtn;};};NAMESPACE.VoteButton = VoteButton;var QuestionPager = function(widget, voteBtn) {var THIS = this;var MAX_PAGE_SIZE = widget.isLongForm ? Number.MAX_VALUE : 1;var qobjList = [];var qobjIndex = 0;var askedList = [];var isVoting = false;var receivedQuestionListeners = [];this.addReceivedQuestionListener = function(f) {if (typeof f == "function") {receivedQuestionListeners.push(f);}}; var run = function() {var origIndex = qobjIndex;var bodyElt = widget.getBodyElement();while (bodyElt.firstChild) {bodyElt.removeChild(bodyElt.firstChild);}askedList = [];while (qobjIndex < qobjList.length) {var qobjMax = Math.min(qobjList.length, qobjIndex + MAX_PAGE_SIZE);var asked = false;while (qobjIndex < qobjMax) {var qobj = qobjList[qobjIndex++];var question = null;switch (qobj.type) {case "radio":question = new RadioQuestion(widget, qobj.html);break;}if (question != null) {if (MAX_PAGE_SIZE == 1) {var progElt = widget.getProgressElement();if (progElt != null) {progElt.className = "poll_progress current_" + qobjIndex + " total_" + qobjList.length;}}question.ask();askedList.push(question);}}if (askedList.length > 0) {widget.getBodyElement().appendChild(voteBtn.getRootElement());isVoting = false;return;}}if (MAX_PAGE_SIZE == 1) {var progElt = widget.getProgressElement();if (progElt != null) {progElt.className = "poll_progress";}}if (origIndex == 0 && qobjList.length != 0) {finish();} else if (widget.getQuestionsUrl) {var url = widget.getQuestionsUrl;var xqids = widget.getReceivedQidList();if (xqids.length > 0) {url += url.indexOf("?") == -1 ? "?" : "&";url += "xq=." + xqids.join(".");}new Request(url, function(response) {widget.setBodyIsLoading(false);qobjList = response.questions || [];if (response.session) {widget.getQuestionsUrl = response.session.getQuestionsUrl;widget.getResultsUrl = response.session.getResultsUrl;widget.putResponsesUrl = response.session.putResponsesUrl;}if (qobjList.length == 0) {finish();} else {var i;for (i = 0; i < receivedQuestionListeners.length; i++) {var j;for (j = 0; j < qobjList.length; j++) {receivedQuestionListeners[i](qobjList[j].id);}}qobjIndex = 0;run();}}).send();widget.setBodyIsLoading(true);}}; this.run = run;var vote = function() {if (!isVoting && widget.putResponsesUrl) {var params = "";var i;for (i = 0; i < askedList.length && askedList[i].isVotable(); i++) {if (params) {params += "&";}params += askedList[i].getUrlParams();}if (i == askedList.length) {var url = widget.putResponsesUrl;if (params != "") {url += url.indexOf("?") == -1 ? "?" : "&";url += params;}new Request(url, function(response) {if (response.ok) {if (response.session) {widget.getQuestionsUrl = response.session.getQuestionsUrl;widget.getResultsUrl = response.session.getResultsUrl;widget.putResponsesUrl = response.session.putResponsesUrl;}run();} else {isVoting = false;}}).send();isVoting = true;}}}; Events.addListener(voteBtn.getButton(), "click", vote);var finishListeners = [];this.addFinishListener = function(f) {if (typeof f == "function") {finishListeners.push(f);}};var finish = function() {var i;for (i = 0; i < finishListeners.length; i++) {finishListeners[i].apply(THIS, []);}}; }; var Question = function(widget, html) {var rootElt = document.createElement("div");rootElt.innerHTML = html;this.getRootElement = function() {return rootElt;};this.getUrlParams = function() {return "";};this.isVotable = function() {return false;};this.ask = function() {widget.getBodyElement().appendChild(rootElt);};}; var RadioQuestion = function(widget, html) {Question.apply(this, [widget, html]);var THIS = this;var radioBtns = [];(function() {var inputs = THIS.getRootElement().getElementsByTagName("input");var i;for (i = 0; i < inputs.length; i++) {if (inputs[i].type == "radio") {radioBtns.push(inputs[i]);}}})();this.getUrlParams = function() {var params = "";var i;for (i = 0; i < radioBtns.length && !params; i++) {if (radioBtns[i].checked) {params = radioBtns[i].value;}}return params;};this.isVotable = function() {var i;for (i = 0; i < radioBtns.length && !radioBtns[i].checked; i++);return i < radioBtns.length;};}; var ResultsPage = function(widget, html, prevPage) {var THIS = this;this.prevPage = prevPage;this.nextPage = null;if (prevPage != null) {prevPage.nextPage = this;}var rootElt = document.createElement("div");rootElt.innerHTML = html;this.show = function() {var container = widget.getBodyElement();while (container.firstChild) {container.removeChild(container.firstChild);}container.appendChild(rootElt);};var prevBtn = null;var nextBtn = null;(function() {var inputs = rootElt.getElementsByTagName("input");var i;for (i = 0; i < inputs.length; i++) {if (/\bprevious\b/.test(inputs[i].className)) {prevBtn = inputs[i];} else if (/\bnext\b/.test(inputs[i].className)) {nextBtn = inputs[i];}}})();if (prevBtn) {Events.addListener(prevBtn, "click", function() {if (THIS.prevPage) {THIS.prevPage.show();}});}if (nextBtn) {Events.addListener(nextBtn, "click", function() {if (THIS.nextPage) {THIS.nextPage.show();} else {widget.restart();}});}}; })();(function() {var BALLOTBOX = com.civicscience.ballotbox;var onload = function() {var linkElt = document.createElement("link");linkElt.rel = "stylesheet";linkElt.type = "text/css";linkElt.href = "https:\/\/civicscience-css.s3.amazonaws.com\/clients\/dallas_news\/dallas_news_620px.css";document.getElementsByTagName("head")[0].appendChild(linkElt);var container = document.getElementById("06cc0054-2f6d-bab4-0959-a68d11b6caa6");if (container) {container.innerHTML = "<div class=\"civicscience ballotbox\">\n    <div class=\"poll_title\">What do you think? <span class=\"what\" title=\"This poll is a tool to help us understand our readers better. All answers are anonymous. The collective responses help our advertisers learn about our audience, and let you see where you stand compared with other readers.\">What's This?<\/span><\/div>\n    <div class=\"poll_body\"><\/div>\n        <div class=\"poll_progress\"><\/div>\n            <div class=\"poll_footer\"><\/div>\n    <\/div>";var voteBtn = new BALLOTBOX.VoteButton("<div class=\"buttons\">\n    <input type=\"button\" class=\"vote\" value=\"Submit\" \/>\n<\/div>\n");var widget = new BALLOTBOX.Widget(container, voteBtn);widget.isLongForm = false;widget.isOptOutUser = false;widget.getQuestionsUrl = "https:\/\/www.civicscience.com\/widget\/jspoll\/getQuestions?tgt=1450";widget.setBodyLoadingClassIsEnabled(true);widget.run();}};BALLOTBOX.Events.addListener(window, "load", onload); })();