if(typeof Pierre=="undefined"){var Pierre={}}else{throw"Pierre is already defined."}Pierre.namespace=function(){var A=arguments,E=null,C,B,D;for(C=0;C<A.length;C=C+1){D=A[C].split(".");E=Pierre;for(B=(D[0]=="Pierre")?1:0;B<D.length;B=B+1){E[D[B]]=E[D[B]]||{};E=E[D[B]]}}return E};Pierre.namespace("Pierre.core");Pierre.namespace("Pierre.widgets");String.prototype.startsWith=function(A){return(this.substr(0,A.length)==A)};String.prototype.endsWith=function(A){return(this.substr(this.length-A.length)==A)};String.prototype.trim=function(){return(this.replace(/^\s*|\s*$/g,""))};String.prototype.urlencode=function(){return encodeURIComponent(this)};isset=function(A){if(typeof (A)=="undefined"){return false}else{return true}};Pierre.core.URL=function(A){this.href=null;this.protocol=null;this.location=null;this.host=null;this.nodes=new Array();this.domain=null;this.fullPath=null;this.path=null;this.queryString=null;this.params=new Array();this.anchorNames=null;if(A){this.href=A;this.protocol=this.href.substr(0,this.href.indexOf("//")+2);this.location=this.href.replace(this.protocol,"");this.host=this.location.substr(0,this.location.indexOf("/"));this.fullPath=this.location.substr(this.location.indexOf("/"));this.path=this.fullPath.substr(0,this.fullPath.indexOf("?"));this.nodes=this.host.split(".");if(this.nodes.length>1){this.domain=this.nodes[this.nodes.length-2]+"."+this.nodes[this.nodes.length-1]}if(this.fullPath.indexOf("#")>=0){this.anchorNames=this.fullPath.substr(this.fullPath.indexOf("#")+1)}if(this.fullPath.indexOf("?")>=0){if(this.fullPath.indexOf("#")>=0){this.queryString=this.fullPath.substring(this.fullPath.indexOf("?")+1,this.fullPath.indexOf("#"))}else{this.queryString=this.fullPath.substr(this.fullPath.indexOf("?")+1)}var D=this.queryString.split("&");for(var B=0;B<D.length;B++){var C=D[B].split("=");if(C.length==1){this.params[C[0]]=null}else{this.params[C[0]]=C[1]}}}if(this.fullPath.indexOf("#")>=0){this.anchorNames=this.fullPath.substr(this.fullPath.indexOf("#")+1)}}this.isset=function(E){return isset(this.params[E])};this.getParam=function(E){if(this.params[E]){return this.params[E]}else{return null}}};Pierre.core.UserAgent=new function(){var C={ie:0,opera:0,gecko:0,webkit:0,mobile:null,air:0};var B=navigator.userAgent,A;if((/KHTML/).test(B)){C.webkit=1}A=B.match(/AppleWebKit\/([^\s]*)/);if(A&&A[1]){C.webkit=parseFloat(A[1]);if(/ Mobile\//.test(B)){C.mobile="Apple"}else{A=B.match(/NokiaN[^\/]*/);if(A){C.mobile=A[0]}}A=B.match(/AdobeAIR\/([^\s]*)/);if(A){C.air=A[0]}}if(!C.webkit){A=B.match(/Opera[\s\/]([^\s]*)/);if(A&&A[1]){C.opera=parseFloat(A[1]);A=B.match(/Opera Mini[^;]*/);if(A){C.mobile=A[0]}}else{A=B.match(/MSIE\s([^;]*)/);if(A&&A[1]){C.ie=parseFloat(A[1])}else{A=B.match(/Gecko\/([^\s]*)/);if(A){C.gecko=1;A=B.match(/rv:([^\s\)]*)/);if(A&&A[1]){C.gecko=parseFloat(A[1])}}}}}};Pierre.core.Extend={};Pierre.core.Extend._ADD=["toString","valueOf"];Pierre.core.Extend._hasOwnProperty=(Object.prototype.hasOwnProperty)?function(A,B){return A&&A.hasOwnProperty(B)}:function(A,B){return typeof A[B]!="undefined"&&A.constructor.prototype[B]!==A[B]};Pierre.core.Extend._IEEnumFix=(Pierre.core.UserAgent.ie)?function(C,B){for(var A=0;A<this._ADD.length;A=A+1){var E=this._ADD[A],D=B[E];if(typeof D==="function"&&D!=Object.prototype[E]){C[E]=D}}}:function(){};Pierre.core.Extend.extend=function(D,E,C){if(!E||!D){throw new Error("extend failed, please check that all dependencies are included.")}var B=function(){};B.prototype=E.prototype;D.prototype=new B();D.prototype.constructor=D;D.superclass=E.prototype;if(E.prototype.constructor==Object.prototype.constructor){E.prototype.constructor=E}if(C){for(var A in C){if(Pierre.core.Extend._hasOwnProperty(C,A)){D.prototype[A]=C[A]}}Pierre.core.Extend._IEEnumFix(D.prototype,C)}};Pierre.extend=Pierre.core.Extend.extend;Pierre.core.Loader=function(){this.files=new Array();this.addScript=function(C,B){var A=new Pierre.core.Loader.File("script",C,B);A.load();this.files[this.files.length]=A;return A};this.addCSS=function(C,B){var A=new Pierre.core.Loader.File("link",C,B);A.load();this.files[this.files.length]=A;return A};this.isReady=function(){for(var A=0;A<this.files.length;A++){if(this.files[A].isRequired&&this.files[A].state!="loaded"){return false}}return true}};Pierre.core.Loader.File=function(A,C,B){if((A!="script"&&A!="link")||!C.trim()){return null}this.type=A;this.isRequired=B;this.state="init";this.onReady=null;this.el=document.createElement(this.type);if(this.type=="script"){this.el.type="text/javascript";this.el.src=C}else{if(this.type=="link"){this.el.type="text/css";this.el.rel="stylesheet";this.el.href=C}}this.load=function(){var E=this._getDocumentHead();E.appendChild(this.el);var D=this;D.el.onload=D.el.onreadystatechange=function(){if(D.state!="loaded"&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){D.state="loaded";if(D.onReady){D.onReady.callback.apply(D.onReady.scope)}}else{D.state=this.readyState}};return this};this._getDocumentHead=function(){var D=document.getElementsByTagName("head");if(D&&D.length>0){D=D[0]}else{D=document.body.parentNode.appendChild(document.createElement("head"))}return D}};Pierre.core.Library=function(){this.name=null;this.init=function(C){this.name=C;try{var A=Pierre.adapters[C];this.Ajax=new Pierre.adapters.interfaces.Ajax(C,A);this.Dom=new Pierre.adapters.interfaces.Dom(C,A);this.Event=new Pierre.adapters.interfaces.Event(C,A);this.Util=new Pierre.adapters.interfaces.Util(C,A)}catch(B){}}};Pierre.core.Session=function(){this.url=new Pierre.core.URL(location.href);this.loader=new Pierre.core.Loader();this.lib=new Pierre.core.Library();this.widgets={};this.initialize={};plib=this.lib;this.init=function(config,callback){this.config=config||{};if(this.config.loader){if(this.config.loader.loadExampleCSS){this._loadExampleCSS()}if(this.config.loader.library){this._loadLibrary()}if(this.config.loader.useRollup){this._loadRollup()}else{this._loadEach()}this._loadWidgets()}this._whenReady(callback,0)};this._loadLibrary=function(){if(this.config.loader.library=="yui"&&typeof YAHOO=="undefined"){this.loader.addScript("http://yui.yahooapis.com/combo?2.5.1/build/utilities/utilities.js&2.5.1/build/selector/selector-beta-min.js",true)}else{if(this.config.loader.library=="jquery"&&typeof jQuery=="undefined"){this.loader.addScript("http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js",true)}}};this._loadExampleCSS=function(){if(this.config.loader.useRollup){this.loader.addCSS("http://lib.newsvine.com/Pierre/resources/css/pierre-lib.css")}else{this.loader.addCSS("http://lib.newsvine.com/Pierre/resources/css/reset.css");this.loader.addCSS("http://lib.newsvine.com/Pierre/resources/css/default.css");this.loader.addCSS("http://lib.newsvine.com/Pierre/resources/css/global.css")}this.loader.addCSS("example.css")};this._loadRollup=function(){this.loader.addScript("http://lib.newsvine.com/Pierre/adapters/"+this.config.loader.library+"/"+this.config.loader.library+"-lib.js",true);this.loader.addScript("http://lib.newsvine.com/Pierre/adapters/interfaces/pierre-lib.js",true)};this._loadEach=function(){this.loader.addScript("http://lib.newsvine.com/Pierre/adapters/"+this.config.loader.library+"/Ajax.js",true);this.loader.addScript("http://lib.newsvine.com/Pierre/adapters/interfaces/Ajax.js",true);this.loader.addScript("http://lib.newsvine.com/Pierre/adapters/"+this.config.loader.library+"/Dom.js",true);this.loader.addScript("http://lib.newsvine.com/Pierre/adapters/interfaces/Dom.js",true);this.loader.addScript("http://lib.newsvine.com/Pierre/adapters/"+this.config.loader.library+"/Event.js",true);this.loader.addScript("http://lib.newsvine.com/Pierre/adapters/interfaces/Event.js",true)};this._onReady=function(callback){var lib=this.config.loader&&this.config.loader.library?this.config.loader.library:this.config.library;this.lib.init(lib);this._initWidgets();if(callback){plib.Event.onDOMReady(function(){callback.apply(Pierre.session)})}};this._whenReady=function(callback,timer){var increment=10;var timeout=1000;if(this.loader.isReady()){this._onReady(callback)}else{if(timer<timeout){setTimeout(function(){Pierre.session._whenReady(callback,timer+increment)},increment)}}};this._loadWidgets=function(){if(this.config.widgets){for(var name in this.config.widgets){var src="http://lib.newsvine.com/Pierre/"+this.config.widgets[name].path;this.loader.addScript(src,true)}}};this._initWidgets=function(){if(this.config.widgets){for(var name in this.config.widgets){var widget=this.config.widgets[name];if(widget.init){var evilEval=name+".Initialize.apply(this);";eval(evilEval)}}}}};Pierre.session=new Pierre.core.Session();if(typeof Pierre.adapters=="undefined"){Pierre.namespace("adapters")}if(typeof Pierre.adapters.jquery=="undefined"){Pierre.namespace("adapters.jquery")}Pierre.adapters.jquery.Ajax=function(){this.ajax=function(A){return $.ajax(A)};this.serializeForm=function(A){return jQuery(A).serialize()};this.request=function(D,B,A,C){if(!A){A={}}A.type=D;A.url=B;A.data=C;A.error=A.failure;A.complete=A.success;A.success=null;return this.ajax(A)};this.formRequest=function(C,B,A,D){var D=jQuery(C).serialize()+(D?"&"+D:"");return this.request(C.method||"POST",B,A,D)};this.getRequest=function(B,A){if(!A){A={}}A.url=B;A.type="GET";A.dataType="script";if(A.success&&A.success.name&&A.success.scope&&A.success.callback){var C=A.success.name+"="+this.newCallback(A.success.scope,A.success.callback);A.url+=A.url.indexOf("?")>0?"&"+C:"?"+C;A.success=null}return jQuery.ajax(A)}};if(typeof Pierre.adapters=="undefined"){Pierre.namespace("adapters")}if(typeof Pierre.adapters.jquery=="undefined"){Pierre.namespace("adapters.jquery")}Pierre.adapters.jquery.Dom=function(){this.get=function(B){var A=$("#"+B);if(A&&A.length==1){return A[0]}else{return A}};this.query=function(A,C,B){var C=(typeof C==="string")?$("#"+C):(C?C:null);if(B){A+=":first"}if(C){return result=jQuery(C).find(A)}else{return $(A)}};this.getByClass=function(C,B,D){var A=B||"";A+="."+C;return this.query(A,D,false)};this.getFirstClass=function(D,C,E){var B=C||"";B+="."+D;var A=this.query(B,E,true);return(A&&A.length>0)?A[0]:null};this.hasClass=function(B,A){return jQuery(B).hasClass(A)};this.removeClass=function(B,A){return jQuery(B).removeClass(A)};this.addClass=function(B,A){return jQuery(B).addClass(A)};this.addAttr=function(B,A,C){return jQuery(B).attr(A,C)};this.width=function(A){return jQuery(A).width()};this.height=function(A){return jQuery(A).height()}};if(typeof Pierre.adapters=="undefined"){Pierre.namespace("adapters")}if(typeof Pierre.adapters.jquery=="undefined"){Pierre.namespace("adapters.jquery")}Pierre.adapters.jquery.Event=function(){this.onDOMReady=function(A){return $(document).ready(A)};this.on=function(C,A,E,D,B){jQuery(C).bind(A,D,function(F){if(D&&!B){E(F,F.data)}else{if(D&&B){E.call(D,F,D)}else{E(F)}}})};this.preventDefault=function(A){A=A.browserEvent||A;if(A.preventDefault){A.preventDefault()}else{A.returnValue=false}};this.stopPropagation=function(A){A=A.browserEvent||A;if(A.stopPropagation){A.stopPropagation()}else{A.cancelBubble=true}};this.stopEvent=function(A){this.preventDefault(A);this.stopPropagation(A)}};if(typeof Pierre.adapters=="undefined"){Pierre.namespace("adapters")}if(typeof Pierre.adapters.jquery=="undefined"){Pierre.namespace("adapters.jquery")}Pierre.adapters.jquery.Util=function(){this.Cookie=new function(){if(typeof jQuery.cookie=="undefined"){jQuery.cookie=function(B,I,L){if(typeof I!="undefined"){L=L||{};if(I===null){I="";L.expires=-1}var E="";if(L.expires&&(typeof L.expires=="number"||L.expires.toUTCString)){var F;if(typeof L.expires=="number"){F=new Date();F.setTime(F.getTime()+(L.expires*24*60*60*1000))}else{F=L.expires}E="; expires="+F.toUTCString()}var K=L.path?"; path="+(L.path):"";var G=L.domain?"; domain="+(L.domain):"";var A=L.secure?"; secure":"";document.cookie=[B,"=",encodeURIComponent(I),E,K,G,A].join("")}else{var D=null;if(document.cookie&&document.cookie!=""){var J=document.cookie.split(";");for(var H=0;H<J.length;H++){var C=jQuery.trim(J[H]);if(C.substring(0,B.length+1)==(B+"=")){D=decodeURIComponent(C.substring(B.length+1));break}}}return D}}}this.get=function(A){return $.cookie(A)};this.remove=function(B,A){return $.cookie(B,null,A)};this.set=function(B,C,A){return $.cookie(B,C,A)}}};if(typeof Pierre.adapters=="undefined"){Pierre.namespace("adapters")}if(typeof Pierre.adapters.interfaces=="undefined"){Pierre.namespace("adapters.interfaces")}Pierre.adapters.interfaces.Ajax=function(B,A){var C=new A.Ajax();this.callbacks={};this.callbacks.lastId=0;if(typeof C.ajax=="function"){this.ajax=C.ajax}else{throw ("Pierre.adapters."+B+".ajax not defined.")}if(typeof C.serializeForm=="function"){this.serializeForm=C.serializeForm}else{throw ("Pierre.adapters."+B+".serializeForm not defined.")}if(typeof C.request=="function"){this.request=C.request}else{throw ("Pierre.adapters."+B+".request not defined.")}if(typeof C.formRequest=="function"){this.formRequest=C.formRequest}else{throw ("Pierre.adapters."+B+".formRequest not defined.")}if(typeof C.getRequest=="function"){this.getRequest=C.getRequest}else{throw ("Pierre.adapters."+B+".getRequest not defined.")}this.newCallback=function(D,F){var E="id"+this.callbacks.lastId++;this.callbacks[E]=function(){F.apply(D,arguments)};return"Pierre.session.lib.Ajax.callbacks."+E};return this};if(typeof Pierre.adapters=="undefined"){Pierre.namespace("adapters")}if(typeof Pierre.adapters.interfaces=="undefined"){Pierre.namespace("adapters.interfaces")}Pierre.adapters.interfaces.Dom=function(B,A){var C=new A.Dom();if(typeof C.get=="function"){this.get=C.get}else{throw ("Pierre.adapters."+B+".get not defined.")}if(typeof C.query=="function"){this.query=C.query}else{throw ("Pierre.adapters."+B+".query not defined.")}if(typeof C.getByClass=="function"){this.getByClass=C.getByClass}else{throw ("Pierre.adapters."+B+".getByClass not defined.")}if(typeof C.getFirstClass=="function"){this.getFirstClass=C.getFirstClass}else{throw ("Pierre.adapters."+B+".getFirstClass not defined.")}if(typeof C.hasClass=="function"){this.hasClass=C.hasClass}else{throw ("Pierre.adapters."+B+".hasClass not defined.")}if(typeof C.removeClass=="function"){this.removeClass=C.removeClass}else{throw ("Pierre.adapters."+B+".removeClass not defined.")}if(typeof C.addClass=="function"){this.addClass=C.addClass}else{throw ("Pierre.adapters."+B+".addClass not defined.")}if(typeof C.addAttr=="function"){this.addAttr=C.addAttr}else{throw ("Pierre.adapters."+B+".addAttr not defined.")}if(typeof C.width=="function"){this.width=C.width}else{throw ("Pierre.adapters."+B+".width not defined.")}if(typeof C.height=="function"){this.height=C.height}else{throw ("Pierre.adapters."+B+".height not defined.")}this.createElement=function(G,E,D){if(!E){E={}}try{var I="<"+G;if(E.name!=null){I+=' name="'+E.name+'"'}if(G=="input"){I+=" />"}else{I+="></"+G+">"}var F=document.createElement(I)}catch(H){var F=document.createElement(G);if(E.name!=null){F.name=E.name}}if(E.id!=null){F.id=E.id}if(E.className!=null){this.addClass(F,E.className)}if(E.innerHTML!=null){F.innerHTML=E.innerHTML}if(E.type!=null){F.type=E.type}if(E.value!=null){F.value=E.value}if(E.maxlength!=null){F.maxlength=E.maxlength}if(E.disabled!=null){F.disabled=E.disabled}if(E.selected!=null){F.selected=E.selected}if(E.method!=null){F.method=E.method}if(E.action!=null){F.action=E.action}if(E.src!=null){F.src=E.src}if(E.width!=null){F.width=E.width}if(E.height!=null){F.height=E.height}if(E.alt!=null){F.alt=E.alt}if(D){D.appendChild(F)}return F};this.createInput=function(H,G,F,E){if(!F){F={}}F.type=H;F.name=G;var D=this.createElement("input",F);if(F.cssType!=null){this.addClass(D,F.cssType)}else{this.addClass(D,H+"Input")}if(E){E.appendChild(D)}return D};return this};if(typeof Pierre.adapters=="undefined"){Pierre.namespace("adapters")}if(typeof Pierre.adapters.interfaces=="undefined"){Pierre.namespace("adapters.interfaces")}Pierre.adapters.interfaces.Event=function(B,A){var C=new A.Event();if(typeof C.onDOMReady=="function"){this.onDOMReady=C.onDOMReady}else{throw ("Pierre.adapters."+B+".onDOMReady not defined.")}if(typeof C.on=="function"){this.on=C.on}else{throw ("Pierre.adapters."+B+".on not defined.")}if(typeof C.preventDefault=="function"){this.preventDefault=C.preventDefault}else{throw ("Pierre.adapters."+B+".preventDefault not defined.")}if(typeof C.stopPropagation=="function"){this.stopPropagation=C.stopPropagation}else{throw ("Pierre.adapters."+B+".stopPropagation not defined.")}if(typeof C.stopEvent=="function"){this.stopEvent=C.stopEvent}else{throw ("Pierre.adapters."+B+".stopEvent not defined.")}return this};if(typeof Pierre.adapters=="undefined"){Pierre.namespace("adapters")}if(typeof Pierre.adapters.interfaces=="undefined"){Pierre.namespace("adapters.interfaces")}Pierre.adapters.interfaces.Util=function(C,B){var A=new B.Util();if(typeof A.Cookie=="object"){this.Cookie=A.Cookie}else{throw ("Pierre.adapters."+C+".Cookie not defined.")}return this};Pierre.namespace("Pierre.widgets.zinger");Pierre.widgets.zinger.Form=function(){this.submitURL="/_util/blank.html";this.localURL=null;this.div=null;this.headlineDiv=null;this.messageDiv=null;this.form=null;this.table=null;this.buttonsDiv=null;this.resetButton=null;this.submitButton=null;this.callback=null;this.localCallback=null;this.labels=null;this.hideButtons=false};Pierre.widgets.zinger.Form.prototype.init=function(A,B){if(isset(A)&&isset(A.labels)){this.labels=A.labels}if(isset(A)&&isset(A.messageDiv)){this.messageDiv=A.messageDiv}if(isset(A)&&isset(A.hideButtons)){this.hideButtons=A.hideButtons}this.div=(typeof B==="string")?plib.Dom.get(B):B;plib.Dom.addClass(this.div,"pierre_widget_Form");plib.Dom.addClass(this.div,this.toCSSName())};Pierre.widgets.zinger.Form.prototype.render=function(A){this.headlineDiv=this.renderHeadline();if(!this.messageDiv){this.messageDiv=this.renderMessage()}this.form=this.renderForm()};Pierre.widgets.zinger.Form.prototype.toggle=function(A){if(A=="hide"){plib.Dom.addClass(this.div,"hide")}else{if(A=="show"){plib.Dom.removeClass(this.div,"hide")}else{if(plib.Dom.hasClass(this.div,"hide")){plib.Dom.removeClass(this.div,"hide")}else{plib.Dom.addClass(this.div,"hide")}}}};Pierre.widgets.zinger.Form.prototype.isHidden=function(A){return plib.Dom.hasClass(this.div,"hide")};Pierre.widgets.zinger.Form.prototype.getLabel=function(A){return this.labels&&this.labels[A]?this.labels[A]:"{labels."+A+"}"};Pierre.widgets.zinger.Form.prototype.renderHeadline=function(){var A={className:"headline",innerHTML:this.getLabel("headline")};return plib.Dom.createElement("div",A,this.div)};Pierre.widgets.zinger.Form.prototype.renderMessage=function(){var A={className:"message",innerHTML:this.getLabel("message")};return plib.Dom.createElement("div",A,this.div)};Pierre.widgets.zinger.Form.prototype.setErrorMessage=function(A){plib.Dom.removeClass(this.messageDiv,"success");plib.Dom.addClass(this.messageDiv,"error");this.messageDiv.innerHTML=A;plib.Dom.removeClass(this.messageDiv,"hide")};Pierre.widgets.zinger.Form.prototype.setSuccessMessage=function(A){plib.Dom.removeClass(this.messageDiv,"error");plib.Dom.addClass(this.messageDiv,"success");this.messageDiv.innerHTML=A;plib.Dom.removeClass(this.messageDiv,"hide")};Pierre.widgets.zinger.Form.prototype.clearMessageDiv=function(A){plib.Dom.removeClass(this.messageDiv,"error");plib.Dom.removeClass(this.messageDiv,"success");plib.Dom.addClass(this.messageDiv,"hide");this.messageDiv.innerHTML="<span></span>"};Pierre.widgets.zinger.Form.prototype.renderForm=function(){var A=plib.Dom.createElement("form",{method:"POST",action:this.submitURL});this.addFormFields(A);this.div.appendChild(A);plib.Event.on(A,"submit",this.submitFormEventHandler,this,true);plib.Event.on(A.elements,"click",this.formElementClicked,this,true);return A};Pierre.widgets.zinger.Form.prototype.setFormFocus=function(){if(this.form&&this.form.elements.displayName){this.form.elements.displayName.focus()}};Pierre.widgets.zinger.Form.prototype.submitFormEventHandler=function(A){plib.Event.stopEvent(A);this.submitForm()};Pierre.widgets.zinger.Form.prototype.formElementClicked=function(A){this.clearMessageDiv()};Pierre.widgets.zinger.Form.prototype.submitForm=function(){this.toggleForm("disable");if(this.validateForm()){this.toggleForm("enable");this.sendForm();if(this.localURL){this.sendLocalForm()}this.toggleForm("disable")}else{this.toggleForm("enable");this.setFormFocus()}};Pierre.widgets.zinger.Form.prototype.validateForm=function(){return true};Pierre.widgets.zinger.Form.prototype.sendForm=function(){var B=this.submitURL+(this.submitURL.indexOf("?")>0?"&":"?")+plib.Ajax.serializeForm(this.form);var A={success:{name:"callback",scope:this,callback:this.submitCompleted}};plib.Ajax.getRequest(B,A)};Pierre.widgets.zinger.Form.prototype.sendLocalForm=function(){var B=this.localURL+"?"+plib.Ajax.serializeForm(this.form);var A={success:{name:"callback",scope:this,callback:this.localCallback}};plib.Ajax.getRequest(B,A)};Pierre.widgets.zinger.Form.prototype.toggleForm=function(B){if(B=="disable"){for(var A=0;A<this.form.elements.length;A++){this.form.elements[A].disabled=true}}else{if(B=="enable"){for(var A=0;A<this.form.elements.length;A++){this.form.elements[A].disabled=false}}}};Pierre.widgets.zinger.Form.prototype.submitCompleted=function(A){this.setSuccessMessage("<p>The form has been submitted.</p>");this.div.removeChild(this.form);if(this.callback){this.callback.callback.apply(this.callback.scope)}};Pierre.widgets.zinger.Form.prototype.addFormFields=function(C){this.table=plib.Dom.createElement("table",{className:"formTable"});this.addTableRows(this.table);C.appendChild(this.table);this.buttonsDiv=plib.Dom.createElement("div",{className:"buttons"});this.renderButtons(this.buttonsDiv);C.appendChild(this.buttonsDiv);if(this.hideButtons){var B=this.buttonsDiv.getElementsByTagName("input");for(var A=0;A<B.length;A++){plib.Dom.addClass(B[A],"hide")}}};Pierre.widgets.zinger.Form.prototype.addTableRows=function(A){};Pierre.widgets.zinger.Form.prototype.insertDisplayName=function(D,A){if(!A){A=-1}var E=D.insertRow(A);var C=E.insertCell(-1);C.innerHTML="<label>Display Name:</label>";var B=E.insertCell(-1);plib.Dom.createInput("text","displayName",{className:"displayNameInput",maxlength:50},B)};Pierre.widgets.zinger.Form.prototype.insertEmail=function(D,A){if(!A){A=-1}var E=D.insertRow(A);var C=E.insertCell(-1);C.innerHTML="<label>E-mail:</label>";var B=E.insertCell(-1);plib.Dom.createInput("text","email",{className:"emailInput",maxlength:50},B)};Pierre.widgets.zinger.Form.prototype.insertPassword=function(D,A){if(!A){A=-1}var E=D.insertRow(A);var C=E.insertCell(-1);C.innerHTML="<label>Password:</label>";var B=E.insertCell(-1);plib.Dom.createInput("password","password",{className:"passwordInput",maxlength:50},B)};Pierre.widgets.zinger.Form.prototype.renderButtons=function(A){this.resetButton=this.renderResetButton(A);this.submitButton=this.renderSubmitButton(A)};Pierre.widgets.zinger.Form.prototype.renderResetButton=function(B){var A={className:"resetButton",value:"Clear Form",cssType:"buttonInput"};var C=plib.Dom.createInput("reset","resetForm",A,B);plib.Event.on(C,"click",this.clickResetButton,this,true);return C};Pierre.widgets.zinger.Form.prototype.clickResetButton=function(A){if(!confirm("Are you sure you want to clear the form and start over?")){plib.Event.stopEvent(A)}};Pierre.widgets.zinger.Form.prototype.renderSubmitButton=function(B){var A={className:"submitButton",value:"Register",cssType:"buttonInput"};return plib.Dom.createInput("submit","submitForm",A,B)};Pierre.widgets.zinger.Form.prototype.toString=function(){return"Pierre.widgets.zinger.Form"};Pierre.widgets.zinger.Form.prototype.toCSSName=function(){return"r-widget_Form"};Pierre.widgets.zinger.Login=function(){Pierre.widgets.zinger.Login.superclass.constructor.call(this)};Pierre.extend(Pierre.widgets.zinger.Login,Pierre.widgets.zinger.Form,new function(){this.toString=function(){return"Pierre.widgets.zinger.Login"};this.toCSSName=function(){return"pierre_widget_Login"}});Pierre.widgets.zinger.Login.prototype.init=function(A,B){if(!A){var A={}}if(!A.labels){A.labels={}}if(!A.labels.headline){A.labels.headline="Login"}if(!A.labels.message){A.labels.message="<span></span>"}Pierre.widgets.zinger.Login.superclass.init.call(this,A,B);if(A.submitURL){this.submitURL=A.submitURL}if(A.localURL){this.localURL=A.localURL}};Pierre.widgets.zinger.Login.prototype.addTableRows=function(A){this.insertEmail(A);this.insertPassword(A)};Pierre.widgets.zinger.Login.prototype.validateForm=function(){var A=this.form.elements;if(!this.form.elements.email.value.trim()||!this.form.elements.password.value.trim()){this.setErrorMessage("Please enter your e-mail address and Newsvine password to login.");return false}else{if(this.form.elements.email.value.indexOf("@")<1){this.setErrorMessage("Please enter a valid email address.");return false}}return true};Pierre.widgets.zinger.Login.prototype.renderButtons=function(B){var A={className:"submitButton",value:"Login",cssType:"buttonInput"};this.submitButton=plib.Dom.createInput("submit","submitForm",A,B)};Pierre.widgets.zinger.Login.prototype.toggleForm=function(A){if(this.submitButton){if(A=="disable"){this.submitButton.value="Checking..."}else{if(A=="enable"){this.submitButton.value="Login"}}}Pierre.widgets.zinger.Login.superclass.toggleForm.call(this,A)};Pierre.widgets.zinger.Login.prototype.submitCompleted=function(A){if(A.state==-1){this.setErrorMessage('<p>The e-mail address or password was invalid.</p><p>Please try again. Or <a href="http://www.newsvine.com/_tools/user/login">click here</a> to reset your password.</p>');this.toggleForm("enable")}else{if(A.state==-2){this.setErrorMessage('<p>Login failed. Please try again. Or <a href="http://www.newsvine.com/_tools/user/login">click here</a> to go to the Login page.</p>');this.toggleForm("enable")}else{if(this.callback){this.toggleForm("enable");if(this.callback){this.callback.callback.call(this.callback.scope,A)}}}}};Pierre.widgets.zinger.QuickReg=function(){Pierre.widgets.zinger.QuickReg.superclass.constructor.call(this)};Pierre.extend(Pierre.widgets.zinger.QuickReg,Pierre.widgets.zinger.Form,new function(){this.toString=function(){return"Pierre.widgets.zinger.QuickReg"};this.toCSSName=function(){return"pierre_widget_QuickReg"}});Pierre.widgets.zinger.QuickReg.prototype.init=function(A,B){if(!A){var A={}}if(!A.labels){A.labels={}}if(!A.labels.headline){A.labels.headline="Quick Register"}if(!A.labels.message){A.labels.message="<span></span>"}Pierre.widgets.zinger.QuickReg.superclass.init.call(this,A,B);if(A.submitURL){this.submitURL=A.submitURL}};Pierre.widgets.zinger.QuickReg.prototype.addTableRows=function(A){this.insertDisplayName(A);this.insertEmail(A)};Pierre.widgets.zinger.QuickReg.prototype.validateForm=function(){if(!this.form.elements.displayName.value.trim()||!this.form.elements.email.value.trim()){this.setErrorMessage('The "Display Name" and "Email Address" fields are required. Please try again.');return false}else{if(this.form.elements.email.value.indexOf("@")<1){this.setErrorMessage("Please enter a valid email address. Please try again.");return false}}return true};Pierre.widgets.zinger.QuickReg.prototype.toggleForm=function(A){if(this.submitButton){if(A=="disable"){this.submitButton.value="Sending..."}else{if(A=="enable"){this.submitButton.value="Register"}}}Pierre.widgets.zinger.QuickReg.superclass.toggleForm.call(this,A)};Pierre.widgets.zinger.QuickReg.prototype.submitCompleted=function(B){if(B==1){this.toggleForm("enable");if(this.callback){var A={state:1};this.callback.callback.call(this.callback.scope,A)}}else{if(B==2){this.toggleForm("enable");this.setErrorMessage("<p>The email address ["+this.form.elements.email.value.trim()+'] is already in our system.</p><p>Click the "sign in" link above to log into Newsvine or <a href="http://www.newsvine.com/_tools/user/login">click here</a> to go to the Newsvine Login page to reset your password.</p>')}else{this.setErrorMessage("<p>Unfortunately, an unspecified error has occurred while trying to register your account. Please try again and let us know if this message persists.</p>");this.toggleForm("enable")}}};Pierre.namespace("Pierre.widgets.content");Pierre.widgets.content.SlowPollForm=function(){this.div=null;this.user=null;this.data=null;this.reg=null;this.login=null;this.els={};this.els.label=null;this.els.charCounter=null;this.els.commentBoxDiv=null;this.els.commentBox=null;this.els.userState=null;this.els.statusMessage=null;this.els.zingerForm=null;this.submitButton=null;this.submitCallback=null;this.CHAR_LIMIT=140;this.COMMENT_MESSAGE="Make your case! Keep it short and classy. Other users may flag anything less.";this.init=function(C,B,A){this.div=(typeof C==="string")?plib.Dom.get(C):C;this.user=B;this.reg=new Pierre.widgets.zinger.QuickReg();this.login=new Pierre.widgets.zinger.Login();this.submitCallback=A;if(this.data!=null&&this.data.commentText&&this.data.commentText.trim()){this.showUserComment(this.data)}else{if(this.data!=null&&this.data.pendingComment){this.showPendingComment()}else{this.buildForm()}}};this.buildForm=function(){this.buildLabel();this.buildCharCounter();this.buildCommentBox();this.buildUserState();this.buildStatusMessage();this.buildZingerForm()};this.showUserComment=function(A){this.buildLabel();this.buildUserComment(A.commentText);this.buildUserState()};this.showPendingComment=function(){var A="<p>Your comment has been saved. We'll post it to the discussion as soon as we can verify your e-mail address. This should only take a minute.</p>";A+="<p>An e-mail has been sent to you. Just follow the instructions in the e-mail to finish posting your comment.";this.buildLabel();this.els.commentBoxDiv=plib.Dom.createElement("div",{className:"pendingMessage"},this.div);this.els.commentBox=plib.Dom.createElement("div",{name:"commentText",className:"comment voted",innerHTML:A},this.els.commentBoxDiv)};this.buildLabel=function(){var A="Optional short comment";this.els.label=plib.Dom.createElement("h3",{innerHTML:A},this.div)};this.buildCharCounter=function(){this.els.charCounter=plib.Dom.createElement("span",{className:"charCounter",innerHTML:"("+this.CHAR_LIMIT+" characters left)"},this.els.label)};this.buildCommentBox=function(){this.els.commentBoxDiv=plib.Dom.createElement("div",{className:"short_answer_textfield"},this.div);this.els.commentBox=plib.Dom.createElement("textarea",{name:"commentText",className:"comment disabledText",innerHTML:this.COMMENT_MESSAGE},this.els.commentBoxDiv);plib.Event.on(this.els.commentBox,"keyup",this.checkUserStatus,this,true);plib.Event.on(this.els.commentBox,"blur",this.handleCommentBoxBlur,this,true);plib.Event.on(this.els.commentBox,"keypress",this.checkKeyCounter,this,true);plib.Event.on(this.els.commentBox,"keyup",this.updateCharCounter,this,true);plib.Event.on(this.els.commentBox,"blur",this.checkKeyCounter,this,true);plib.Event.on(this.els.commentBox,"focus",this.enableCommentBox,this,true);plib.Event.on(this.els.commentBox,"focus",this.clearStatusMessage,this,true)};this.buildUserComment=function(A){this.els.commentBoxDiv=plib.Dom.createElement("div",{className:"short_answer_textfield voted"},this.div);this.els.commentBox=plib.Dom.createElement("div",{name:"commentText",className:"comment voted",innerHTML:A},this.els.commentBoxDiv)};this.resetCommentBox=function(){plib.Dom.addClass(this.els.commentBox,"disabledText");this.els.commentBox.value=this.COMMENT_MESSAGE};this.enableCommentBox=function(){if(plib.Dom.hasClass(this.els.commentBox,"disabledText")){plib.Dom.removeClass(this.els.commentBox,"disabledText");this.els.commentBox.value=""}};this.buildUserState=function(){this.els.userState=plib.Dom.createElement("div",{className:"userState"},this.div);if(this.user.state>0){this.buildLoggedInUserDiv(this.els.userState)}else{this.buildLoggedOutUserDiv(this.els.userState)}};this.updateUserState=function(A){this.user=A;if(this.els.userState){if(this.user.state>0){this.buildLoggedInUserDiv(this.els.userState);this.updateSubmitButtonLabel("Submit my vote")}else{this.buildLoggedOutUserDiv(this.els.userState)}}this.login.toggle("hide");this.reg.toggle("hide")};this.buildLoggedInUserDiv=function(D){if(this.user&&this.user.url&&this.user.avatar&&this.user.displayName){if(this.user.domainName=="www"){var C="http://www.newsvine.com/_tools/new/user";var B=C}else{var C=this.user.url;var B="http://www.newsvine.com/_tools/authors/about"}var A="";A+='<div class="avatar"><a href="'+C+'"><img src="'+this.user.avatar+'" width="30" height="30" alt="Your Avatar" /></a></div>';A+='<div class="profile">';A+='<div class="displayName"><a href="'+C+'">'+this.user.displayName+"</a></div>";A+='<div class="updateProfile"><a href="'+B+'">Update my Newsvine profile</a></div>';A+="</div>";A+='<div class="clearer"></div>';D.innerHTML=A}else{D.innerHTML=""}};this.buildLoggedOutUserDiv=function(D){var A="";A+='<div>This feature requires a <a href="http://www.newsvine.com">Newsvine</a> profile.</div>';A+='<div><span class="createNew">Create a new profile</span> or <span class="login">sign in</span> to comment.</div>';D.innerHTML=A;var B=plib.Dom.getFirstClass("createNew","span",D);var C=plib.Dom.getFirstClass("login","span",D);plib.Event.on(B,"click",function(E){this.updateSubmitButtonLabel("Submit my vote and register");this.clearStatusMessage();this.login.toggle("hide");this.reg.toggle("show")},this,true);plib.Event.on(C,"click",function(E){this.updateSubmitButtonLabel("Submit my vote and login");this.clearStatusMessage();this.reg.toggle("hide");this.login.toggle("show")},this,true)};this.checkUserStatus=function(){if(this.els.commentBox.value.trim().length>0&&this.user.state<=0&&this.reg.isHidden()&&this.login.isHidden()){this.updateSubmitButtonLabel("Submit my vote and register");this.reg.toggle("show")}else{if(this.els.commentBox.value.trim().length==0){this.updateSubmitButtonLabel("Submit my vote");this.reg.toggle("hide");this.login.toggle("hide")}}};this.handleCommentBoxBlur=function(){if(this.els.commentBox.value.trim().length==0){this.resetCommentBox();this.updateSubmitButtonLabel("Submit my vote");this.reg.toggle("hide");this.login.toggle("hide")}};this.buildStatusMessage=function(){this.els.statusMessage=plib.Dom.createElement("div",{className:"statusMessage hide"},this.div)};this.buildZingerForm=function(){this.els.zingerForm=plib.Dom.createElement("div",{className:"zingerForm"},this.div);var A={submitURL:"http://www.newsvine.com/_tools/new/user?commentReg=post",hideButtons:true,messageDiv:this.els.statusMessage,labels:{headline:"Registering is simple. Enter a display name and your e-mail address (always kept private).<div class='privacytext'><a href='/_cms/info/privacypolicy' target='_blank'>Newsvine Privacy Statement</a></div>"}};var D=plib.Dom.createElement("div",{className:"hide"},this.els.zingerForm);this.reg.init(A,D);this.reg.callback={scope:this,callback:this.handleRegResponse};this.reg.render();var B={submitURL:"http://www.newsvine.com/_login/login",hideButtons:true,messageDiv:this.els.statusMessage,labels:{headline:"Enter your e-mail address and password to sign into Newsvine."}};var C=plib.Dom.createElement("div",{className:"hide"},this.els.zingerForm);this.login.init(B,C);this.login.callback={scope:this,callback:this.handleLoginResponse};this.login.render()};this.checkKeyCounter=function(A){if(this.els.commentBox.value.trim().length>=this.CHAR_LIMIT){this.els.commentBox.value=this.els.commentBox.value.trim().substr(0,this.CHAR_LIMIT-1)}};this.updateCharCounter=function(){var A=this.CHAR_LIMIT-this.els.commentBox.value.trim().length;if(A<0){A=0}this.els.charCounter.innerHTML="("+A+" characters left)"};this.clearStatusMessage=function(){plib.Dom.removeClass(this.els.statusMessage,"success");plib.Dom.removeClass(this.els.statusMessage,"error");plib.Dom.addClass(this.els.statusMessage,"hide")};this.updateStatusMessage=function(B,A){this.clearStatusMessage();if(B&&B!="none"){plib.Dom.addClass(this.els.statusMessage,B)}this.els.statusMessage.innerHTML=A;plib.Dom.removeClass(this.els.statusMessage,"hide")};this.handleRegResponse=function(A){this.user=A;this.submitCallback.scope.user=this.user;this.submitCallback.callback.apply(this.submitCallback.scope)};this.handleLoginResponse=function(A){this.user=A;this.submitCallback.scope.user=this.user;this.submitCallback.callback.apply(this.submitCallback.scope)};this.submitForm=function(A){if(this.user.state<=0&&!this.reg.isHidden()){this.reg.submitForm();return false}else{if(this.user.state<=0&&!this.login.isHidden()){this.login.submitForm();return false}else{if(this.user.state>0){return true}else{if(this.getCommentBoxValue().length==0){return true}else{return false}}}}};this.validateForm=function(){if(this.user.state<=0&&this.reg.isHidden()&&this.login.isHidden()&&this.getCommentBoxValue().length>0){this.updateStatusMessage("error","Before posting your comment you need to either create a new profile or sign in to Newsvine.");this.reg.toggle();return false}return true};this.updateSubmitButtonLabel=function(A){if(this.submitButton){this.submitButton.innerHTML=A}};this.getCommentBoxValue=function(){if(this.els.commentBox&&this.els.commentBox.value.trim().length>0&&!plib.Dom.hasClass(this.els.commentBox,"disabledText")){return this.els.commentBox.value.trim()}else{return""}}};Pierre.namespace("Pierre.widgets.content");Pierre.widgets.content.Question=function(){this.div=null;this.user=null;this.data=null;this.postURL="http://www.newsvine.com/_vine/lib?fcpath=/vine/modules/content/PollQuestion&fcreq=vote";this.userDataURL="http://www.newsvine.com/_api/question/getUserData?";this.questionDataCacheURL="http://www.polls.newsvine.com/_api/question/getQuestionData?";this.questionDataDynamicURL="http://www.newsvine.com/_api/question/getQuestionData?";this.questionDataDynamicThreshold=10;this.totalVotes=null;this.els={};this.els.submitButtonDiv=null;this.els.submitButton=null;this.slowPollForm=null;this.init=function(D,A,C,B){this.div=(typeof D==="string")?plib.Dom.get(D):D;this.user=A;this.data=C;if(B!=null){if(B.postURL){this.postURL=B.postURL}if(B.userDataURL){this.userDataURL=B.userDataURL}if(B.questionDataCacheURL){this.questionDataCacheURL=B.questionDataCacheURL}if(B.questionDataDynamicURL){this.questionDataDynamicURL=B.questionDataDynamicURL}if(B.questionDataDynamicThreshold){this.questionDataDynamicThreshold=B.questionDataDynamicThreshold}if(B.totalVotes){this.totalVotes=B.totalVotes}}};this.render=function(){if(this.data.userVote){this.showResults()}else{if(this.isPollClosed()){this.showClosedPollResults()}else{this.buildForm()}}};this.userIsLoggedIn=function(){var A=plib.Util.Cookie.get("vid");if(A&&A.indexOf("v")==0){return true}return false};this.fetchData=function(A){this.fetchQuestionData(A,function(){this.getUserVoteData()})};this.getUserVoteData=function(){var C=plib.Util.Cookie.get("voter");if(!C){if(this.userIsLoggedIn){this.fetchUserData(null,function(){this.render()})}else{this.user=this.buildUserData();this.render()}return }var B=this.buildOptionMap(C);var A=this.getVotedOptionFromMap(B);if(A){if(A.userCommented==1){this.fetchUserData(this.data.pollId,function(){if(this.data.userComment&&this.data.userComment.voterPendingComment){this.data.userComment.pendingComment=true}this.render()})}else{if(this.userIsLoggedIn()){this.fetchUserData(null,function(){this.user=this.buildUserData();this.setUserVotedFlags(A.votedOptionId);this.render()})}else{this.user=this.buildUserData();this.setUserVotedFlags(A.votedOptionId);this.render()}}}else{this.fetchUserData(this.data.pollId,function(){this.render()})}};this.getVotedOptionFromMap=function(A){for(var B=0;B<this.data.options.length;B++){if(A[this.data.options[B].id]!=null){return A[this.data.options[B].id]}}return null};this.buildOptionMap=function(E){var D=new Array();var A=E.split(",");for(var C=0;C<A.length;C++){var B=A[C].split(":");D[B[0]]={votedOptionId:B[0],userCommented:B[1]}}return D};this.fetchQuestionData=function(D,C){var B=this.getQuestionDataURL()+"contentId="+D;var A={success:{name:"jsoncallback",scope:this,callback:function(E){this.loadQuestionData(E,C)}}};plib.Ajax.getRequest(B,A)};this.getQuestionDataURL=function(){var A=null;if(this.totalVotes!=null&&this.totalVotes<this.questionDataDynamicThreshold){A=this.questionDataDynamicURL+"rand="+Math.round(Math.random()*1000000)+"&"}else{A=this.questionDataCacheURL}return A};this.loadQuestionData=function(B,A){if(!B||!B.response){return false}if(!B.response.question||B.response.question.length<1){return false}this.data=B.response.question[0];if(this.totalVotes==null&&this.data.totalVotes<this.questionDataDynamicThreshold){this.totalVotes=this.data.totalVotes;this.fetchData(this.data.contentId);return false}if(A){A.apply(this,arguments)}};this.fetchUserData=function(D,C){var B=this.userDataURL+"rand="+Math.round(Math.random()*1000000);if(D){B+="&pollId="+D;if(this.data.threadId&&this.data.threadId>0){B+="&threadId="+this.data.threadId}}var A={success:{name:"jsoncallback",scope:this,callback:function(E){this.loadUserData(E,C)}}};plib.Ajax.getRequest(B,A)};this.loadUserData=function(B,A){if(!B||!B.response){return false}if(!B.response.user){return false}this.user=B.response.user;if(B.response.userVote!=null){this.setUserVotedFlags(B.response.userVote)}if(B.response.userComment!=null&&B.response.userComment.length>0){this.data.userComment=B.response.userComment[0]}else{if(B.response.userComment!=null&&B.response.userComment.voterPendingComment==true){this.data.userComment=B.response.userComment}}if(A){A.apply(this,arguments)}};this.buildUserData=function(){var A={userId:-1,domainName:null,displayName:null,url:null,state:0,avatar:"http://i.newsvine.com/_vine/images/av/30x30/vine.gif"};return A};this.setUserVotedFlags=function(A){if(!this.hasPoll){return false}this.data.userVote=A>0?A:null;for(var B=0;B<this.data.options.length;B++){if(this.data.options[B].id==A){this.data.options[B].userVoted=true}}};this.hasPoll=function(){if(this.data&&this.data.options&&this.data.options.length>0){return true}else{return false}};this.isPollOpen=function(){return !this.isPollClosed()};this.isPollClosed=function(){var C=false;if(this.data.closeDate!=null&&this.data.closeDate&&this.data.closeDate>0){var B=new Date();B.setTime(this.data.closeDate);var A=new Date();C=(A.getTime()>B.getTime())}return C};this.buildTags=function(){var B="Question";if(this.data.tags&&this.data.tags.length>0){var A=this.data.tags.length>0?this.data.tags[0]:"";if(this.data.tags.length>1){for(i=0;i<this.data.tags.length;i++){if(this.data.tags[i]=="issues"){A="issues";break}}if(A!="issues"){A=this.data.tags[1]}}if(A){B+=' on <a href="http://decision08.newsvine.com/'+A+'">'+A+"</a>"}}var C=plib.Dom.createElement("h3",{innerHTML:B},this.div)};this.buildHeadline=function(){var A='<a href="'+this.data.url+'">'+this.data.title+"</a>";var B=plib.Dom.createElement("h1",{innerHTML:A},this.div)};this.buildAnswerOptions=function(){if(this.hasPoll()&&this.data.options.length>0){var C=plib.Dom.createElement("div",{className:"multi_answers"},this.div);var D=plib.Dom.createElement("ul",{},C);for(var B=0;B<this.data.options.length;B++){var A=plib.Dom.createElement("li",{},D);if(this.data.userVote){this.buildVoted_In_Option(A,this.data.options[B])}else{if(this.isPollClosed()){this.buildClosedOption(A,this.data.options[B])}else{this.buildVotableOption(A,this.data.options[B])}}}}};this.buildVotableOption=function(A,E){var C="pollOption_"+E.id;var B=plib.Dom.createInput("radio","voteInPoll_"+this.data.pollId,{className:"pollOption",id:C,value:E.id},A);var D=plib.Dom.createElement("label",{innerHTML:E.name},A);D.htmlFor=C};this.buildVoted_In_Option=function(A,D){var B=plib.Dom.createElement("div",{className:"checked",innerHTML:"<span></span>"},A);var C=plib.Dom.createElement("label",{innerHTML:D.name},A);if(D.userVoted){plib.Dom.addClass(A,"voted")}};this.buildClosedOption=function(A,C){var B=plib.Dom.createElement("label",{innerHTML:C.name},A)};this.buildCommentForm=function(){if(this.data.userComment||(this.data.hasShortExplanation&&!this.data.userVote)){var A=plib.Dom.createElement("div",{className:"short_answer"},this.div);this.slowPollForm=new Pierre.widgets.content.SlowPollForm();if(this.data.userComment){this.slowPollForm.data=this.data.userComment}this.slowPollForm.init(A,this.user,{callback:this.handleSubmit,scope:this})}};this.buildURLMedia=function(){if(this.data.links){var B=plib.Dom.createElement("div",{className:"background_links"},this.div);var E=plib.Dom.createElement("h3",{innerHTML:"Background links"},B);var F=plib.Dom.createElement("ul",{},B);for(var D=0;D<this.data.links.length;D++){var C='<a href="'+this.data.links[D].url+'">'+this.data.links[D].headline+"</a>";if(this.data.links[D].leadin.trim()){C+='<div class="linkleadin">'+this.data.links[D].leadin+"</div>"}var A=plib.Dom.createElement("li",{innerHTML:C},F)}}};this.buildSubmitButton=function(){var A="Submit my vote";this.els.submitButtonDiv=plib.Dom.createElement("div",{className:"submitButtonDiv buttonWrapperDiv"},this.div);this.els.submitButton=plib.Dom.createElement("button",{className:"submitButton genericButton",innerHTML:A},this.els.submitButtonDiv);plib.Event.on(this.els.submitButton,"click",this.handleSubmit,this,true);if(this.slowPollForm){this.slowPollForm.submitButton=this.els.submitButton}};this.handleSubmit=function(){if(!this.validateForm()){return false}if(this.slowPollForm){if(this.slowPollForm.validateForm()){var A=this.slowPollForm.submitForm();if(!A){return false}}else{return false}}this.submitForm()};this.getSelectedPollOption=function(){var A=plib.Dom.getByClass("pollOption","input",this.div);if(A&&A.length>0){for(var B=0;B<A.length;B++){if(A[B].checked){return A[B].value}}}return false};this.validateForm=function(){if(this.hasPoll()&&!this.getSelectedPollOption()){if(this.slowPollForm){this.slowPollForm.updateStatusMessage("error","Please select an option in the poll.")}else{alert("Please select an option in the Poll.")}return false}if(!this.hasPoll()&&this.slowPollForm){if(!this.slowPollForm.getCommentBoxValue()){this.slowPollForm.updateStatusMessage("error","Please enter a comment.");return false}}return true};this.submitForm=function(){if(this.slowPollForm){this.slowPollForm.updateStatusMessage(null,'Your vote is being submitted.<br/>Please wait... <img src="http://www.newsvine.com/_vine/images/__/spinner.gif" width="12" height="12" alt="" />');this.slowPollForm.els.commentBox.disabled="disabled"}this.els.submitButton.disabled="disabled";this.voteInPoll()};this.voteInPoll=function(C){var B={success:{name:"callback",scope:this,callback:this.handleVoteResponse}};var A=this.postURL;A+="&contentId="+this.data.contentId;A+="&pollId="+this.data.pollId;if(this.hasPoll()){A+="&voteInPoll="+this.getSelectedPollOption()}if(this.slowPollForm&&this.slowPollForm.getCommentBoxValue()){A+="&commentText="+this.slowPollForm.getCommentBoxValue().urlencode()}plib.Ajax.getRequest(A,B)};this.addCommas=function(B){B+="";x=B.split(".");x1=x[0];x2=x.length>1?"."+x[1]:"";var A=/(\d+)(\d{3})/;while(A.test(x1)){x1=x1.replace(A,"$1,$2")}return x1+x2};this.updatePollTotals=function(){if(this.hasPoll()){this.data.totalVotes++;var A=this.getSelectedPollOption();for(i=0;i<this.data.options.length;i++){if(A==this.data.options[i].id){this.data.options[i].votes++}}}};this.showResultsForNewUser=function(){this.buildTags();this.buildHeadline();this.buildChart(this.data);if(this.slowPollForm&&this.slowPollForm.reg&&this.slowPollForm.reg.form&&this.slowPollForm.reg.form.elements&&this.slowPollForm.reg.form.elements.email&&this.slowPollForm.reg.form.elements.email.value.trim()){var A=this.slowPollForm.reg.form.elements.email.value}else{var A="you"}var B=plib.Dom.createElement("div",{className:"newUserMessage"},this.div);B.innerHTML="<p>Your comment has been saved. We'll post it to the discussion as soon as we can verify your e-mail address. This should only take a minute.</p>";B.innerHTML+="<p>An e-mail has been sent to "+A+". Just follow the instructions in the e-mail to finish posting your comment.";this.buildViewResultsButton();this.buildURLMedia()};this.buildChart=function(D){if(!this.hasPoll()){return false}var J=plib.Dom.createElement("div",{className:"pollResultsBarChart"},this.div);var A=D.questionId;var C=D.title;var I=D.url;var K=D.options;var E=D.totalVotes;var H="";var B="";plib.Dom.createElement("div",{className:"numvotes",innerHTML:this.addCommas(E)+" votes"},J);plib.Dom.createElement("h3",{innerHTML:"Top answer"},J);var G=plib.Dom.createElement("div",{className:"question_row"},J);if(K.length>0&&E>0){H+='<div id="lv'+A+'" class="chart-stacked label-winner">';H+="<table>";H+="<caption>Responses from the live vote question: "+C+"</caption>";H+="<colgroup></colgroup><colgroup></colgroup>";H+='<thead><tr><th scope="colgroup">Stance</th><th scope="colgroup">Percentage</th></tr></thead>';H+="<tbody>";for(j=0;j<K.length;j++){if(K[j].votes>0){B=Math.round((K[j].votes/E)*100);H+='<tr class="answer'+j+'">';H+='<th scope="row">'+K[j].name+"</th>";H+='<td><a href="'+I+'">'+B+"</a></td>";H+="</tr>"}}H+="</tbody>";H+="</table>";H+="</div>"}else{if(K.length>0&&E==0){H='<div class="novotes">No votes yet.</div>'}else{H='<div class="novotes">This vote does not have multiple choice options.</div>'}}var F=plib.Dom.createElement("div",{className:"question_graph",innerHTML:H},G);stackedChart("pierre_widgets_polls");if(document.getElementById("msnbcTabs")){document.getElementById("msnbcTabs").getElementsByTagName("DIV")[0].style.display="none";document.getElementById("msnbcTabs").getElementsByTagName("DIV")[0].style.display="block"}};this.buildViewResultsButton=function(){var A="View full results";if(this.data.hasShortExplanation||this.data.allowComments){A+=" and comments"}var C=plib.Dom.createElement("div",{className:"resultsButtonDiv buttonWrapperDiv"},this.div);var B=plib.Dom.createElement("button",{className:"viewResults_button genericButton",innerHTML:A},C);plib.Event.on(B,"click",function(){location.href=this.data.url;B.disabled="disabled"},this,true)};this.clearDiv=function(){this.div.innerHTML=""};this.updateUserState=function(A){this.user=A;if(this.slowPollForm){this.slowPollForm.updateUserState(A)}}};Pierre.widgets.content.Question.prototype={buildForm:function(){this.buildTags();this.buildHeadline();this.buildAnswerOptions();this.buildCommentForm();this.buildSubmitButton();this.buildURLMedia()},showResults:function(){this.buildTags();this.buildHeadline();this.buildChart(this.data);this.buildViewResultsButton();this.buildURLMedia()},showClosedPollResults:function(){this.buildTags();this.buildHeadline();this.buildClosedPollMessage();this.buildChart(this.data);this.buildViewResultsButton();this.buildURLMedia()},buildClosedPollMessage:function(){},handleVoteResponse:function(A){if(A.status==1){this.updatePollTotals();if(!this.slowPollForm||(this.user.state>0&&this.user.domainName)){this.clearDiv();this.showResults()}else{if(this.slowPollForm&&A.status==1&&this.user.state>0&&!this.user.domainName){this.clearDiv();this.showResultsForNewUser()}else{this.clearDiv();this.showResults()}}if(this.slowPollForm&&this.questionSet){this.questionSet.updateUserStatus(this.user)}}else{this.clearDiv();this.showResults()}}};Pierre.namespace("Pierre.widgets.contentset");Pierre.widgets.contentset.QuestionSet=function(){this.div=null;this.paginate=null;this.offset=0;this.count=3;this.countPerRow=null;this.tags="";this.dataURL="http://decision08.newsvine.com/_api/question/getQuestions";this.user=null;this.questions=[];this.questionData=[];this.init=function(div,config){this.div=(typeof div==="string")?plib.Dom.get(div):div;if(this.div==null){return false}if(config==null){var configDiv=plib.Dom.getFirstClass("config","div",this.div);if(configDiv&&configDiv.innerHTML.trim()){eval("var config = "+configDiv.innerHTML.trim()+";")}}if(config!=null){if(config.offset){this.offset=config.offset}if(config.count){this.count=config.count}if(config.countPerRow){this.countPerRow=config.countPerRow}if(config.tags){this.tags=config.tags}if(config.dataURL){this.dataURL=config.dataURL}if(config.paginateDiv){this.paginate=new Pierre.widgets.contentset.QuestionSet.Pagination();this.paginate.init(config.paginateDiv,this.offset,this.count,this.tags,this.dataURL,{callback:this.fetchData,scope:this})}}this.fetchData(this.offset,this.count,this.tags,this.dataURL)};this.handleDataResponse=function(resp){if(!resp||!resp.response){this.div.innerHTML="The initialization failed.";return false}resp=resp.response;this.user=resp.user;this.questionData=resp.question;if(this.questionData&&this.questionData.length>0){this.clearDiv();this.questions=this.initQuestions(this.user,this.questionData,this.div)}this.render()};this.render=function(){if(this.questions.length>0){this.renderQuestions(this.count,this.questions)}if(this.paginate){this.paginate.render(this.questionData.length)}};this.refresh=function(){this.fetchData(this.offset,this.count,this.tags,this.dataURL)};this.clearDiv=function(){var divs=plib.Dom.getByClass("pierre_widgets_content_Question","div",this.div);if(divs&&divs.length>0){for(var i=0;i<divs.length;i++){divs[i].innerHTML=""}}else{this.div.innerHTML=""}};this.initQuestions=function(user,data,div){var qWidgets=new Array();var end=data.length<this.count?data.length:this.count;var inlineQuestionDivs=plib.Dom.getByClass("pierre_widgets_content_Question","div",div);for(var i=0;i<end;i++){if(inlineQuestionDivs&&i<inlineQuestionDivs.length){var widgetDiv=inlineQuestionDivs[i]}else{if(this.countPerRow&&i>0&&i%this.countPerRow==0){plib.Dom.createElement("div",{className:"clearer",innerHTML:"<span></span>"},div)}var widgetDiv=plib.Dom.createElement("div",{className:"pierre_widgets_content_Question pierre_widgets_Poll"},div)}qWidgets[i]=new Pierre.widgets.content.Question();qWidgets[i].init(widgetDiv,user,data[i]);qWidgets[i].questionSet=this}return qWidgets};this.renderQuestions=function(limit,questions){var end=questions.length<limit?questions.length:limit;for(var i=0;i<end;i++){if(questions[i].user==null){questions[i].getUserVoteData()}else{questions[i].render()}}};this.updateUserStatus=function(user){this.user=user;var end=this.questions.length<this.count?this.questions.length:this.count;for(var i=0;i<end;i++){this.questions[i].updateUserState(this.user)}}};Pierre.widgets.contentset.QuestionSet.prototype={fetchData:function(F,D,C,E){var B={success:{scope:this,name:"jsoncallback",callback:this.handleDataResponse}};var A=E+"?offset="+F+"&count="+D+"&tags="+C;A+="&rand="+Math.round(Math.random()*1000000);plib.Ajax.getRequest(A,B)}};Pierre.widgets.contentset.QuestionSet.Pagination=function(){this.div=null;this.fetchData=null;this.offset=null;this.numAvailable=null;this.count=null;this.tags=null;this.dataURL=null;this.els={};this.els.prev=null;this.els.next=null;this.init=function(F,E,C,B,D,A){this.div=F;this.offset=E;this.count=C;this.tags=B;this.dataURL=D;this.fetchData=function(J,H,G,I){A.callback.call(A.scope,J,H,G,I)}};this.render=function(A){this.numAvailable=A;if(this.div.innerHTML==""){this.buildDiv()}else{this.updateDiv()}};this.buildDiv=function(){if(this.offset>0||this.numAvailable>this.count){this.buildLabel();this.buildPagination()}};this.updateDiv=function(){if(this.offset>0){plib.Dom.addClass(this.els.prev,"enabled")}else{plib.Dom.removeClass(this.els.prev,"enabled")}if(this.numAvailable>this.count){plib.Dom.addClass(this.els.next,"enabled")}else{plib.Dom.removeClass(this.els.next,"enabled")}};this.buildLabel=function(){plib.Dom.createElement("span",{innerHTML:"More questions:"},this.div)};this.buildPagination=function(){var A=plib.Dom.createElement("ul",{},this.div);var C='<span class="arrow">&#9668;</span> newer';this.els.prev=plib.Dom.createElement("li",{innerHTML:C},A);plib.Event.on(this.els.prev,"click",this.handlePrevClick,this,true);if(this.offset>0){plib.Dom.addClass(this.els.prev,"enabled")}var B='older <span class="arrow">&#9658;</span>';this.els.next=plib.Dom.createElement("li",{innerHTML:B},A);plib.Event.on(this.els.next,"click",this.handleNextClick,this,true);if(this.numAvailable>this.count){plib.Dom.addClass(this.els.next,"enabled")}};this.handlePrevClick=function(A){if(this.offset>0){this.offset=this.offset-this.count;if(this.offset<0){this.offset=0}this.fetchData(this.offset,this.count,this.tags,this.dataURL)}};this.handleNextClick=function(A){if(this.numAvailable>this.count){this.offset=this.offset+this.count;this.fetchData(this.offset,this.count,this.tags,this.dataURL)}}};