$opj.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires= -1;}var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}expires='; expires='+date.toUTCString();}var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=$opj.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}return cookieValue;}};(function($){$.fn.pollOPP=function(method){var pollObj;var mode;var $self;var methods={init:function(options){if(!options.poll)$.error('init() must be supplied with a poll object.');$self=this;pollObj=options.poll;mode=options.mode;var previewMode=mode=="preview";this.empty();if(pollObj.open==true||previewMode){createPollHtmlOPP(previewMode);}else{showPollClosedOPP(previewMode);}return this;},chart:function(options){if(!options.poll)$.error('chart() must be supplied with a poll object.');$self=this;pollObj=options.poll;this.find("#OPP-div-around-poll").empty();eval("pollObj.style = "+pollObj.styleString);createEmptyPollOPP();createChartOPP();return this;}};var createPollHtmlOPP=function(previewMode){if(!previewMode){eval("pollObj.style = "+pollObj.styleString);}setDefaultValues();if(pollObj.adEnabled===undefined||pollObj.adEnabled==true){var opUrls=["http://www.objectplanet.com/opinio/","http://www.easypolls.net/","https://www.murvey.com"];var $next=$self.next();if(0<window.location.href.indexOf("tumblr.com")){if($next.is("p")){$next.children().addClass("OPP-powered-by").unwrap();}}var anchorUrl=$(".OPP-powered-by").eq(0).attr('href');if(!(anchorUrl==opUrls[0]||anchorUrl==opUrls[1]||anchorUrl==opUrls[2])&& !previewMode){$self.text("You can not remove the poll link");return;}}if(!previewMode){var $next=$self.next();if($next.hasClass("OPP-powered-by"))$next.remove();}setWidth();createEmptyPollOPP();setQuestionTextOPP(pollObj.question);if(pollObj.voteButtonText&&0<pollObj.voteButtonText.length){setVoteButtonOPP(pollObj.voteButtonText,previewMode);}if(pollObj.resultLinkText&&0<pollObj.resultLinkText.length){setResultLinkTextOPP(pollObj.resultLinkText);}var i=0;while(pollObj["choice"+i]){addChoiceOPP(pollObj["choice"+i],i++);};if(pollObj.pollChoiceType=="checkbox"){$("#OPP-poll-id-"+pollObj.pollId+" input:checkbox").each(function(i){$(this).attr("name","multResp"+i).attr("value",i);});}else{$("#OPP-poll-id-"+pollObj.pollId+" input:radio").each(function(i){$(this).attr("name","multResp"+pollObj.pollId).attr("value",i);});}if(pollObj.style){setPollStyleOPP();};if($.cookie("OPP"+pollObj.pollId)=="true"){createChartOPP();}else{if(0==$("#OPP-poll-vote-button",$self).size()){setChoicesClickableOPP(previewMode);}};if(mode!="preview")$(".OPP-powered-by").show();};var showPollClosedOPP=function(previewMode){if(!previewMode){eval("pollObj.style = "+pollObj.styleString);}if(pollObj.adEnabled===undefined||pollObj.adEnabled==true){var opUrls=["http://www.objectplanet.com/opinio/","http://www.easypolls.net/","https://www.murvey.com"];var $next=$self.next();if(0<window.location.href.indexOf("tumblr.com")){if($next.is("p")){$next.children().addClass("OPP-powered-by").unwrap();}}var anchorUrl=$(".OPP-powered-by").eq(0).attr('href');if(!(anchorUrl==opUrls[0]||anchorUrl==opUrls[1]||anchorUrl==opUrls[2])&& !previewMode){$self.text("You can not remove the poll link");return;}}var $next=$self.next();if($next.hasClass("OPP-powered-by"))$next.remove();setWidth();if(!pollObj.anchorUrl){pollObj.anchorUrl="http://www.objectplanet.com/opinio/";}var adEnabled=(pollObj.adEnabled===undefined||pollObj.adEnabled==true);if(adEnabled){pollObj.anchorText=pollObj.anchorText&&pollObj.anchorText!=""?pollObj.anchorText:"surveys & polls";}$self.html('<div id="OPP-div-around-poll" class="OPP-div-around-poll">'+'<div style="text-align: center;" id="OPP-poll-question-text"><div style="padding-top: 40px; padding-bottom: 40px;">'+pollObj.pollClosedText+'</div>'+'</div>'+'</div>'+(adEnabled?'<a href="'+pollObj.anchorUrl+'" target="objp" style="text-decoration:none;"><div id="OPP-powered-by" class="OPP-powered-by-div" align="center" style="font: 9px arial; color: gray;">'+pollObj.anchorText+'</div></a>':""));if(pollObj.style){setPollStyleOPP();};if(mode!="preview")$(".OPP-powered-by").show();};var createEmptyPollOPP=function(){if(!pollObj.anchorUrl){pollObj.anchorUrl="http://www.objectplanet.com/opinio/";}var adEnabled=(pollObj.adEnabled===undefined||pollObj.adEnabled==true);if(adEnabled){pollObj.anchorText=pollObj.anchorText&&pollObj.anchorText!=""?pollObj.anchorText:"surveys & polls";}$self.html('<div id="OPP-div-around-poll" class="OPP-div-around-poll">'+'<div style="text-align: '+(pollObj.rtlEnabled?'right':'left')+'; padding-bottom: 3px;" id="OPP-poll-question-text">'+'</div>'+'<fieldset class="OPP-choices" style="border: 0px; padding: 0px; margin-top: 2px;">'+'</fieldset>'+'<div id="OPP-poll-vote" style="vertical-align: middle; text-align: center; font-family: Arial; font-size: 8pt; font-style: normal; font-weight: normal;">'+'<span style="cursor: pointer; font-family: Arial; font-size: 7pt; font-style: normal; font-weight: normal;" id="OPP-poll-vote-result-txt"></span>'+'<span id="OPP-poll-vote-button-span"></span>'+'</div>'+'</div>'+(adEnabled?'<a href="'+pollObj.anchorUrl+'" target="objp" style="text-decoration:none;"><div id="OPP-powered-by" class="OPP-powered-by-div" align="center" style="font: 9px arial; color: gray;">'+pollObj.anchorText+'</div></a>':""));};var setWidth=function(){var $parent=$self.parent();pollObj.style.maxPollWidth=parseInt(pollObj.style.maxPollWidth+"");var parentWidth=$parent.is(":visible")?$parent.width():pollObj.style.maxPollWidth;if(pollObj.style.maxPollWidth<=parentWidth){$self.css("width",pollObj.style.maxPollWidth+"px");}else{$self.css("width","");}};var addChoiceOPP=function(choiceText,i){var align=pollObj.rtlEnabled?'right':'left';var temp='<div class="OPP-poll-choice-div" style="vertical-align: top; clear: both;">'+'<input id="c_'+i+'_'+pollObj.pollId+'" class="OPP-choice-button" type="'+pollObj.pollChoiceType+'" style="float: '+align+'; margin-left: 0px; margin-top: 0px; display: block" name=m0 value=0 type="radio" />'+'<label for="c_'+i+'_'+pollObj.pollId+'" class="OPP-poll-choice OPP-poll-choice-text" id="l_'+i+'_'+pollObj.pollId+'" style="text-align: '+align+'; cursor: pointer; position: relative; margin-'+align+': 16px; margin-top: 2px; display: block; ">'+choiceText+'</label>'+'</div>';$(".OPP-choices",$self).append(temp);};var setChoicesClickableOPP=function(previewMode){if(previewMode){$(".OPP-poll-choice",$self).css("cursor","pointer").mouseenter(function(){$(this).css("opacity","0.4")}).mouseleave(function(){$(this).css("opacity","1")}).bind("click",function(){$("input",$(this).parent()).attr('checked',true);createChartOPP();});}else{$(".OPP-poll-choice",$self).css("cursor","pointer").mouseenter(function(){$(this).css("opacity","0.4")}).mouseleave(function(){$(this).css("opacity","1")}).bind("click",function(){$("input",$(this).parent()).attr('checked',true);saveResponseOPP({data:pollObj});});}};var setQuestionTextOPP=function(questionText){var qtArray=questionText.split("\n");if(qtArray.length==1){$('#OPP-poll-question-text',$self).text(questionText);}else{for(i=0;i<qtArray.length;i++){$('#OPP-poll-question-text',$self).append(document.createTextNode(qtArray[i])).append("<br>");}}};var setVoteButtonOPP=function(text,previewMode){var temp='<button id="OPP-poll-vote-button" ></button>';$("#OPP-poll-vote-button-span",$self).html(temp);$('#OPP-poll-vote',$self).attr("align",pollObj.style.pollVoteAlign);if(previewMode){$("#OPP-poll-vote-button",$self).text(text).unbind("click").bind("click",pollObj,createChartOPP);}else{$("#OPP-poll-vote-button",$self).text(text).unbind("click").bind("click",pollObj,saveResponseOPP);}};var saveResponseOPP=function(attributes){$.cookie("OPPCookieTest",'true',{expires:2});if($.cookie("OPPCookieTest")=="true"){var pollObj=attributes.data;var params=new Object();if(!pollObj.reportData){pollObj.reportData=new Object();}if(pollObj.pollChoiceType=="checkbox"){$("#OPP-poll-id-"+pollObj.pollId+" input:checked").each(function(i){var selectedIndex=$(this).val();params["multResp"+selectedIndex]=selectedIndex+"";var currRptVal=pollObj.reportData["c"+selectedIndex];pollObj.reportData["c"+selectedIndex]=currRptVal?parseInt(currRptVal)+1:1;});}else{params.multResp=$("#OPP-poll-id-"+pollObj.pollId+" input[name=multResp"+pollObj.pollId+"]:checked").val();if(!params.multResp){return;}var currRptVal=pollObj.reportData["c"+params.multResp];pollObj.reportData["c"+params.multResp]=currRptVal?parseInt(currRptVal)+1:1;}pollObj.responseCount=pollObj.responseCount?pollObj.responseCount+1:1;if(mode!="test"){params.pollId=pollObj.pollId;params.pollKey=pollObj.pollKey;params.command="saveResponse";var OPP_BASEURL=$self.data("OPP_BASEURL");$.getJSON(OPP_BASEURL,params,function(data){if(data.resultCode=="0"){$.cookie("OPP"+pollObj.pollId,'true',{expires:365});}});}}createChartOPP();};var setResultLinkTextOPP=function(text){var temp='<span id="OPP-result-link-text"></span> ';$("#OPP-poll-vote-result-txt",$self).html(temp);$('#OPP-poll-vote',$self).attr("align",pollObj.style.pollVoteAlign);$("#OPP-result-link-text",$self).text(text).unbind("click").bind("click",pollObj,createChartOPP).css("cursor","pointer");};var createChartOPP=function(){setDefaultValues();var $divAroundPoll=$("#OPP-div-around-poll",$self);$("#OPP-powered-by",$self).text("EasyPolls").parent().attr("href","http://www.easypolls.net");setWidth();if(pollObj.style){setPollStyleOPP();}var totalVotes=0;var totalVoters=pollObj.responseCount;var choiceIndex=0;if(pollObj.reportData){while(pollObj["choice"+choiceIndex]){if(!pollObj.reportData["c"+choiceIndex])pollObj.reportData["c"+choiceIndex]=0;totalVotes+=parseInt(pollObj.reportData["c"+choiceIndex]);++choiceIndex;}}var insideWidth=$divAroundPoll.innerWidth()-parseInt($divAroundPoll.css("padding-left").replace("px",""))-parseInt($divAroundPoll.css("padding-right").replace("px",""));choiceIndex=0;var align=pollObj.rtlEnabled?'right':'left';var temp='<div style="text-align: '+align+'; padding-bottom: 3px;" id="OPP-poll-question-text">'+'</div>';while(pollObj["choice"+choiceIndex]){var count=0;if(pollObj.reportData){count=pollObj.reportData["c"+choiceIndex];}var percent=getPercentOPP(count,totalVotes);var filledWidth=insideWidth*(percent/100)-2;filledWidth=0<=filledWidth?filledWidth:0;var emptyWidth=insideWidth*((100-percent)/100)-2;emptyWidth=0<=emptyWidth?emptyWidth:0;temp=temp+'<div class="OPP-poll-choice-div OPP-poll-choice-text" style="text-align: '+align+'; clear: both">'+pollObj["choice"+choiceIndex]+' <span style="font-size: .9em; padding-left: 5px; opacity: 0.7;">'+getPercentOPP(count,totalVotes)+'% ('+count+')</span>'+'</div>'+'<div style="height: '+pollObj.style.chartBarHeight+'px">'+(0<filledWidth?'<div style="display: inline-block; float: '+align+'; background-color: '+pollObj.style.chartBarFilledColor+'; border: 1px solid '+pollObj.style.chartBarFilledBorderColor+'; width:'+filledWidth+'px; height: 100%"></div>':"")+(0<emptyWidth?'<div style="display: inline-block; float: '+align+'; background-color: '+pollObj.style.chartBarNotFilledColor+'; border: 1px solid '+pollObj.style.chartBarNotFilledBorderColor+'; width:'+emptyWidth+'px; height: 100%"></div>':"")+'</div>';++choiceIndex;};temp=temp+'<div id="OPP-result-link-text" style="text-align: '+align+'; padding-top: 7px;">'+(pollObj.totalVotesText==""?"":pollObj.totalVotesText+' '+totalVotes)+'</div>';$divAroundPoll.html(temp);setQuestionTextOPP(pollObj.question);var origPadding=pollObj.style.pollChoiceTextPaddingBottom;var origVAlign=pollObj.style.pollChoiceTextVAlign;pollObj.style.pollChoiceTextPaddingBottom="0px";pollObj.style.pollChoiceTextVAlign="bottom";setPollTextStylesOPP();pollObj.style.pollChoiceTextPaddingBottom=origPadding;pollObj.style.pollChoiceTextVAlign=origVAlign;};var getPercentOPP=function(value,total){return value==0?0:Math.round((value/total)*100);};var setPollTextStylesOPP=function(){with(pollObj.style){$('#OPP-poll-title',$self).css('font-family',pollTitleFontFamily).css('font-size',pollTitleFontSize).css('font-style',pollTitleFontStyle).css('font-weight',pollTitleFontWeight).css('color',pollTitleColor).css('text-align',pollTitleTextAlign).css('border-left',pollTitleBorderLeft).css('border-right',pollTitleBorderRight).css('border-top',pollTitleBorderTop).css('border-bottom',pollTitleBorderBottom).css('padding-left',pollTitlePaddingLeft).css('padding-right',pollTitlePaddingRight).css('padding-top',pollTitlePaddingTop).css('padding-bottom',pollTitlePaddingBottom).css('background-color',pollTitleBgColor);$('#OPP-poll-question-text',$self).css('font-family',pollQuestionFontFamily).css('font-size',pollQuestionFontSize).css('font-style',pollQuestionFontStyle).css('font-weight',pollQuestionFontWeight).css('color',pollQuestionColor).css('border-left',pollQuestionBorderLeft).css('border-right',pollQuestionBorderRight).css('border-top',pollQuestionBorderTop).css('border-bottom',pollQuestionBorderBottom).css('padding-left',pollQuestionPaddingLeft).css('padding-right',pollQuestionPaddingRight).css('padding-top',pollQuestionPaddingTop).css('padding-bottom',pollQuestionPaddingBottom).css('background-color',pollQuestionBgColor);$('.OPP-poll-choice-div',$self).css('font-family',pollChoiceTextFontFamily).css('font-size',pollChoiceTextFontSize).css('font-style',pollChoiceTextFontStyle).css('font-weight',pollChoiceTextFontWeight).css('color',pollChoiceTextColor).css('border-left',pollChoiceTextBorderLeft).css('border-right',pollChoiceTextBorderRight).css('border-top',pollChoiceTextBorderTop).css('border-bottom',pollChoiceTextBorderBottom).css('padding-left',pollChoiceTextPaddingLeft).css('padding-right',pollChoiceTextPaddingRight).css('padding-top',pollChoiceTextPaddingTop).css('padding-bottom',pollChoiceTextPaddingBottom).css('text-align',pollObj.rtlEnabled?"right":"left").css('vertical-align',pollChoiceTextVAlign).css('background-color',pollChoiceTextBgColor);$('.OPP-poll-choice-text',$self).css('font-size',pollChoiceTextFontSize);$('#OPP-result-link-text',$self).css('font-family',pollResultLinkTextFontFamily).css('font-size',pollResultLinkTextFontSize).css('font-style',pollResultLinkTextFontStyle).css('font-weight',pollResultLinkTextFontWeight).css('color',pollResultLinkTextColor).css('margin-right',pollResultLinkTextMarginRight);}if($.browser.msie){$('.OPP-poll-choice-text',$self).each(function(i){if(i==0)return;var $prev=$(this).prev();$prev.css("margin-bottom",($(this).height()-$prev.height()-2));});if($.browser.version==5.0||$.browser.version==7.0){$('.OPP-poll-choice-div',$self).css("clear","none");$('.OPP-choice-button, .OPP-poll-choice-text',$self).css("display","inline-block");}}};var setPollStyleOPP=function(){with(pollObj.style){$('#OPP-div-around-poll',$self).css('background-color',divAroundPollBgColor).css('border-left',divAroundPollBorderLeft).css('border-right',divAroundPollBorderRight).css('border-top',divAroundPollBorderTop).css('border-bottom',divAroundPollBorderBottom).css('margin-left',divAroundPollMarginLeft).css('margin-right',divAroundPollMarginRight).css('margin-top',divAroundPollMarginTop).css('margin-bottom',divAroundPollMarginBottom).css('padding-left',divAroundPollPaddingLeft).css('padding-right',divAroundPollPaddingRight).css('padding-top',divAroundPollPaddingTop).css('padding-bottom',divAroundPollPaddingBottom).css('-moz-box-shadow',pollShadow).css('-webkit-box-shadow',pollShadow).css('box-shadow',pollShadow);$('#OPP-choices',$self).css('border-spacing',pollTableBorderSpacing).css('border-left',pollTableBorderLeft).css('border-right',pollTableBorderRight).css('border-top',pollTableBorderTop).css('border-bottom',pollTableBorderBottom).css('margin-left',pollTableMarginLeft).css('margin-right',pollTableMarginRight).css('margin-top',pollTableMarginTop).css('margin-bottom',pollTableMarginBottom).css('padding-left',pollTablePaddingLeft).css('padding-right',pollTablePaddingRight).css('padding-top',pollTablePaddingTop).css('padding-bottom',pollTablePaddingBottom);$('.OPP-choice-button',$self).css('height',pollChoiceTextFontSize).css('margin-top',"2px").css('margin-right',pollObj.rtlEnabled?"0px":"3px").css('margin-left',pollObj.rtlEnabled?"3px":"0px").css('min-height',"12px").css('padding-top',"0px");if($.browser.webkit&&mode=="preview"){$('.OPP-choice-button',$self).css("margin-top","3px");}$('#OPP-poll-vote',$self).css('font-family',pollVoteFontFamily).css('font-size',pollVoteFontSize).css('font-style',pollVoteFontStyle).css('font-weight',pollVoteFontWeight).css('color',pollVoteColor).css('border-left',pollVoteBorderLeft).css('border-right',pollVoteBorderRight).css('border-top',pollVoteBorderTop).css('border-bottom',pollVoteBorderBottom).css('padding-left',pollVotePaddingLeft).css('padding-right',pollVotePaddingRight).css('padding-top',pollVotePaddingTop).css('padding-bottom',pollVotePaddingBottom);$('#OPP-poll-vote-button',$self).css('font-family',pollVoteButtonFontFamily).css('font-size',pollVoteButtonFontSize).css('font-style',pollVoteButtonFontStyle).css('font-weight',pollVoteButtonFontWeight).css('color',pollVoteButtonColor).css('padding',pollVoteButtonPadding);if(pollVoteButtonBorder!=""){$('#OPP-poll-vote-button',$self).css('border',pollVoteButtonBorder);}setPollTextStylesOPP();if(0<cornersStyle.length&&cornersStyle!="0px"){$('#OPP-div-around-poll',$self).css("border-radius",cornersStyle).css("-moz-border-radius",cornersStyle);}}};var setDefaultValues=function(){var defaultValues={totalVotesText:"Total votes:",pollClosedText:"Poll is closed.",anchorText:"polls & surveys",rtl:false,style:{pollVotePaddingTop:"4px",pollShadow:"0px 0px 0px 0px rgba(0,00,00,0.00)"}};pollObj=$.extend(true,{},defaultValues,pollObj);return pollObj;};if(methods[method]){return methods[method].apply(this,Array.prototype.slice.call(arguments,1));}else if(typeof method==='object'|| !method){return methods.init.apply(this,arguments);}else{$.error('Method '+method+' does not exist on jQuery.pollOPP');}};})($opj);
