function yOPP(){var nonEmptyChoices=0;$("#OPP-create-tab-create input").each(function(){if($(this).val()!=""){nonEmptyChoices++;}});if($("#OPP-question-text").val()==""){vOPP('Invalid input','The poll needs a question text.');}else if(0==nonEmptyChoices){vOPP('Invalid input','The poll needs at least one choice.');}else if(0<pollData.responseCount){BOPP("You can not edit a poll with responses.",true,$("#OPP-design-poll-tips"));}else{var randomMessageId=Math.floor(Math.random()*OPPlinkMessages.length);pollData.anchorText=OPPlinkMessages[randomMessageId];switch(OPPlinks[randomMessageId]){case 1:pollData.anchorUrl="http://www.easypolls.net/";break;case 2:pollData.anchorUrl="https://www.murvey.com";break;default:pollData.anchorUrl="http://www.objectplanet.com/opinio/";}var styleString="{";jQuery.each(pollData.style,function(attribute,val){styleString+='"'+attribute+'":"'+val+'",';});styleString=styleString.substring(0,styleString.length-1)+"}";pollData.styleString=styleString;$("#OPP-save-poll-button").text("Saving...").attr('disabled',true).qtip("show").qtip("hide");var createdDate=(pollData.pollId?pollData.createdDate:(new Date()).getTime());var updatedDate=(pollData.pollId?(new Date()).getTime():0);if(pollUserId){var pollDataClone=$.extend({},pollData);$.ajax({url:OPP_PG_BASEURL+"?command=savePoll",type:"POST",data:pollDataClone,dataType:"json",contentType:"application/x-www-form-urlencoded; charset=UTF-8",timeout:"5000",success:function(resultObj,textStatus){if(resultObj.resultCode==RESULT_CODE_OK){lastEditTime=0;pollData.pollId=resultObj.pollId;if(0<$("#"+pollData.pollId).length){wOPP(pollData.pollId);}var pollInfo={pollId:resultObj.pollId,name:pollData.question,hasPremiumFeature:false,createdDate:createdDate,updatedDate:updatedDate,votes:0,isOpen:pollDataClone.isOpen,lastResponseDate:0};aQOPP(pollInfo);VOPP();BOPP("Poll was saved",true,$("#OPP-design-poll-tips"));setTimeout("xOPP()",REFRESH_MAX_AGE+50);qOPP();rOPP();FOPP();}else if(resultObj.resultCode==RESULT_CODE_NOT_LOGGED_IN){hOPP();$('#OPP-dialog-login').dialog('option','buttons',{'Login':function(){sOPP(true,yOPP);},Cancel:function(){$(this).dialog('close');}}).dialog('open');}else if(resultObj.resultCode==RETURN_CODE_CONNECTOR_RESPONDENTS_EXIST){hOPP();BOPP("The poll has responses, and can not be edited.",true,$("#OPP-design-poll-tips"));}else{bROPP();}},error:bROPP});}else{$('#OPP-dialog-account').dialog('open');}}};function VOPP(){if(!pollData.pollId||pollData.pollId=="")return;if(OPPaccStatus=="NOTCONFIRMED"){$("#OPP-publish-info").hide();$("#OPP-publish-not-saved").hide();$("#OPP-publish-not-validated").show();}else{$("#OPP-publish-info").show();$("#OPP-publish-not-saved").hide();$("#OPP-publish-not-validated").hide();var pollPageUrl=OPPpollAddress+OPPpollPage+"?p="+pollData.pollId;var pollEmbedUrl=OPPpollAddress+OPPembedScript+"?p="+pollData.pollId;if($("#OPP-secure").is(':checked')){pollEmbedUrl=pollEmbedUrl.replace("http:","https:").replace("www","host1");}else{pollEmbedUrl=pollEmbedUrl.replace("https:","http:").replace("host1","www");}var tempQuestion=pollData.question;var shareFacebookUrl="http://www.facebook.com/share.php?u="+OPPpollAddress+OPPpollPageJsp+"?t="+encodeURIComponent(tempQuestion+"&p=")+pollData.pollId;var shareTwitterUrl="http://twitter.com/home?status="+encodeURIComponent(pollData.question)+" "+encodeURIComponent(pollPageUrl);$("#OPP-poll-public-link").html("<div style='font: bold 13px arial; color: #6fa7d1;'>Poll page:</div><a style='text-decoration: none; color: gray;' target='POLL"+pollData.pollId+"' href='"+pollPageUrl+"'>"+pollPageUrl+"</a>");var textToAppend='<script type="text/javascript" src="'+pollEmbedUrl+'"></script>';if(pollData.adEnabled){textToAppend=textToAppend+'<a class="OPP-powered-by" href="'+(pollData.anchorUrl==""|| !pollData.anchorUrl?"http://www.objectplanet.com/opinio/":pollData.anchorUrl)+'" style="text-decoration:none;">'+'<div style="font: 9px arial; color: gray;">'+(pollData.anchorText==""|| !pollData.anchorText?"survey software":pollData.anchorText)+'</div>'+'</a>';}if($("#OPP-no-script-code").is(':checked')){textToAppend=textToAppend+"\n<noscript>JavaScript is disabled!</noscript>";}$("#OPP-poll-embed-code").val(textToAppend);$("#OPP-share-social").html("<div style='font: bold 13px arial; color: #6fa7d1;'>Share:</div>"+"<div id='OPP-share-social-buttons' class='addthis_toolbox addthis_default_style '>"+"</div>");var tbx=$("#OPP-share-social-buttons"),svcs={twitter:'',facebook:'',email:'',gmail:'',linkedin:'',friendster:'',myspace:'',digg:'',bebo:'',expanded:''};for(var s in svcs){tbx.append('<a class="addthis_button_'+s+'">'+svcs[s]+'</a>');}addthis.toolbox("#OPP-share-social-buttons",{},{url:pollPageUrl,title:"Poll"});}};function aDOPP(){pollData.pollId="";pollData.responseCount=0;pollData.reportData="";pollData.adEnabled=true;pollData.geoLocationEnabled=false;$("#OPP-ad-enabled").val("true");FOPP(true);yOPP();};function beOPP(){tOPP(pollData.pollId);XOPP();};function bROPP(xhr){BOPP("An error occurred when saving.",true,$("#OPP-design-poll-tips"));$("#OPP-save-poll-button").text("Save").attr('disabled',false);};function hOPP(){var nonEmptyChoices=0;$("#OPP-create-tab-create input").each(function(){if($(this).val()!=""){nonEmptyChoices++;}});if($("#OPP-question-text").val()!=""&&0<nonEmptyChoices){$("#OPP-save-poll-button").text("Save").attr('disabled',false);BOPP("",false,$("#OPP-design-poll-tips"));if(pollData.pollId){$("#OPP-save-as-new-poll-button").show();$("#OPP-save-poll-button").show();$("#OPP-clear-poll-button").show();}else{if(0<$("#OPP-bottom-area button:visible").length){$("#OPP-save-poll-button").show();$("#OPP-clear-poll-button").show();}else{$("#OPP-save-poll-button").show('blind');$("#OPP-clear-poll-button").show('blind');}}}};function xOPP(){$("#OPP-save-poll-button").hide();$("#OPP-save-as-new-poll-button").hide();$("#OPP-clear-poll-button").hide();};function qOPP(){$("#OPP-delete-poll-button").show();};function bCOPP(){$("#OPP-delete-poll-button").qtip("hide");$("#OPP-delete-poll-button").hide();};function anOPP(animate){if($("#OPP-choice-tables input:last").val()!=''){var OPPlastChoice=$("#OPP-choice-tables").append($("#OPP-choice-table-hidden").clone().attr("id","OPP-choice-table"));if(animate){$("#OPP-choice-tables").children(":last").show('blind');}else{$("#OPP-choice-tables").children(":last").show();}YOPP();$("#OPP-choice-tables input:last").val('');}};function aHOPP(event){$('#OPP-choice-separator').removeClass('OPP-choice-separator-hover');var OPPinsert=$("#OPP-choice-table-hidden").clone().attr("id","OPP-choice-table");$('input',OPPinsert).val('');$(event.target).parents("#OPP-choice-table").before(OPPinsert);OPPinsert.show('blind');YOPP();hOPP();};function FOPP(force){if(((new Date().getTime())-lastEditTime)<REFRESH_MAX_AGE||force){if(!force)hOPP();pollData.question=$('#OPP-question-text').val();var questionExist=pollData.question.length>0;var choiceNumber=0;pollData.reportData={};pollData.adEnabled=String($('#OPP-ad-enabled').val())=="true";$('#OPP-choice-tables input').each(function(i){eval("pollData.choice"+i+"= ''");if($(this).val().length>0){eval("pollData.choice"+choiceNumber+"= $(this).val()");eval("pollData.reportData.c"+choiceNumber+" = "+Math.floor(Math.random()*101));choiceNumber++;}});if(0<choiceNumber){questionExist=true;}pollData.voteButtonText=$('#OPP-opt-vote-button-label').val();pollData.resultLinkText=$('#OPP-opt-see-results-label').val();pollData.totalVotesText=$('#OPP-opt-total-votes-label').val();pollData.pollClosedText=$('#OPP-opt-poll-closed-label').val();if(0<$('#OPP-opt-multiple-selections-td :checked').length){pollData.pollChoiceType="checkbox";}else{pollData.pollChoiceType="radio";}pollData.style.maxPollWidth=$('#OPP-opt-max-poll-width').slider('option','value');if(0<$('#OPP-opt-advanced-anti-cheat-td :checked').length){pollData.antiCheatLevel=2;$("#OPP-opt-anti-cheat-text-div").show();}else{pollData.antiCheatLevel=0;$("#OPP-opt-anti-cheat-text-div").hide();}pollData.rtlEnabled=$('#OPP-opt-rtl-enabled').attr("checked")=="checked";pollData.style.divAroundPollBgColor=$("#OPP-bg-color").val();pollData.style.cornersStyle=$('#OPP-corner-radius-value').text();pollData.style.pollQuestionColor=$("#OPP-question-text-color").val();pollData.style.pollChoiceTextColor=$("#OPP-choice-text-color").val();pollData.style.pollResultLinkTextColor=$("#OPP-see-results-text-color").val();pollData.style.pollVoteButtonColor=$("#OPP-vote-button-text-color").val();pollData.style.chartBarFilledColor=$("#OPP-chart-bar-filled-color").val();pollData.style.chartBarFilledBorderColor=$("#OPP-chart-bar-filled-border-color").val();pollData.style.chartBarNotFilledColor=$("#OPP-chart-bar-not-filled-color").val();pollData.style.chartBarNotFilledBorderColor=$("#OPP-chart-bar-not-filled-border-color").val();pollData.style.chartBarHeight=$("#OPP-chart-bar-height").val();pollData.style.divAroundPollPaddingLeft=$("#OPP-padding-left-value").text();pollData.style.divAroundPollPaddingRight=$("#OPP-padding-right-value").text();pollData.style.divAroundPollPaddingTop=$("#OPP-padding-top-value").text();pollData.style.divAroundPollPaddingBottom=$("#OPP-padding-bottom-value").text();pollData.style.pollQuestionFontFamily=$("#OPP-question-text-font").val();pollData.style.pollQuestionFontSize=$("#OPP-question-text-size").val()+"pt";if($("#OPP-question-text-size").val()==""){pollData.style.pollQuestionFontSize="8pt";}if($("#OPP-question-text-bold").css("opacity")=="1"){pollData.style.pollQuestionFontWeight="bold";}else{pollData.style.pollQuestionFontWeight="normal";}if($("#OPP-question-text-italic").css("opacity")=="1"){pollData.style.pollQuestionFontStyle="italic";}else{pollData.style.pollQuestionFontStyle="normal";}pollData.style.pollChoiceTextFontFamily=$("#OPP-choice-text-font").val();pollData.style.pollChoiceTextFontSize=$("#OPP-choice-text-size").val()+"pt";if($("#OPP-choice-text-size").val()==""){pollData.style.pollChoiceTextFontSize="8pt";}if($("#OPP-choice-text-bold").css("opacity")=="1"){pollData.style.pollChoiceTextFontWeight="bold";}else{pollData.style.pollChoiceTextFontWeight="normal";}if($("#OPP-choice-text-italic").css("opacity")=="1"){pollData.style.pollChoiceTextFontStyle="italic";}else{pollData.style.pollChoiceTextFontStyle="normal";}pollData.style.pollResultLinkTextFontFamily=$("#OPP-see-results-text-font").val();pollData.style.pollResultLinkTextFontSize=$("#OPP-see-results-text-size").val()+"pt";if($("#OPP-see-results-text-size").val()==""){pollData.style.pollResultLinkTextFontSize="8pt";}if($("#OPP-see-results-text-bold").css("opacity")=="1"){pollData.style.pollResultLinkTextFontWeight="bold";}else{pollData.style.pollResultLinkTextFontWeight="normal";}if($("#OPP-see-results-text-italic").css("opacity")=="1"){pollData.style.pollResultLinkTextFontStyle="italic";}else{pollData.style.pollResultLinkTextFontStyle="normal";}pollData.style.pollVoteButtonFontFamily=$("#OPP-vote-button-text-font").val();pollData.style.pollVoteButtonFontSize=$("#OPP-vote-button-text-size").val()+"pt";if($("#OPP-vote-button-text-size").val()==""){pollData.style.pollVoteButtonFontSize="8pt";}if($("#OPP-vote-button-text-bold").css("opacity")=="1"){pollData.style.pollVoteButtonFontWeight="bold";}else{pollData.style.pollVoteButtonFontWeight="normal";}if($("#OPP-vote-button-text-italic").css("opacity")=="1"){pollData.style.pollVoteButtonFontStyle="italic";}else{pollData.style.pollVoteButtonFontStyle="normal";}$(".OPP-poll-preview").attr("id","OPP-poll-id-"+pollData.pollId);if(questionExist){$(".OPP-poll-preview").pollOPP('init',{poll:pollData,mode:"preview"});}else{pollData.question="-- EMPTY POLL --";pollData.voteButtonText="";pollData.resultLinkText="";$(".OPP-poll-preview").pollOPP('init',{poll:pollData,mode:"preview"});pollData.titleText="";}pollData.anchorText=pollData.anchorText?pollData.anchorText:"polls & surveys";AOPP("#OPP-powered-by",true);AOPP("#OPP-premium-ad-free",true);pollData.style.pollShadow=$('#OPP-poll-shadow').val();}setTimeout(FOPP,75);};function XOPP(){lastEditTime=new Date().getTime();};function nOPP(millis){lastEditTime=new Date().getTime()+parseInt(millis);};function kOPP(event){$(event.target).parents("#OPP-choice-table").children().children().children().children().val('');if(3<$("#OPP-choice-tables input").size()){$(event.target).parents("#OPP-choice-table").hide("blind","normal",function(){$(this).remove();YOPP();});}};function YOPP(){$("#OPP-choice-tables img").show().unbind('click',XOPP).bind('click',XOPP);$("#OPP-choice-tables img[src*='delete']:last").hide();$("#OPP-choice-tables img[src*='down.png']:last").hide();$("#OPP-choice-tables img[src*='up.png']:first").hide();$("#OPP-choice-tables img[src*='delete']").unbind('click',kOPP).bind('click',kOPP).css("opacity","0.4").mouseenter(function(){$(this).css("opacity","1")}).mouseleave(function(){$(this).css("opacity","0.4")});$("#OPP-choice-tables img[src*='up.png']").unbind('click',iOPP).bind('click',iOPP);$("#OPP-choice-tables img[src*='down.png']").unbind('click',aOPP).bind('click',aOPP);$('.OPP-choice-separator').unbind('click',aHOPP).bind('click',aHOPP);$("#OPP-choice-tables input:last").bind('keyup',anOPP);$("#OPP-choice-tables input").unbind('keyup',XOPP).bind('keyup',XOPP);};function iOPP(event){var temp=$(event.target).parents("#OPP-choice-table");var OPPthisValue=$('input',temp);var OPPpreviousValue=$('input',temp.prev());temp=OPPthisValue.val();OPPthisValue.val(OPPpreviousValue.val());OPPpreviousValue.val(temp);YOPP();};function aOPP(event){var temp=$(event.target).parents("#OPP-choice-table");var OPPthisValue=$('input',temp);var OPPnextValue=$('input',temp.next());temp=OPPthisValue.val();OPPthisValue.val(OPPnextValue.val());OPPnextValue.val(temp);YOPP();};function JOPP(){pollData.pollId="";pollData.responseCount="";pollData.anchorText="survey software";pollData.anchorUrl="http://www.objectplanet.com/opinio/";pollData.adEnabled=true;pollData.geoLocationEnabled=false;pollData.isOpen=true;BOPP("",true,$("#OPP-design-poll-tips"));$('#OPP-ad-enabled').val("true");$('#OPP-geo-location-enabled').val("false");$('#OPP-question-text').val("");for(i=0;i<$("#OPP-choice-tables input").size();i++){eval('pollData.choice'+i+'= ""');}while($("#OPP-choice-tables input").size()>3){$("#OPP-choice-tables").children(":first").remove();}$("#OPP-choice-tables input").val("");$('.OPP-preview-thumb:first').click();$("#OPP-poll-public-link").html("");$("#OPP-publish-info").hide();$("#OPP-publish-not-saved").show();$("#OPP-publish-not-validated").hide();YOPP();xOPP();bCOPP();$('#OPP-opt-multiple-selections').attr('checked',false);$('#OPP-opt-vote-button-label').val("vote");$('#OPP-opt-see-results-label').val("See results");$('#OPP-opt-total-votes-label').val("Total votes:");$('#OPP-opt-poll-closed-label').val("Poll is closed.");XOPP();};var REFRESH_MAX_AGE=300;var RESULT_CODE_OK="0";var RESULT_CODE_INVALID_INPUT="2";var RESULT_CODE_NOT_LOGGED_IN="3";var RESULT_CODE_EMAIL_EXISTS="6";var RETURN_CODE_CONNECTOR_RESPONDENTS_EXIST="-7";var RESULT_CODE_NO_REMAINING_AD_FREE_POLLS="9";var RESULT_CODE_NOT_ENOUGH_FUNDS="10";var SORT_QUESTION_TEXT="0";var SORT_CREATED_DATE="1";var SORT_RESPONSE_DATE="2";var SORT_UPDATED_DATE="3";var SORT_TOTAL_VOTES="4";var OPP_ENTER_KEY=13;var pollData={style:{}};var pollUserId;var OPPremainingFunds=0;var OPPemail;var OPPallRegistrationFormFields;var lastEditTime=0;var OPP_PG_BASEURL=window.location.href.substring(0,window.location.href.indexOf("poll/")+5)+"polladm";var OPPpollAddress="";var OPPpollPage="";var OPPpollPageJsp="";var OPPembedScript="";var OPPinviteMessage="Hi,\n\nI've discovered a great tool for creating polls.\n\nGo here to check it out:\nhttp://www.easypolls.net";var OPPaccStatus="LOGGEDOUT";var OPPlinkMessages=["online surveys","online survey","survey software","customer survey","customer surveys","feedback surveys","web survey","survey service","survey services","web surveys","survey tools","surveys & polls","polls & surveys","survey solutions","survey hosting","panel management","web polls","online polls","free polls"];var OPPlinks=[2,2,0,0,0,0,2,0,0,2,0,2,2,0,0,0,1,1,1];var $opj;$opj=$;$(function(){$.extend(true,pollData.style,defaultStyleAttributes);$(window).load(function(){$('#OPP-all-content').show();$("#OPP-loading-screen").hide();if($.browser.msie&&($.browser.version=="6.0"||$.browser.version=="5.0")){$("#OPP-all-content").hide();$("#OPP-incompatible-browser").show();}FOPP();nOPP(1000);});if(0<window.location.href.indexOf("easypolls.net")){OPP_PG_BASEURL=window.location.href.substring(0,window.location.href.indexOf("easypolls.net")+13)+"/polladm";}$("#OPP-copyright").text("© 2009-"+(new Date()).getFullYear()+" ObjectPlanet, Inc.");OPPallRegistrationFormFields=$([]).add($("#OPP-register-email")).add($("#OPP-register-password")).add($("#OPP-register-password-2"));$("#OPP-tab-create textarea").bind('keyup',XOPP).bind('change',XOPP);$("#OPP-create-tab-look-feel input").bind('keyup',XOPP).bind('change',XOPP);$("#OPP-create-tab-options input").bind('keyup',XOPP).bind('change',XOPP);$("#OPP-create-tab-look-feel select").bind('change',XOPP);$.ajaxSetup({scriptCharset:"utf-8",cache:false});bBOPP();DOPP(".OPP-tooltip");DOPP("#OPP-save-poll-button",{show:{delay:0,solo:true}});DOPP(".OPP-tooltip-mouse",{position:{target:"mouse"}});DOPP("#OPP-no-script-code",IOPP("No-script tag",false));DOPP("#OPP-secure",IOPP("Embed on a secure page",false));DOPP("#OPP-poll-public-link",IOPP("Poll page",false));DOPP("#OPP-poll-embed-code-div",IOPP("Embed poll",false));DOPP("#OPP-opt-max-poll-width",IOPP("Maximum poll width",false));DOPP("#OPP-faq",{content:{url:'faq.html'},title:{text:'FAQ',button:'Close'},hide:{when:{event:'unfocus'}},show:{when:{event:'click'},delay:0},style:{width:{min:500}}});DOPP("#OPP-news",{content:{url:'changes.html'},title:{text:'A log of new features changes of EasyPolls.net',button:'Close'},hide:{when:{event:'unfocus'}},show:{when:{event:'click'},delay:0},style:{width:{min:500},height:{max:500}}});DOPP("#OPP-about",{content:{url:'about.html'},title:{text:'About',button:'Close'},hide:{when:{event:'unfocus'}},show:{when:{event:'click'},delay:0},style:{width:{min:500}}});TOPP($("#OPP-corner-radius"),$("#OPP-corner-radius-value"),0,30);TOPP($("#OPP-padding-left"),$("#OPP-padding-left-value"),0,30);TOPP($("#OPP-padding-right"),$("#OPP-padding-right-value"),0,30);TOPP($("#OPP-padding-top"),$("#OPP-padding-top-value"),0,30);TOPP($("#OPP-padding-bottom"),$("#OPP-padding-bottom-value"),0,30);TOPP($("#OPP-opt-max-poll-width"),$("#OPP-opt-max-poll-width-value"),50,500,5,200);$('.OPP-preview-thumb:first').click();JOPP();$("#OPP-choice-tables").append($("#OPP-choice-table-hidden").clone().show().attr("id","OPP-choice-table")).append($("#OPP-choice-table-hidden").clone().show().attr("id","OPP-choice-table")).append($("#OPP-choice-table-hidden").clone().show().attr("id","OPP-choice-table"));YOPP();xOPP();bCOPP();$("#OPP-poll-shadow-editor").shadowEditor('init',{shadowStringField:'#OPP-poll-shadow'});$('#OPP-poll-shadow').live('click',function(){$('#OPP-poll-shadow-editor').css('display','block').css('top',$(this).position().top+30).css('left',$(this).position().left);$("#OPP-poll-shadow-editor").shadowEditor('applyShadowString',pollData.style.pollShadow);var removeShadowEditor=function(){$('#OPP-poll-shadow-editor').css('display','none');$('*').unbind('click',removeShadowEditor);$("#OPP-poll-shadow-editor").find('*').add("#OPP-poll-shadow-editor").unbind('click',stopRemoveEvent);};var stopRemoveEvent=function(e){e.stopPropagation();};$('*').not('#OPP-poll-shadow-editor, #OPP-poll-shadow-editor *').click(removeShadowEditor);$("#OPP-poll-shadow-editor").find('*').add("#OPP-poll-shadow-editor").click(stopRemoveEvent);}).change(function(){XOPP();hOPP();});$("#OPP-poll-embed-code").bind('click',function(){$(this).select();});$("#OPP-embed-options-table input").bind('click',function(){VOPP();});var f=$.farbtastic('#OPP-color-dialog');$('.OPP-color').live('focus',function(){$('#OPP-color-dialog').css('display','block').css('top',$(this).position().top).css('left',$(this).position().left+70);f.linkTo(this);}).live('blur',function(){$('#OPP-color-dialog').css('display','none');});$(".OPP-img-text-toggle").css("opacity","0.5").bind("click",function(){if($(this).css("opacity")=="0.5"){$(this).css("opacity","1");}else{$(this).css("opacity","0.5");}XOPP();});$(".ui-button").live("mouseenter",function(){$(this).addClass("ui-state-hover");}).live("mouseleave",function(){$(this).removeClass("ui-state-hover");}).live("mousedown",function(){$(this).addClass("ui-state-active");}).live("mouseup",function(){$(this).removeClass("ui-state-active");});$("#OPP-save-poll-button").bind('click',yOPP);$("#OPP-save-as-new-poll-button").bind('click',aDOPP);$("#OPP-delete-poll-button").bind('click',beOPP);aUOPP();$("#OPP-new-poll-button").bind('click',ahOPP);$("#OPP-clear-poll-button").bind('click',JOPP);$("#OPP-login-button-facebook").live('click',function(){gOPP('facebook');});$("#OPP-login-button-google").live('click',function(){gOPP('google');});$("#OPP-invite-button").bind('click',function(){$("#OPP-invite-email").removeClass('ui-state-error');var OPPemails=$("#OPP-invite-email").val();OPPemails=OPPemails.replace(/ /g,"");OPPemails=OPPemails.replace(/;/g,",");var OPPemailValid=true;if(OPPemails.indexOf(",")){var singleEmail=OPPemails.split(",");for(i=0;i<singleEmail.length;i++){if(singleEmail[i].length!=0){if(!COPP($("#OPP-invite-email").val(singleEmail[i]),true,$("#OPP-invite-tips"))){OPPemailValid=false;break;}}}$("#OPP-invite-email").val(OPPemails);}if(OPPemailValid||COPP($("#OPP-invite-email"),true,$("#OPP-invite-tips"))){params={command:"sendEmail",email:$("#OPP-invite-email").val(),fromEmail:OPPemail,subject:"EasyPolls invitation",message:$("#OPP-invite-message").val()};$.ajax({url:OPP_PG_BASEURL,type:"POST",data:params,dataType:"json",timeout:"10000",success:function(data){if(data.resultCode==RESULT_CODE_OK){BOPP('Your invitation was sent.',true,$("#OPP-invite-tips"),8000);$("#OPP-invite-email").val("");return;}else{BOPP('An error has occurred. Please try again later.',true,$("#OPP-invite-tips"));return;}},error:function(XMLHttpRequest,textStatus){BOPP("Error occurred, status: "+textStatus,true,$("#OPP-invite-tips"));}});}});JOPP();$("#OPP-dialog-login").dialog({bgiframe:true,autoOpen:false,height:320,width:355,modal:true,show:'fold',hide:'fold',close:function(){$("#OPP-login-password").val('');lOPP();},open:function(){if(OPPemail){$("#OPP-login-email").val(OPPemail);}setTimeout(function(){if($("#OPP-login-email").attr("readonly")){$("#OPP-login-password").focus();}else{$("#OPP-login-email").focus();}},1000);$("#OPP-login-email").focus();jOPP($('[aria-labelledby$=OPP-dialog-login]').find(":button:contains('Login')"),OPP_ENTER_KEY);}});$("#OPP-dialog-new-password").dialog({bgiframe:true,autoOpen:false,modal:true,show:'fold',hide:'fold',close:function(){$("#OPP-new-password1").val('');$("#OPP-new-password2").val('');lOPP();},open:function(){setTimeout(function(){$("#OPP-new-password1").focus();},1000);$("#OPP-new-password1").focus();jOPP($('[aria-labelledby$=OPP-dialog-login]').find(":button:contains('Set new password')"),OPP_ENTER_KEY);},buttons:{'Set new password':function(){var bValid=true;$("#OPP-new-password1").removeClass('ui-state-error');$("#OPP-new-password2").removeClass('ui-state-error');bValid=bValid&&pOPP($("#OPP-new-password1"),true,$("#OPP-new-password-tips"));bValid=bValid&&SOPP($("#OPP-new-password1"),$("#OPP-new-password2"),true,$("#OPP-new-password-tips"));if(bValid){bzOPP();}}}});$('#OPP-login-request-password-field').click(function(){$('#OPP-dialog-login').dialog('option','hide',null);$('#OPP-dialog-login').dialog('option','show',null);$('#OPP-dialog-login').dialog('close');$('#OPP-dialog-login').dialog('option','hide','fold');$('#OPP-dialog-request-password').dialog('open');});$('#OPP-login-logout').click(function(){if($(this).hasClass('OPP-login')){$('#OPP-dialog-login').dialog('option','buttons',{'Login':function(){sOPP(true);},Cancel:function(){$(this).dialog('close');}}).dialog('open');}else{bnOPP();}});$('#OPP-register-login-field').click(function(){$('#OPP-dialog-account').dialog('option','hide',null).dialog('option','show',null).dialog('close').dialog('option','hide','fold').dialog('option','show','fold');$('#OPP-dialog-login').dialog('option','buttons',{'Login':function(){sOPP(true);},Cancel:function(){$(this).dialog('close');}}).dialog('open');});$('#OPP-contact-us').click(function(){BOPP("All feedback and bug reports are welcome.",false,$("#OPP-send-email-validate-tips"));$('#OPP-dialog-send-email').dialog('open');$("#OPP-subject").val("EasyPolls user message");$("#OPP-to-email").val("poll@easypolls.net");$("#OPP-from-email").val(OPPemail);});$('#OPP-dialog-send-email').dialog({autoOpen:false,show:'fold',hide:'fold',modal:'true',buttons:{'Send email':function(){$("#OPP-send-email").removeClass('ui-state-error');if(COPP($("#OPP-to-email"),true,$("#OPP-send-email-validate-tips"))){params={command:"sendEmail",email:$("#OPP-to-email").val(),fromEmail:$("#OPP-from-email").val(),subject:$("#OPP-subject").val(),message:$("#OPP-send-email-message").val()};$.ajax({url:OPP_PG_BASEURL,type:"POST",data:params,dataType:"json",timeout:"10000",success:function(data){if(data.resultCode==RESULT_CODE_OK){$('#OPP-dialog-send-email').dialog('close');OOPP('Message sent','Your message was sent.');return;}else{BOPP('An error has occurred. Please try again later.',true,$("#OPP-send-email-validate-tips"));return;}},error:function(XMLHttpRequest,textStatus){BOPP("Error occurred, status: "+textStatus,true,$("#OPP-send-email-validate-tips"));}});}}},close:function(){$("#OPP-send-email-message").val('');}});$('#OPP-dialog-send-email').bind('keyup',function(e){if(!((e.which&&e.which==OPP_ENTER_KEY)||(e.keyCode&&e.keyCode==OPP_ENTER_KEY))){OPPallRegistrationFormFields.removeClass('ui-state-error');}});$('#OPP-login-register-field').click(function(){$('#OPP-dialog-login').dialog('option','hide',null).dialog('option','show',null).dialog('close').dialog('option','hide','fold').dialog('option','show','fold');$('#OPP-dialog-account').dialog('open');});$("#OPP-confirm-message").dialog({autoOpen:false,show:'scale',hide:'scale',modal:'true',buttons:{'Ok':function(){$(this).dialog('close');}}});$("#OPP-warning-message").dialog({autoOpen:false,show:'scale',hide:'scale',modal:'true',buttons:{'Ok':function(){$(this).dialog('close');}}});$("#OPP-dialog-account").dialog({bgiframe:true,autoOpen:false,height:365,width:395,modal:true,show:'fold',hide:'fold',buttons:{'Create account and login':function(){var bValid=true;OPPallRegistrationFormFields.removeClass('ui-state-error');bValid=bValid&&COPP($("#OPP-register-email"),true,$("#OPP-register-validate-tips"));bValid=bValid&&pOPP($("#OPP-register-password"),true,$("#OPP-register-validate-tips"));bValid=bValid&&SOPP($("#OPP-register-password"),$("#OPP-register-password-2"),true,$("#OPP-register-validate-tips"));if(bValid){aoOPP($("#OPP-register-email"),true);}},Cancel:function(){$(this).dialog('close');}},close:function(){OPPallRegistrationFormFields.val('').removeClass('ui-state-error');lOPP();if(!pollUserId){$("#OPP-save-poll-button").text("Save").attr('disabled',false);}},open:function(){setTimeout(function(){$("#OPP-register-email").focus()},1000);$("#OPP-register-email").focus();jOPP($('[aria-labelledby$=OPP-dialog-account]').find(":button:contains('Create')"),OPP_ENTER_KEY);}});$('#OPP-register-email').bind('keyup',function(e){if(!((e.which&&e.which==OPP_ENTER_KEY)||(e.keyCode&&e.keyCode==OPP_ENTER_KEY))){OPPallRegistrationFormFields.removeClass('ui-state-error');COPP($("#OPP-register-email"),false,$("#OPP-register-validate-tips"));}});$('#OPP-register-password').bind('keyup',function(e){if(!((e.which&&e.which==OPP_ENTER_KEY)||(e.keyCode&&e.keyCode==OPP_ENTER_KEY))){OPPallRegistrationFormFields.removeClass('ui-state-error');pOPP($("#OPP-register-password"),false,$("#OPP-register-validate-tips"));}});$('#OPP-register-password-2').bind('keyup',function(e){if(!((e.which&&e.which==OPP_ENTER_KEY)||(e.keyCode&&e.keyCode==OPP_ENTER_KEY))){OPPallRegistrationFormFields.removeClass('ui-state-error');SOPP($("#OPP-register-password"),$("#OPP-register-password-2"),false,$("#OPP-register-validate-tips"));}});$('#OPP-create-account').click(function(){$('#OPP-dialog-account').dialog('open');});$('#OPP-expand-look-feel').click(function(){$(this).hide();$("#OPP-collapse-look-feel").show();$("#OPP-look-feel-settings-table").show("blind");});$('#OPP-collapse-look-feel').click(function(){$(this).hide();$("#OPP-expand-look-feel").show();$("#OPP-look-feel-settings-table").hide("blind");});$("#OPP-dialog-request-password").dialog({bgiframe:true,autoOpen:false,height:200,modal:true,buttons:{'Create new password':function(){bTOPP(true);$('#OPP-dialog-login').dialog('option','show','fold');},Cancel:function(){$(this).dialog('close');$("#OPP-dialog-login").dialog('open');$('#OPP-dialog-login').dialog('option','show','fold');}},close:function(){lOPP();},open:function(){BOPP("Type in your e-mail address to request a new password.",false,$("#OPP-request-pw-validate-tips"));$("#OPP-request-pw-email").val($("#OPP-login-email").val()).focus();jOPP($('[aria-labelledby$=OPP-dialog-request-password]').find(":button:contains('Create')"),OPP_ENTER_KEY);}});$('#OPP-update-acc-button').click(function(){POPP();});$('#OPP-delete-acc-button').click(function(){acOPP();});$('#OPP-validate-email-button').click(function(){bIOPP();});aLOPP("#OPP-remaining-funds-button");$("#OPP-my-polls-table-more-button").click(function(){HOPP()});$("#OPP-my-polls-sort").change(function(){$("#OPP-my-polls-table-list").html("");HOPP()});$(".OPP-geo-map-expand").live("click",function(){var $parentWrapper=$(this).parents(".OPP-geo-location-chart-wrapper");var $alreadyExpanded=$(".OPP-geo-location-chart-wrapper-expanded");if(0<$alreadyExpanded.size()&&$(this).parent().find("#OPP-icon-expand").hasClass("ui-icon-newwin")){$alreadyExpanded.removeClass("OPP-geo-location-chart-wrapper-expanded").css('width','').css('height','').find(".OPP-geo-location-chart").height(200).resize().end().find("#OPP-icon-expand").removeClass("ui-icon-closethick").addClass("ui-icon-newwin");}var $elem=$(this);if($elem.size()==0)return;$elem.parent().find("#OPP-icon-expand").toggleClass("ui-icon-newwin").toggleClass("ui-icon-closethick").parents(".OPP-geo-location-chart-wrapper").toggleClass("OPP-geo-location-chart-wrapper-expanded");if($elem.parents(".OPP-geo-location-chart-wrapper").hasClass("OPP-geo-location-chart-wrapper-expanded")){$parentWrapper.find('.OPP-geo-map-preview').removeClass('OPP-geo-map-preview').addClass('OPP-geo-map-preview-big');$mapElem=$elem.parents(".OPP-geo-location-chart-wrapper-expanded");$mapElem.width(Math.round($(window).width()*0.8)).height(Math.round($(window).height()*0.8)).offset({top:$(window).height()/2+$(window).scrollTop()-($mapElem.height()/2),left:$(window).width()/2+$(window).scrollLeft()-($mapElem.width()/2)}).css("z-index",999).find(".OPP-geo-location-chart").height($mapElem.height()-21).resize();$parentWrapper.find('.OPP-geo-location-chart').get(0).adjustMapBig();}else{$parentWrapper.find('.OPP-geo-map-preview-big').removeClass('OPP-geo-map-preview-big').addClass('OPP-geo-map-preview');$mapElem.css('width','').css('height','').find(".OPP-geo-location-chart").height(200).resize();$parentWrapper.find('.OPP-geo-location-chart').get(0).adjustMapSmall();}});$(".OPP-geo-map-load-next-block").live("click",function(){var widg=$(this).parents(".OPP-geo-location-chart-wrapper").find('.OPP-geo-location-chart').get(0);$(this).parents(".OPP-geo-location-chart-wrapper").find('.OPP-geo-location-chart').get(0).loadNextBlock();});AOPP("#OPP-premium-ad-free.OPP-not-activated",true);ROPP("#OPP-premium-geo-loc.OPP-not-activated",true);$("#b").click(function(){setTimeout("$('.OPP-geo-location-chart').resize();",1000);});});function OOPP(title,content){$("#OPP-confirm-message-value").text(content);$("#OPP-confirm-message").dialog('option','title',title).dialog('option','width','300').dialog('option','height','200').dialog('open');};function vOPP(title,content){$("#OPP-warning-message-value").text(content);$("#OPP-warning-message").dialog('option','title',title).dialog('option','width','300').dialog('option','height','200').dialog('open');};function ajOPP(title,content){$("#OPP-yes-no-message-value").text(content);$("#OPP-yes-no-message").dialog('option','title',title).dialog('option','width','300').dialog('option','height','200').dialog('option','close','destroy').dialog('open');};function LOPP(action){if(action=="login"){$("#OPP-login-email").attr("readonly","readonly");$('#OPP-login-logout').html('Log out').removeClass('OPP-login').addClass('OPP-logout');$('#OPP-create-account').hide();HOPP();bgOPP();$("#b").unbind('click',cOPP);$("#c").unbind('click',cOPP);$("#d").unbind('click',cOPP);$("#OPP-invite-message").val(OPPinviteMessage);}else if(action=="logout"){OPPaccStatus="LOGGEDOUT";$("#OPP-login-email").removeAttr("readonly");$('#OPP-login-logout').addClass('OPP-login').removeClass('OPP-logout').html('Log in');$('#OPP-create-account').show();$('#OPP-welcome-msg').hide();$("#b").bind('click',cOPP);$("#c").bind('click',cOPP);$("#d").bind('click',cOPP);$("#OPP-invite-message").val("");$("#OPP-invite-email").val("");}KOPP();};$(function(){$("#tabset1").buildMbTabset({sortable:false,position:"right",stop:function(){ZOPP(" tab");},start:function(){ZOPP(" tab");}});$("#tabset2").buildMbTabset({sortable:false});});function cOPP(){$('#OPP-dialog-login').dialog('option','buttons',{'Login':function(){$(this).dialog('option','close',function(){$("#OPP-login-password").val('');lOPP();});sOPP(true);},Cancel:function(){$(this).dialog('close');}}).dialog('option','close',function(){$("#OPP-login-password").val('');lOPP();$("#a").click();$(this).dialog('option','close',function(){$("#OPP-login-password").val('');lOPP();});}).dialog('open');};function bfOPP(element,cssClass){$(element).addClass(cssClass);};function bGOPP(element,cssClass){$(element).removeClass(cssClass);};function BOPP(text,highlight,OPPtips,millis){if(0<OPPtips.data("timeoutId")){clearTimeout(OPPtips.data("timeoutId"));}if(highlight){OPPtips.text(text).effect("highlight",{},1500);}else{if(text=='&nbsp;'){OPPtips.html(text);}else{OPPtips.text(text);}}if(0<millis){bEOPP(OPPtips,millis);}};function bEOPP(jqueryElement,millis){var timeoutId=setTimeout(function(){jqueryElement.html("&nbsp;");},millis);jqueryElement.data("timeoutId",timeoutId);};function DOPP(elementOrSelector,newAttributes){var defaultAttribues={content:{text:false,title:{text:false}},show:'mouseover',hide:'mouseout',position:{adjust:{screen:true}},style:{name:"blue",background:"#F3F7FA",tip:true,title:{'font-size':12},'font-size':12},show:{delay:600,solo:true}};if(!newAttributes){newAttributes={};}var attributes={};$.extend(true,attributes,defaultAttribues,newAttributes);$(elementOrSelector).qtip(attributes);};function IOPP(title,content){return{content:{text:content,title:{text:title}}}};function WOPP(){$("#OPP-warning-message-value").text('You can not send invitations before your e-mail address has been validated. If you have lost your activation code, you can generate a new from the "Account" tab.');$('#OPP-warning-message').dialog('option','title','Invitations unavailable').dialog('option','close',function(){$("#d").click();$(this).dialog('option','close',function(){});}).dialog('open');};function uOPP(options){if(!options)return;if(options.adDisabled){$("#OPP-ad-enabled").val("");pollData.adEnabled=false;}if(options.geoLocationEnabled){$("#OPP-geo-location-enabled").val("true");pollData.geoLocationEnabled=true;}};function KOPP(){if(OPPaccStatus=="NOTCONFIRMED"){$("#d").html("<span>Account*</span>").css("color","red");$(".OPP-not-validated").show();$("#c").bind('click',WOPP);$("OPP-publish-info").hide();}else{$("#d").html("<span>Account</span>").css("color","");$(".OPP-not-validated").hide();$("#c").unbind('click',WOPP);}};function jOPP(OPPbutton,OPPkey){lOPP();$(document).keypress(function(e){if((e.which&&e.which==OPPkey)||(e.keyCode&&e.keyCode==OPPkey)){if($("button.ui-state-focus :visible").length==0){OPPbutton.click();return false;}else{return true;}}});};function lOPP(){$(document).unbind('keypress');};function AOPP(selector,showPanelForPoll,pollId){$(selector).unbind().mouseenter(function(){var options={userId:pollUserId,remainingFunds:OPPremainingFunds,showPanelForPoll:showPanelForPoll,element:this,pollId:(pollId?pollId:pollData.pollId),featureEnabled:(pollData.adEnabled?false:true),notLoggedInText:"This ad can be removed once you have logged in and saved your poll. <br><br>The price is only <span class='OPP-bold'>99 cents</span>",panelText:"The ad is a link back to our site. <br>Make your poll <span style='font-weight: bold'>ad free</span> for little as <span class='OPP-bold'>99 cents</span>. <br>You may remove the ad on a live poll.",enableFeatureText:"Make this poll ad-free: $0.99<div style='font-size: 0.8em'>($"+(Math.round(OPPremainingFunds*100)/100)+" remaining in your account)",featurePrice:0.99};options.buttons=new Array();options.buttons=[{pollExistsText:"Make this poll ad-free: $0.99",generalText:"Add $0.99 to your account",paypalButtonId:"QMJ3RRZZCWT2Y",productId:"1ADFREE"},{pollExistsText:"Ad-free poll + $4 into your account.<br>Pay only $3.99!",generalText:"Add $5 to your account<br>pay only $3.99!",detail:null,paypalButtonId:"J4V36E5DUCYXC",productId:"1ADFREE4USD"},{pollExistsText:"Ad-free poll + $9 into your account<br>Pay only $5.99!",generalText:"Add $10 to your account<br>pay only $5.99!",paypalButtonId:"ZBN5MDGV9JLPN",productId:"1ADFREE9USD"},{pollExistsText:"Ad-free poll + $19 into your account.<br>Pay only $9.99!",generalText:"Add $20 to your account<br>pay only $9.99!",paypalButtonId:"3NNX47VZJ6EXJ",productId:"1ADFREE19USD"}];options.enableFeatureFunction=function(updateTipsFunc){var params={command:"disableAd",pollId:options.pollId};$.ajax({url:OPP_PG_BASEURL,type:"GET",data:params,dataType:"json",timeout:"10000",success:function(data,textStatus){if(data.resultCode==RESULT_CODE_OK){OPPremainingFunds-=parseFloat(data.amountSpent);$("#OPP-remaining-funds").text(Math.round(OPPremainingFunds*100)/100);$("#OPP-purchase-panel-content").remove();if(pollData.pollId&&options.pollId==pollData.pollId){uOPP({adDisabled:true});}updateTipsFunc("Ad was removed for this poll.");$("#OPP-poll-id-"+options.pollId+"p").find(".OPP-powered-by-div").parent().remove();$("#OPP-poll-id-"+options.pollId+"pr").find(".OPP-powered-by-div").parent().remove();nOPP(800);VOPP();}else{if(data.resultCode==RESULT_CODE_NOT_ENOUGH_FUNDS){updateTipsFunc("Ad was not removed. You have insufficient funds in your account. Refresh your browser (F5) and review your account information.");}else{updateTipsFunc("Unsuccessful. "+data.resultCodeMessage);}}},error:function(XMLHttpRequest,textStatus){updateTipsFunc("Error occurred while trying to remove ad for your poll"+textStatus);}});};$(selector).purchasePanel(options);});};function ROPP(selector,showPanelForPoll,pollId){$(selector).unbind().mouseenter(function(){var options={userId:pollUserId,remainingFunds:OPPremainingFunds,showPanelForPoll:showPanelForPoll,element:this,pollId:(pollId?pollId:pollData.pollId),featureEnabled:(pollData.geoLocationEnabled?true:false),remainingFunds:OPPremainingFunds,notLoggedInText:"Location tracking can be enabled once you have logged in and saved your poll. <br><br>The price is only <span class='OPP-bold'>99 cents</span>",panelText:"Track the location of your respondents. <br>Start tracking for little as <span class='OPP-bold'>99 cents</span>. <br>You may enable tracking on a live poll.",enableFeatureText:"Enable location tracking: $0.99<div style='font-size: 0.8em'>($"+(Math.round(OPPremainingFunds*100)/100)+" USD in your account)",featurePrice:0.99};options.buttons=new Array();options.buttons=[{pollExistsText:"Enable location tracking: $0.99",generalText:"Add $0.99 to your account",paypalButtonId:"34QRFDBW6UDQL",productId:"1GEOTRACK"},{pollExistsText:"Location tracking + $4 into your account.<br>Pay only $3.99!",generalText:"Add $5 to your account<br>pay only $3.99!",detail:null,paypalButtonId:"E6TX5UY4E49R4",productId:"1GEOTRACK4USD"},{pollExistsText:"Location tracking + $9 into your account<br>Pay only $5.99!",generalText:"Add $10 to your account<br>pay only $5.99!",paypalButtonId:"H42KA5WYA6LNE",productId:"1GEOTRACK9USD"},{pollExistsText:"Location tracking + $19 into your account.<br>Pay only $9.99!",generalText:"Add $20 to your account<br>pay only $9.99!",paypalButtonId:"MSN4ERXZL7GZY",productId:"1GEOTRACK19USD"}];options.enableFeatureFunction=function(updateTipsFunc){var params={command:"enableLocationTracking",pollId:options.pollId};$.ajax({url:OPP_PG_BASEURL,type:"GET",data:params,dataType:"json",timeout:"10000",success:function(data,textStatus){if(data.resultCode==RESULT_CODE_OK){OPPremainingFunds-=parseFloat(data.amountSpent);$("#OPP-remaining-funds").text(Math.round(OPPremainingFunds*100)/100);$("#OPP-purchase-panel-content").remove();if(pollData.pollId&&options.pollId==pollData.pollId){uOPP({geoLocationEnabled:true});}updateTipsFunc("Location tracking was enabled for this poll.");$("#OPP-poll-id-"+options.pollId+"pglow").find(".OPP-enable-geo-loc").remove();$("#OPP-poll-id-"+options.pollId+"pgl").geoLocationReport({geoLocationEnabled:true});XOPP();VOPP();}else{if(data.resultCode==RESULT_CODE_NOT_ENOUGH_FUNDS){updateTipsFunc("Location tracking was not enabled. You have insufficient funds in your account. Refresh your browser (F5) and review your account information.");}else{updateTipsFunc("Unsuccessful. "+data.resultCodeMessage);}}},error:function(XMLHttpRequest,textStatus){updateTipsFunc("Error occurred while trying to remove ad for your poll"+textStatus);}});};$(selector).purchasePanel(options);});};function aLOPP(selector,pollId){$(selector).unbind().mouseenter(function(){var options={userId:pollUserId,remainingFunds:OPPremainingFunds,showPanelForPoll:false,element:this,pollId:(pollId?pollId:pollData.pollId),notLoggedInText:"",panelText:"Add funds to your account to use the  <span class='OPP-bold'>great premium features</span>.",enableFeatureText:""};options.buttons=new Array();options.buttons=[{pollExistsText:"",generalText:"Add 99 cents to your account",paypalButtonId:"UZQBANXEQ8GAE",productId:"99CENTS"},{pollExistsText:"",generalText:"Add $5 to your account<br>pay only $3.99!",paypalButtonId:"JC5KJ42LS7XS4",productId:"5USD"},{pollExistsText:"",generalText:"Add $10 to your account<br>pay only $5.99!",paypalButtonId:"F79A5W66SJM96",productId:"10USD"},{pollExistsText:"",generalText:"Add $20 to your account<br>pay only $9.99!",paypalButtonId:"7NBC6AKC2JATQ",productId:"20USD"}];$(selector).purchasePanel(options);});};var updatePayableItems=(function(){var timer=0;var stopTime=0;return function(ms){clearTimeout(timer);currMillis=(new Date()).getTime();var newStopTime=(ms&&ms!=0?currMillis+ms:0);if(0<newStopTime)stopTime=newStopTime;if(0<stopTime&&currMillis<stopTime){var params={command:"getPayableStatus",pollId:pollData.pollId};$.ajax({url:OPP_PG_BASEURL,type:"GET",data:params,dataType:"json",timeout:"5000",success:function(data,textStatus){if(data.resultCode==RESULT_CODE_OK){OPPremainingFunds=data.remainingFunds;$("#OPP-remaining-funds").text(Math.round(OPPremainingFunds*100)/100);$("#OPP-ad-enabled").val(data.adEnabled);$("#OPP-geo-location-enabled").val(data.geoLocationEnabled);XOPP();VOPP();}},error:function(){}});timer=setTimeout(updatePayableItems,10000);}else{stopTime=0;return;}};})();$.fn.slideFadeToggle=function(easing,callback){return this.animate({opacity:'toggle',height:'toggle'},"fast",easing,callback);};(function($){$.fn.purchasePanel=function(options){var animSpeed=350;var payPalLink="http://www.paypal.com";var self=this.eq(0);var getPaypalBuyNowButton=function(pollId,showPanelForPoll,button){var result="<form action='https://www.paypal.com/cgi-bin/webscr' method='post' onsubmit='window.open(\"\", \"paypal\", \"width=800,height=600,scrollbars=yes\")' target='paypal'>"+"<button id='"+button.productId+"' class='ui-button ui-state-default ui-corner-all'>"+(pollId&&showPanelForPoll?button.pollExistsText:button.generalText)+"</button>"+"<input type='hidden' name='cmd' value='_s-xclick'>"+"<input type='hidden' class='custom' name='custom' value=''>"+"<input type='hidden' name='hosted_button_id' value='"+button.paypalButtonId+"'>"+"</form>";return result;};var updateTips=function(str){BOPP(str,true,$("#OPP-purchase-panel").find(".OPP-tips"));};options=options?options:{};self.data("options",options);var $paymentPanel=$("#OPP-purchase-panel");if(0==$paymentPanel.size()){$paymentPanel=$("<div id='OPP-purchase-panel' class='o-ui-hoverMenu' style='width: 350px; text-align: center;'></div>").appendTo("body");}$paymentPanel.children().remove();$paymentPanel.append("<div style='color: #000; font-size: 1.2em; color: #000; background-color: #f5faff; border: 1px solid #A6C9E2; -moz-border-radius: 8px; border-radius: 8px; padding: 20px; -moz-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.25); -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.25); box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.25);'></div>");var panelContent="";if(options.featureEnabled){panelContent+="This feature is already enabled";}else if(options.userId){panelContent+="<span id='OPP-purchase-panel-content'>"+"<span class='OPP-purchase-panel-buttons'>";if(options.featurePrice&&options.featurePrice<=options.remainingFunds&&options.showPanelForPoll&&options.pollId&&options.pollId!=""){panelContent+="<div>"+"<button id='OPP-enable-feature' type='submit' class='ui-button ui-state-default ui-corner-all'>"+options.enableFeatureText+"</div></button>"+"</div>";}else{panelContent+="<div>"+options.panelText+"</div>";for(var i=0;options.buttons&&i<options.buttons.length;i++){panelContent+="<div>"+getPaypalBuyNowButton(options.pollId,options.showPanelForPoll,options.buttons[i])+"</div>";}panelContent+="<div style='padding-bottom: 10px; font-size: 0.8em'>Prices are in USD.</div>"+"<table cellpadding=\"0\" cellspacing=\"0\" align=\"center\"><tr><td align=\"center\"></td></tr><tr><td align=\"center\"><a href=\"#\" onclick=\"javascript:window.open(\'https://www.paypal.com/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside\',\'olcwhatispaypal\',\'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=400, height=350\');\"><img  src=\"https://www.paypal.com/en_US/i/bnr/bnr_paymentsBy_150x40.gif\" border=\"0\" alt=\"Solution Graphics\"></a></td></tr></table>";}panelContent+="</span>";if(options.showPanelForPoll)panelContent+="<div style='padding-top: 10px; font-size: 0.8em'>This popup will never show on a live poll.</div>";panelContent+="</span>";}else{panelContent+=options.notLoggedInText;}panelContent+="<div class='OPP-tips'></div>";var removePanelFunc=function(e){$panel=$("#OPP-purchase-panel");var panelX=$panel.position().left,panelY=$panel.position().top,panelX2=$panel.position().left+$panel.width(),panelY2=$panel.position().top+$panel.height();if(!(panelX<e.pageX&&e.pageX<panelX2&&panelY<e.pageY&&e.pageY<panelY2)){$("*").die("mouseenter",removePanelFunc);$panel.fadeOut(animSpeed);}};$paymentPanel.children().append(panelContent).end().fadeIn(animSpeed,function(){$("*").unbind("live",removePanelFunc).live("mouseenter",removePanelFunc);});$(".OPP-powered-by").addClass("OPP-purchasePanelElement");var pos=$(options.element).position();pos.left+=$(options.element).width()/2;pos.left-=$paymentPanel.width()/2;pos.top-=30;$paymentPanel.css(pos);$paymentPanel.mouseleave(function(){$(this).fadeOut(animSpeed)}).find("button").not("#OPP-enable-feature").click(function(){var buttonClicked=this;var params={command:"initOrder",pollId:options.pollId,productIds:$(this).attr("id")};$.ajax({url:OPP_PG_BASEURL,type:"GET",data:params,dataType:"json",timeout:"10000",success:function(data,textStatus){if(data.resultCode==RESULT_CODE_OK&&data.orderId&&data.orderId!=""){var $form=$(buttonClicked).parents("form");$form.find(".custom").val(data.orderId);$form.submit();updatePayableItems(5*60*1000);}else{updateTips("Could not initialize order. Please try again.");}},error:function(){updateTips("Could not initialize order. Status: "+textStatus);}});return true;});$paymentPanel.find("#OPP-enable-feature").click(function(){options.enableFeatureFunction(updateTips)});return self;}})(jQuery);function sOPP(highlight,OPPcallbackFunction){var params={command:"login",email:$("#OPP-login-email").val(),password:$("#OPP-login-password").val()};$.ajax({url:OPP_PG_BASEURL,type:"POST",data:params,dataType:"json",timeout:"10000",success:function(data,textStatus){if(data.resultCode==RESULT_CODE_OK){if(data.result=='true'){$('#OPP-dialog-login').dialog('close');if(pollUserId!=data.pollUserId){pollUserId=data.pollUserId;OPPpollAddress=data.serverAddress;OPPpollPage=data.connectorPollPage;OPPpollPageJsp=data.connectorPollPageJsp;OPPembedScript=data.embedScript;OPPaccStatus=data.accountStatus;LOPP("login");}OPPremainingFunds=parseFloat(data.remainingFunds);if(data.changePasswordRequired=='true'){$("#OPP-dialog-new-password").dialog('open');}if(OPPcallbackFunction){OPPcallbackFunction();}return;}else{BOPP('Invalid login.',highlight,$("#OPP-login-validate-tips"));return;}}BOPP('An error has occurred. Please try again later. ErrorCode: '+data.resultCode,true,$("#OPP-login-validate-tips"));},error:function(XMLHttpRequest,textStatus){BOPP("Error occurred, status: "+textStatus,true,$("#OPP-login-validate-tips"));}});};function bnOPP(){var params={command:"logout"};$.getJSON(OPP_PG_BASEURL,params,function(data){if(data.resultCode==0){$("#a").click();pollUserId="";LOPP("logout");OPPemail="";JOPP();aIOPP();amOPP()}});};function aUOPP(){var params={command:"isLoggedIn"};$.getJSON(OPP_PG_BASEURL,params,function(data){if(data.resultCode==0&&data.result=='true'){pollUserId=data.pollUserId;OPPremainingFunds=parseFloat(data.remainingFunds);OPPpollAddress=data.serverAddress;OPPpollPage=data.connectorPollPage;OPPpollPageJsp=data.connectorPollPageJsp;OPPembedScript=data.embedScript;OPPaccStatus=data.accountStatus;LOPP("login");}else{pollUserId="";LOPP("logout");}});};var styles={lightBlueStyle:{},lightGrayStyle:{},lightRedStyle:{},lightRedStyle:{},lightGreenStyle:{},lightPurpleStyle:{},lightPinkStyle:{},blackWhiteStyle:{},greyRedStyle:{},goldenStyle:{},greenStyle:{},blueGrayStyle:{},blueGrayShadowStyle:{},lightYellowStyle:{},orangeStyle:{},whiteShadowStyle:{}};var defaultStyleAttributes={image:"images/thumbMissing.png",divAroundPollBgColor:"",divAroundPollShadow:"",divAroundPollWidth:"",divAroundPollBorderLeft:"",divAroundPollBorderRight:"",divAroundPollBorderTop:"",divAroundPollBorderBottom:"",divAroundPollMarginLeft:"",divAroundPollMarginRight:"",divAroundPollMarginTop:"",divAroundPollMarginBottom:"",divAroundPollPaddingLeft:"10px",divAroundPollPaddingRight:"10px",divAroundPollPaddingTop:"10px",divAroundPollPaddingBottom:"10px",pollShadow:"0px 0px 0px 0px rgba(0,0,0,0.00)",pollTableBorderSpacing:"0",pollTableBorderLeft:"",pollTableBorderRight:"",pollTableBorderTop:"",pollTableBorderBottom:"",pollTableMarginLeft:"",pollTableMarginRight:"",pollTableMarginTop:"",pollTableMarginBottom:"",pollTablePaddingLeft:"",pollTablePaddingRight:"",pollTablePaddingTop:"",pollTablePaddingBottom:"",pollTitleFontFamily:"Arial",pollTitleFontSize:"10pt",pollTitleFontStyle:"normal",pollTitleFontWeight:"bold",pollTitleColor:"",pollTitleTextAlign:"center",pollTitleBorderLeft:"",pollTitleBorderRight:"",pollTitleBorderTop:"",pollTitleBorderBottom:"",pollTitlePaddingLeft:"",pollTitlePaddingRight:"",pollTitlePaddingTop:"",pollTitlePaddingBottom:"",pollTitleBgColor:"",pollQuestionFontFamily:"Arial",pollQuestionFontSize:"10pt",pollQuestionFontStyle:"normal",pollQuestionFontWeight:"normal",pollQuestionColor:"",pollQuestionBorderLeft:"",pollQuestionBorderRight:"",pollQuestionBorderTop:"",pollQuestionBorderBottom:"",pollQuestionPaddingLeft:"",pollQuestionPaddingRight:"",pollQuestionPaddingTop:"",pollQuestionPaddingBottom:"3px",pollQuestionBgColor:"",pollChoiceButtonBorderLeft:"",pollChoiceButtonBorderRight:"",pollChoiceButtonBorderTop:"",pollChoiceButtonBorderBottom:"",pollChoiceButtonPaddingLeft:"",pollChoiceButtonPaddingRight:"",pollChoiceButtonPaddingTop:"",pollChoiceButtonPaddingBottom:"",pollChoiceButtonTextAlign:"right",pollChoiceButtonVAlign:"top",pollChoiceButtonBgColor:"",pollChoiceTextColor:"",pollChoiceTextFontFamily:"Arial",pollChoiceTextFontSize:"8pt",pollChoiceTextFontStyle:"normal",pollChoiceTextFontWeight:"normal",pollChoiceTextBorderLeft:"",pollChoiceTextBorderRight:"",pollChoiceTextBorderTop:"",pollChoiceTextBorderBottom:"",pollChoiceTextPaddingLeft:"",pollChoiceTextPaddingRight:"",pollChoiceTextPaddingTop:"4px",pollChoiceTextPaddingBottom:"",pollChoiceTextPaddingRight:"",pollChoiceTextTextAlign:"left",pollChoiceTextVAlign:"top",pollChoiceTextBgColor:"",pollVoteAlign:"center",pollVoteFontFamily:"Arial",pollVoteFontSize:"8pt",pollVoteFontStyle:"normal",pollVoteFontWeight:"normal",pollVoteColor:"",pollVoteBorderLeft:"",pollVoteBorderRight:"",pollVoteBorderTop:"",pollVoteBorderBottom:"",pollVotePaddingLeft:"",pollVotePaddingRight:"",pollVotePaddingTop:"3px",pollVotePaddingBottom:"",pollResultLinkTextColor:"",pollResultLinkTextFontFamily:"Arial",pollResultLinkTextFontSize:"7pt",pollResultLinkTextFontStyle:"normal",pollResultLinkTextFontWeight:"normal",pollResultLinkTextMarginRight:"",pollVoteButtonFontFamily:"Arial",pollVoteButtonFontSize:"10pt",pollVoteButtonFontStyle:"normal",pollVoteButtonFontWeight:"normal",pollVoteButtonColor:"#000",pollVoteButtonBorder:"",pollVoteButtonPadding:"",chartBarFilledColor:"#555",chartBarFilledBorderColor:"#333",chartBarNotFilledColor:"#bbb",chartBarNotFilledBorderColor:"#aaa",chartBarHeight:"5",cornersStyle:"10px",maxPollWidth:200};$.extend(true,styles.lightBlueStyle,defaultStyleAttributes,{image:"images/themes/lightBlueStyle.png",divAroundPollBgColor:"#CEE7FF",pollTitleColor:"#466D92",pollQuestionColor:"#466D92",pollChoiceTextColor:"#466D92",pollResultLinkTextColor:"#466D92",chartBarFilledColor:"#578bbc",chartBarFilledBorderColor:"#578bbc",chartBarNotFilledColor:"#c8dcef",chartBarNotFilledBorderColor:"#c8dcef"});$.extend(true,styles.lightGrayStyle,defaultStyleAttributes,{image:"images/themes/lightGrayStyle.png",divAroundPollBgColor:"#ccc",pollTitleColor:"#777",pollQuestionColor:"#444",pollChoiceTextColor:"#444",pollResultLinkTextColor:"#444",chartBarFilledColor:"#555",chartBarFilledBorderColor:"#333",chartBarNotFilledColor:"#c1c1c1",chartBarNotFilledBorderColor:"#c1c1c1"});$.extend(true,styles.lightRedStyle,defaultStyleAttributes,{image:"images/themes/lightRedStyle.png",divAroundPollBgColor:"#FFCECE",pollTitleColor:"#774A4A",pollQuestionColor:"#774A4A",pollChoiceTextColor:"#774A4A",pollResultLinkTextColor:"#774A4A",chartBarFilledColor:"#824040",chartBarFilledBorderColor:"#824040",chartBarNotFilledColor:"#d8c0c0",chartBarNotFilledBorderColor:"#cfb0b0"});$.extend(true,styles.lightGreenStyle,defaultStyleAttributes,{image:"images/themes/lightGreenStyle.png",divAroundPollBgColor:"#D3FED3",pollTitleColor:"#4D5F4D",pollQuestionColor:"#4D5F4D",pollChoiceTextColor:"#4D5F4D",pollResultLinkTextColor:"#4D5F4D",chartBarFilledColor:"#4D5F4D",chartBarFilledBorderColor:"#4D5F4D",chartBarNotFilledColor:"#d6e1d6",chartBarNotFilledBorderColor:"#c7d6c7"});$.extend(true,styles.lightPurpleStyle,defaultStyleAttributes,{image:"images/themes/lightPurpleStyle.png",divAroundPollBgColor:"#EECAFF",pollTitleColor:"#65556D",pollQuestionColor:"#65556D",pollChoiceTextColor:"#65556D",pollResultLinkTextColor:"#65556D",chartBarFilledColor:"#806a8a",chartBarFilledBorderColor:"#65556D",chartBarNotFilledColor:"#cdc0d3",chartBarNotFilledBorderColor:"#c3b4cb"});$.extend(true,styles.lightPinkStyle,defaultStyleAttributes,{image:"images/themes/lightPinkStyle.png",divAroundPollBgColor:"#FFCEF1",pollTitleColor:"#7D5472",pollQuestionColor:"#7D5472",pollChoiceTextColor:"#7D5472",pollResultLinkTextColor:"#7D5472",chartBarFilledColor:"#9c6d8f",chartBarFilledBorderColor:"#8f6182",chartBarNotFilledColor:"#ddc0d5",chartBarNotFilledBorderColor:"#d2acc8"});$.extend(true,styles.blackWhiteStyle,defaultStyleAttributes,{image:"images/themes/blackWhiteStyle.png",divAroundPollBgColor:"#000000",pollTitleColor:"#ffffff",pollQuestionColor:"#ffffff",pollChoiceTextColor:"#ffffff",pollResultLinkTextColor:"#ffffff",chartBarFilledColor:"#c9c9c9",chartBarFilledBorderColor:"#c9c9c9",chartBarNotFilledColor:"#3b3b3b",chartBarNotFilledBorderColor:"#3b3b3b",chartBarHeight:"5",pollTitleFontFamily:"Arial",pollTitleFontSize:"10pt",pollTitleFontWeight:"bold",pollQuestionFontFamily:"Arial",pollQuestionFontSize:"10pt",pollQuestionFontWeight:"bold",pollChoiceTextFontFamily:"Arial",pollChoiceTextFontSize:"10pt"});$.extend(true,styles.greyRedStyle,defaultStyleAttributes,{image:"images/themes/greyRedStyle.png",divAroundPollBgColor:"#f5f5f5",pollTitleColor:"#9d3100",pollQuestionColor:"#9d3100",pollChoiceTextColor:"#9d3100",pollResultLinkTextColor:"#9d3100",pollResultLinkTextFontFamily:"Georgia",pollVoteButtonFontFamily:"Georgia",chartBarFilledColor:"#806666",chartBarFilledBorderColor:"#9d3100",chartBarNotFilledColor:"#f5f5f5",chartBarNotFilledBorderColor:"#9d3100",chartBarHeight:"7",pollTitleFontFamily:"Verdana",pollTitleFontSize:"9pt",pollTitleFontWeight:"bold",pollQuestionFontFamily:"Verdana",pollQuestionFontSize:"9pt",pollQuestionFontWeight:"bold",pollChoiceTextFontFamily:"Verdana",pollChoiceTextFontSize:"8pt",cornersStyle:"0px",divAroundPollPaddingTop:"7px",divAroundPollPaddingBottom:"3px"});$.extend(true,styles.goldenStyle,defaultStyleAttributes,{image:"images/themes/goldenStyle.png",divAroundPollBgColor:"#d2d57c",divAroundPollPaddingTop:"6px",divAroundPollPaddingBottom:"6px",divAroundPollPaddingLeft:"6px",divAroundPollPaddingRight:"6px",pollTitleColor:"#898501",pollTitleFontFamily:"Georgia",pollTitleFontSize:"9pt",pollQuestionColor:"#898501",pollQuestionFontFamily:"Georgia",pollQuestionFontSize:"9pt",pollQuestionFontWeight:"bold",pollChoiceTextColor:"#898501",pollChoiceTextFontFamily:"Verdana",pollResultLinkTextColor:"#9d9901",pollResultLinkTextFontFamily:"Courier New",pollResultLinkTextFontSize:"9pt",pollVoteButtonFontFamily:"Georgia",chartBarFilledColor:"#898501",chartBarFilledBorderColor:"#9d9901",chartBarNotFilledColor:"#f5f5f5",chartBarNotFilledBorderColor:"#9d9901",chartBarHeight:"7",cornersStyle:"2px"});$.extend(true,styles.greenStyle,defaultStyleAttributes,{image:"images/themes/greenStyle.png",divAroundPollBgColor:"#99db95",pollTitleColor:"#774A4A",pollQuestionColor:"#1b4918",pollChoiceTextColor:"#1b4918",pollResultLinkTextColor:"#1b4918",chartBarFilledColor:"#419c3a",chartBarFilledBorderColor:"#419c3a",chartBarNotFilledColor:"#9ab899",chartBarNotFilledBorderColor:"#9ab899"});$.extend(true,styles.blueGrayStyle,defaultStyleAttributes,{image:"images/themes/blueGrayStyle.png",divAroundPollBgColor:"#6a8daf",pollTitleColor:"#466D92",pollQuestionFontWeight:"bold",pollQuestionColor:"#f1f5f9",pollChoiceTextColor:"#f1f5f9",pollResultLinkTextColor:"#f1f5f9",chartBarFilledColor:"#d2dce4",chartBarFilledBorderColor:"#d2dce4",chartBarNotFilledColor:"#86a1bb",chartBarNotFilledBorderColor:"#86a1bb",cornersStyle:"7px"});$.extend(true,styles.blueGrayShadowStyle,defaultStyleAttributes,{image:"images/themes/blueGrayShadowStyle.png",divAroundPollBgColor:"#739abf",pollTitleColor:"#466D92",pollQuestionFontWeight:"bold",pollQuestionColor:"#f1f5f9",pollChoiceTextColor:"#f1f5f9",pollResultLinkTextColor:"#f1f5f9",chartBarFilledColor:"#d2dce4",chartBarFilledBorderColor:"#d2dce4",chartBarNotFilledColor:"#86a1bb",chartBarNotFilledBorderColor:"#86a1bb",cornersStyle:"7px",pollShadow:"3px 3px 7px 0px rgba(0,0,0,0.76)"});$.extend(true,styles.lightYellowStyle,defaultStyleAttributes,{image:"images/themes/lightYellowStyle.png",divAroundPollBgColor:"#fffc8a",pollTitleColor:"#774A4A",pollChoiceTextColor:"#4d4b00",pollResultLinkTextColor:"#4d4b00",chartBarFilledColor:"#c5c011",chartBarFilledBorderColor:"#c5c011",chartBarNotFilledColor:"#f8f7af",chartBarNotFilledBorderColor:"#e3e2ab",chartBarHeight:"6",cornersStyle:"7px"});$.extend(true,styles.orangeStyle,defaultStyleAttributes,{image:"images/themes/orangeStyle.png",divAroundPollBgColor:"#ffd280",pollTitleFontWeight:"bold",pollTitleColor:"#774A4A",pollQuestionColor:"#754c00",pollChoiceTextColor:"#754c00",pollResultLinkTextColor:"#754c00",chartBarFilledColor:"#cc8300",chartBarFilledBorderColor:"#cc8300",chartBarNotFilledColor:"#ffe4b3",chartBarNotFilledBorderColor:"#ffdea3",chartBarHeight:"6",cornersStyle:"7px"});$.extend(true,styles.whiteShadowStyle,defaultStyleAttributes,{image:"images/themes/whiteShadowStyle.png",divAroundPollBgColor:"#fff",pollTitleColor:"#777",pollQuestionColor:"#444",pollChoiceTextColor:"#444",pollResultLinkTextColor:"#444",chartBarFilledColor:"#777",chartBarFilledBorderColor:"#666",chartBarNotFilledColor:"#eee",chartBarNotFilledBorderColor:"#ddd",pollShadow:"0px 0px 25px 0px rgba(0,0,0,0.61)"});function bBOPP(){jQuery.each(styles,function(theme,themeContent){$('#OPP-look-feel-td').append('<img src="'+themeContent.image+'" border="0" style="cursor: pointer;" class="OPP-tooltip-mouse" title="Set this style"> ').children(':last').css('padding','3px').bind('click',theme,aAOPP).addClass('OPP-preview-thumb');});};function aAOPP(event){pollData.style=$.extend(true,{},eval('styles.'+event.data));EOPP();};function EOPP(){$("#OPP-corner-radius").slider('value',pollData.style.cornersStyle.substring(0,pollData.style.cornersStyle.length-2));$("#OPP-corner-radius-value").text(pollData.style.cornersStyle);$("#OPP-bg-color").val(pollData.style.divAroundPollBgColor);$("#OPP-poll-shadow").val(pollData.style.pollShadow);$("#OPP-question-text-color").val(pollData.style.pollQuestionColor);$("#OPP-choice-text-color").val(pollData.style.pollChoiceTextColor);$("#OPP-see-results-text-color").val(pollData.style.pollResultLinkTextColor);$("#OPP-vote-button-text-color").val(pollData.style.pollVoteButtonColor);$("#OPP-opt-max-poll-width").slider('value',pollData.style.maxPollWidth);$("#OPP-opt-max-poll-width-value").text(pollData.style.maxPollWidth+"px");$("#OPP-chart-bar-filled-color").val(pollData.style.chartBarFilledColor);$("#OPP-chart-bar-filled-border-color").val(pollData.style.chartBarFilledBorderColor);$("#OPP-chart-bar-not-filled-color").val(pollData.style.chartBarNotFilledColor);$("#OPP-chart-bar-not-filled-border-color").val(pollData.style.chartBarNotFilledBorderColor);$("#OPP-chart-bar-height").val(pollData.style.chartBarHeight);$("#OPP-padding-left").slider('value',pollData.style.divAroundPollPaddingLeft.substring(0,pollData.style.divAroundPollPaddingLeft.length-2));$("#OPP-padding-left-value").text(pollData.style.divAroundPollPaddingLeft);$("#OPP-padding-right").slider('value',pollData.style.divAroundPollPaddingRight.substring(0,pollData.style.divAroundPollPaddingRight.length-2));$("#OPP-padding-right-value").text(pollData.style.divAroundPollPaddingRight);$("#OPP-padding-top").slider('value',pollData.style.divAroundPollPaddingTop.substring(0,pollData.style.divAroundPollPaddingTop.length-2));$("#OPP-padding-top-value").text(pollData.style.divAroundPollPaddingTop);$("#OPP-padding-bottom").slider('value',pollData.style.divAroundPollPaddingBottom.substring(0,pollData.style.divAroundPollPaddingBottom.length-2));$("#OPP-padding-bottom-value").text(pollData.style.divAroundPollPaddingBottom);$("#OPP-question-text-font").val(pollData.style.pollQuestionFontFamily);$("#OPP-question-text-size").val(pollData.style.pollQuestionFontSize.substring(0,pollData.style.pollQuestionFontSize.length-2));if(pollData.style.pollQuestionFontWeight=="bold"){$("#OPP-question-text-bold").css("opacity","1");}else{$("#OPP-question-text-bold").css("opacity","0.5");}if(pollData.style.pollQuestionFontStyle=="italic"){$("#OPP-question-text-italic").css("opacity","1");}else{$("#OPP-question-text-italic").css("opacity","0.5");}$("#OPP-choice-text-font").val(pollData.style.pollChoiceTextFontFamily);$("#OPP-choice-text-size").val(pollData.style.pollChoiceTextFontSize.substring(0,pollData.style.pollChoiceTextFontSize.length-2));if(pollData.style.pollChoiceTextFontWeight=="bold"){$("#OPP-choice-text-bold").css("opacity","1");}else{$("#OPP-choice-text-bold").css("opacity","0.5");}if(pollData.style.pollChoiceTextFontStyle=="italic"){$("#OPP-choice-text-italic").css("opacity","1");}else{$("#OPP-choice-text-italic").css("opacity","0.5");}$("#OPP-see-results-text-font").val(pollData.style.pollResultLinkTextFontFamily);$("#OPP-see-results-text-size").val(pollData.style.pollResultLinkTextFontSize.substring(0,pollData.style.pollResultLinkTextFontSize.length-2));if(pollData.style.pollResultLinkTextFontWeight=="bold"){$("#OPP-see-results-text-bold").css("opacity","1");}else{$("#OPP-see-results-text-bold").css("opacity","0.5");}if(pollData.style.pollResultLinkTextFontStyle=="italic"){$("#OPP-see-results-text-italic").css("opacity","1");}else{$("#OPP-see-results-text-italic").css("opacity","0.5");}$("#OPP-vote-button-text-font").val(pollData.style.pollVoteButtonFontFamily);$("#OPP-vote-button-text-size").val(pollData.style.pollVoteButtonFontSize.substring(0,pollData.style.pollVoteButtonFontSize.length-2));if(pollData.style.pollVoteButtonFontWeight=="bold"){$("#OPP-vote-button-text-bold").css("opacity","1");}else{$("#OPP-vote-button-text-bold").css("opacity","0.5");}if(pollData.style.pollVoteButtonFontStyle=="italic"){$("#OPP-vote-button-text-italic").css("opacity","1");}else{$("#OPP-vote-button-text-italic").css("opacity","0.5");}hOPP();XOPP();};function TOPP(elem,valueElem,minValue,maxValue,step,defaultValue){elem.slider({range:"min",step:step,min:minValue,max:maxValue,value:defaultValue,orientation:"horizontal",slide:function(event,ui){valueElem.text(ui.value+'px');XOPP();hOPP();}});valueElem.text(defaultValue+'px');};function HOPP(){$.ajax({url:OPP_PG_BASEURL+"?command=getPolls"+"&skip="+$("#OPP-my-polls-table-list > div").size()+"&sort="+$("#OPP-my-polls-sort").val()+"&limit=25",type:"GET",dataType:"json",timeout:"20000",success:function(obj,textStatus){if(obj.resultCode==RESULT_CODE_OK){jQuery.each(obj.polls,function(index,value){var dFormat='M jS, Y \\i\\s \\h\\e\\r\\e!';aQOPP({pollId:obj.polls[index].pollId,name:obj.polls[index].name,hasPremiumFeature:obj.polls[index].hasPremiumFeature,lastResponseDate:obj.polls[index].lastResponseDate,createdDate:obj.polls[index].createdDate,updatedDate:obj.polls[index].updatedDate,votes:obj.polls[index].totalVotes,isOpen:obj.polls[index].open},true);});if(25<=obj.polls.length){$("#OPP-my-polls-table-more").show();}else{$("#OPP-my-polls-table-more").hide();}rOPP();}else if(obj.resultCode==RESULT_CODE_NOT_LOGGED_IN){$('#OPP-dialog-login').dialog('option','buttons',{'Login':function(){sOPP(true,function(){HOPP();});},Cancel:function(){$(this).dialog('close');}}).dialog('open');}else{BOPP("Error occurred, error code: "+obj.resultCode,true,$("#OPP-my-polls-validate-tips"));}},error:function(XMLHttpRequest,textStatus){BOPP("Error occurred, status: "+textStatus,true,$("#OPP-my-polls-validate-tips"));}});};function aQOPP(pollInfo,atEnd){var pollInfoHtml="<div class='OPP-pollInfo'>"+"<span>votes: "+pollInfo.votes+"</span>"+"<span>last response: "+(pollInfo.lastResponseDate?(new Date(pollInfo.lastResponseDate)).toString('d-MMM-yyyy HH:mm'):"never")+"</span>"+"<span>created: "+(pollInfo.createdDate?(new Date(pollInfo.createdDate)).toString('d-MMM-yyyy HH:mm'):"never")+"</span>"+"<span>updated: "+(pollInfo.updatedDate?(new Date(pollInfo.updatedDate)).toString('d-MMM-yyyy HH:mm'):"never")+"</span>"+"</div>";var html="<div id='"+pollInfo.pollId+"' class='OPP-pollName "+(pollInfo.isOpen?"":"OPP-closed")+"'>"+"<div class='OPP-nameAndButtons'>"+"<span class='OPP-action'> "+"<span class='OPP-showPoll ui-button ui-widget ui-state-default ui-corner-all' style='vertical-align:top'>"+"<span style='display: inline; float: left' class='OPP-reports-icon ui-icon ui-icon-carat-1-s'></span>"+"reports"+"</span> "+"<span class='OPP-openClosePoll "+(pollInfo.isOpen?"poll-is-open":"poll-is-closed")+" ui-button ui-widget ui-state-default ui-corner-all' style='vertical-align:top' title='"+(!pollInfo.isOpen?"open poll":"close poll")+"' >"+"<span style='display: inline; float: left' class='OPP-reports-icon ui-icon "+(pollInfo.isOpen?"ui-icon-unlocked":"ui-icon-locked")+" '></span>"+"</span> "+"<span class='OPP-deletePoll ui-button ui-widget ui-state-default ui-corner-all' title='delete poll'>"+"<span style='display: inline; float: left' class='ui-icon ui-icon-trash'></span>"+"</span>"+"</span>"+"<div class='OPP-pollNameText OPP-pointer' title='Click to edit poll.'>"+pollInfo.name+"</div>"+pollInfoHtml+" </div>"+"</div>";var added=false;var $pollList=$("#OPP-my-polls-table-list .OPP-pollName");var listSize=$pollList.size();if(!atEnd){var sort=$("#OPP-my-polls-sort").val();$pollList.each(function(i){switch(sort){case SORT_QUESTION_TEXT:if(pollInfo.name.toLowerCase()<=$(this).data("name").toLowerCase()){$(this).before(html);added=true;return false;}break;case SORT_CREATED_DATE:if(parseInt($(this).data("createdDate"))<=parseInt(pollInfo.createdDate)&&i<listSize){$(this).before(html);added=true;return false;}break;case SORT_UPDATED_DATE:if($(this).data("updatedDate")<=pollInfo.updatedDate&&i<listSize){$(this).before(html);added=true;return false;}break;case SORT_RESPONSE_DATE:if($(this).data("lastResponseDate")<=pollInfo.lastResponseDate&&i<listSize){$(this).before(html);added=true;return false;}break;case SORT_TOTAL_VOTES:if($(this).data("votes")<=pollInfo.votes&&i<listSize){$(this).before(html);added=true;return false;}break;}});}if(!added&&(atEnd||($("#OPP-my-polls-table-more").is(":hidden")&&listSize<25))){$("#OPP-my-polls-table-list").append(html);added=true;}if(added){$("#"+pollInfo.pollId).bind('click',pollInfo.pollId,aaOPP);$("#"+pollInfo.pollId).data("hasPremiumFeature",pollInfo.hasPremiumFeature);$("#"+pollInfo.pollId).data("name",pollInfo.name);$("#"+pollInfo.pollId).data("createdDate",pollInfo.createdDate);$("#"+pollInfo.pollId).data("updatedDate",pollInfo.updatedDate);$("#"+pollInfo.pollId).data("lastResponseDate",pollInfo.lastResponseDate);$("#"+pollInfo.pollId).data("votes",pollInfo.votes);bqOPP($("#"+pollInfo.pollId));}};function bqOPP(element){DOPP(element.find('.OPP-pollNameText'),{position:{adjust:{x: -10,y: -10}}});};function wOPP(pollId){if($("#"+pollId).next().hasClass('OPP-poll-preview-result')){$("#"+pollId).next().remove();}$("#"+pollId+" td").unbind('click');$("#"+pollId).remove();rOPP();};function amOPP(){$("#OPP-my-polls-table-list > div").remove();rOPP();};function rOPP(){if(0<$("#OPP-my-polls-table-list div").length){$(".OPP-reports-icon ui-icon.ui-icon-carat-1-s").click();$("#OPP-no-polls-text").hide();$("#OPP-my-polls-table").show();}else{$("#OPP-no-polls-text").show();$("#OPP-my-polls-table").hide();}};function aaOPP(event){if($(event.target).hasClass('OPP-pollNameText')){aOOPP(event.data);}else if(0<$(event.target).find('.ui-icon-carat-1-s').size()||0<$(event.target).parents('.OPP-showPoll').find('.ui-icon-carat-1-s').size()){dOPP(event);}else if($(event.target).hasClass('OPP-showPoll')||0<$(event.target).parents('.OPP-showPoll').find('.ui-icon-carat-1-n').size()){$(event.target).parents(".OPP-action").find(".OPP-reports-icon").toggleClass('ui-icon-carat-1-s').toggleClass('ui-icon-carat-1-n');$(event.target).parents(".OPP-pollName").find(".OPP-poll-preview-result").remove();$(event.target).parents(".OPP-pollName").animate({height:36},function(){});}else if($(event.target).hasClass('OPP-openClosePoll')||0<$(event.target).parents('.OPP-openClosePoll').size()){axOPP(event.data);}else if($(event.target).hasClass('OPP-deletePoll')||0<$(event.target).parents('.OPP-deletePoll').size()){tOPP(event.data);}};function dOPP(event){$(event.target).parents(".OPP-action").find(".OPP-reports-icon").toggleClass('ui-icon-carat-1-s').toggleClass('ui-icon-carat-1-n');$(event.target).parents(".OPP-pollName").append('<div style="" id="OPP-poll-preview-result'+event.data+'" class="OPP-poll-preview-result"></div>').animate({height:230},150,function(){$(this).find("#OPP-poll-preview-result"+event.data).html("<span align='center'><span id='OPP-poll-id-"+event.data+"p'>Loading...</span></span>"+"<span align='center'><span align='center' id='OPP-poll-id-"+event.data+"pr'></span></span>"+"<span align='center'>"+"<span align='center' id='OPP-poll-id-"+event.data+"pglow' class='OPP-geo-location-chart-outer-wrapper'>"+"<span align='center' id='OPP-poll-id-"+event.data+"pglw' class='OPP-geo-location-chart-wrapper'>"+"<span class='OPP-geo-map-title'>Location Tracking</span>"+"<span class='OPP-geo-map-note'></span>"+"<button class='ui-button ui-widget ui-state-default ui-corner-all OPP-geo-map-expand' title=''>"+"<span id='OPP-icon-expand' class='ui-icon ui-icon-newwin'></span>"+"</button>"+"<button class='ui-button ui-widget ui-state-default ui-corner-all OPP-geo-map-load-next-block' title='load 100 earlier responses'>"+"<span id='OPP-icon-next-block' class='ui-icon ui-icon-arrowrefresh-1-s'></span>"+"</button>"+"<span align='center' id='OPP-poll-id-"+event.data+"pgl' class='OPP-geo-location-chart'></span>"+"</span>"+"</span>"+"</span>").hide().fadeIn();aCOPP(event,function(data){akOPP(event,data);});});};function aCOPP(event,callback){$.ajax({url:OPP_PG_BASEURL+"?command=getPoll&pollId="+event.data,type:"GET",dataType:"json",timeout:"10000",success:function(data,textStatus){if(data.resultCode==RESULT_CODE_OK){var tmpstyle;var orgPollId=data.pollId;data.style={};eval("tmpstyle = "+data.styleString);$.extend(true,data.style,defaultStyleAttributes,tmpstyle);data.pollId=data.pollId+"p";var $pollView=$("#OPP-poll-id-"+data.pollId);$pollView.pollOPP('init',{poll:data,mode:"preview"});$("*",$pollView).unbind("click");data.pollId=data.pollId+"r";var $chartView=$("#OPP-poll-id-"+data.pollId);$chartView.empty().append($pollView.clone("true"));$chartView.pollOPP('chart',{poll:data});$("*",$chartView).unbind("click");AOPP("#OPP-poll-preview-result"+orgPollId+" .OPP-powered-by-div",true,orgPollId);var pollHeight=$pollView.parents("#OPP-poll-preview-result"+orgPollId).height();var textHeight=$pollView.parents(".OPP-pollName").find(".OPP-pollNameText").height();$pollView.parents(".OPP-pollName").height(pollHeight+textHeight+25);$pollView.parents(".OPP-pollName").find(".OPP-powered-by-div").css("text-align","center");if(callback){data.pollId=orgPollId;callback(data);}}else if(data.resultCode==RESULT_CODE_NOT_LOGGED_IN){$(event.target).parents(".OPP-action").find(".OPP-reports-icon").toggleClass('ui-icon-carat-1-s').toggleClass('ui-icon-carat-1-n');$(event.target).parents(".OPP-pollName").find(".OPP-poll-preview-result").remove();$(event.target).parents(".OPP-pollName").animate({height:32},function(){});$('#OPP-dialog-login').dialog('option','buttons',{'Login':function(){sOPP(true);dOPP(event);},Cancel:function(){$(this).dialog('close');}}).dialog('open');}else{BOPP("Error occurred, error code: "+data.resultCode,true,$("#OPP-my-polls-validate-tips"));}},error:function(XMLHttpRequest,textStatus){$(event.target).parents(".OPP-action").find(".OPP-reports-icon").toggleClass('ui-icon-carat-1-s').toggleClass('ui-icon-carat-1-n');$(event.target).parent().next().animate({height:0},function(){$(this).remove();}).html("");BOPP("Error occurred, status: "+textStatus,true,$("#OPP-my-polls-validate-tips"));}});};function akOPP(event,data){$("#OPP-poll-id-"+event.data+"pgl").geoLocationReport({data:data});ROPP("#OPP-poll-id-"+event.data+"pglow .OPP-enable-geo-loc",true,event.data);};function axOPP(pollId){var openCloseElement=$("#"+pollId).find('.OPP-openClosePoll');var action=openCloseElement.hasClass("poll-is-open")?"closePoll":"openPoll";var params={command:action,pollId:pollId};$.ajax({url:OPP_PG_BASEURL,type:"GET",data:params,dataType:"json",timeout:"10000",success:function(data){if(data.resultCode==RESULT_CODE_OK){BOPP("Poll was closed.",true,$("#OPP-design-poll-tips"),10000);if(action=="closePoll"){openCloseElement.removeClass("poll-is-open").addClass("poll-is-closed").attr("title","open poll").find('.ui-icon').removeClass('ui-icon-unlocked').addClass('ui-icon-locked').parents(".OPP-pollName").addClass("OPP-closed");BOPP("Poll was closed.",true,$('#OPP-my-polls-validate-tips'),10000);}else{openCloseElement.removeClass("poll-is-closed").addClass("poll-is-open").attr("title","close poll").find('.ui-icon').removeClass('ui-icon-locked').addClass('ui-icon-unlocked').parents(".OPP-pollName").removeClass("OPP-closed");BOPP("Poll was opened.",true,$('#OPP-my-polls-validate-tips'),10000);}}else if(data.resultCode==RESULT_CODE_NOT_LOGGED_IN){$('#OPP-dialog-login').dialog('option','buttons',{'Login':function(){sOPP(true);},Cancel:function(){$(this).dialog('close');}}).dialog('open');}},error:function(data){if(action=="closePoll"){BOPP("Could not close poll",true,$("#OPP-my-polls-validate-tips"));}else{BOPP("Could not open poll",true,$("#OPP-my-polls-validate-tips"));}}});};function tOPP(pollId){$("#OPP-yes-no-message-value").html("Are you sure you want to delete the poll? "+($("#"+pollId).data("hasPremiumFeature")?"<br><br><div class='OPP-bold'>Note: poll has at least one premium feature enabled.</div>":""));$("#OPP-yes-no-message").dialog({autoOpen:false,show:'scale',hide:'scale',modal:'true',title:'Confirm delete',close:function(){$(this).dialog('destroy');},buttons:{'Yes':function(){$(this).dialog('close');$.ajax({url:OPP_PG_BASEURL+"?command=deletePoll&pollId="+pollId,type:"GET",dataType:"json",timeout:"5000",success:function(obj,textStatus){if(obj.resultCode==RESULT_CODE_OK){wOPP(obj.pollId);if(pollData.pollId==pollId){JOPP();BOPP("Poll was deleted.",true,$("#OPP-design-poll-tips"));}BOPP("Poll was deleted.",true,$('#OPP-my-polls-validate-tips'),10000);}else if(obj.resultCode==RESULT_CODE_NOT_LOGGED_IN){$('#OPP-dialog-login').dialog('option','buttons',{'Login':function(){sOPP(true);},Cancel:function(){$(this).dialog('close');}}).dialog('open');}else{BOPP("Could not delete poll. Code: "+obj.resultCode,true,$("#OPP-my-polls-validate-tips"));}},error:function(data){BOPP("Could not delete poll",true,$("#OPP-my-polls-validate-tips"));}});},'No':function(){$(this).dialog('close');}}}).dialog("open");};function ahOPP(){$('#a').click();JOPP();};function aOOPP(pollId){var params={command:"getPoll",pollId:pollId};$.ajax({url:OPP_PG_BASEURL,type:"GET",data:params,dataType:"json",timeout:"10000",success:function(data){if(data.resultCode==RESULT_CODE_OK){$(".OPP-poll-preview #OPP-div-around-poll").width(200);$('#a').click();var tmpstyle;pollData.style={};eval("tmpstyle = "+data.styleString);$.extend(true,pollData.style,defaultStyleAttributes,tmpstyle);EOPP();$('#OPP-ad-enabled').val(data.adEnabled+"");$('#OPP-question-text').val(data.question);pollData.question=data.question;for(i=0;i<$("#OPP-choice-tables input").size();i++){eval('pollData.choice'+i+'= ""');}while($("#OPP-choice-tables input").size()>3){$("OPP-choice-tables").append($("#OPP-choice-tables").children(":first").remove());}var choiceNumber=0;var choiceText=eval("data.choice"+choiceNumber);while(choiceText){eval('$("#OPP-choice-tables input:eq('+choiceNumber+')").val(choiceText)');anOPP();choiceNumber++;choiceText=eval("data.choice"+choiceNumber);}YOPP();xOPP();if(data.pollChoiceType=="checkbox"){$('#OPP-opt-multiple-selections').attr('checked',true);}else{$('#OPP-opt-multiple-selections').attr('checked',false);}$('#OPP-opt-vote-button-label').val(data.voteButtonText);$('#OPP-opt-see-results-label').val(data.resultLinkText);$('#OPP-opt-total-votes-label').val(data.totalVotesText);$('#OPP-opt-poll-closed-label').val(data.pollClosedText);if(data.antiCheatLevel=="2"){$('#OPP-opt-advanced-anti-cheat').attr('checked',true);}else{$('#OPP-opt-advanced-anti-cheat').attr('checked',false);}$('#OPP-opt-rtl-enabled').attr('checked',data.rtlEnabled);pollData.pollId=data.pollId;pollData.reportData=data.reportData;pollData.responseCount=data.responseCount;pollData.anchorText=data.anchorText;pollData.anchorUrl=data.anchorUrl;pollData.adEnabled=data.adEnabled;pollData.rtlEnabled=data.rtlEnabled;pollData.isOpen=data.open;uOPP({adDisabled:(data.adEnabled?false:true),geoLocationEnabled:(data.geoLocationEnabled?true:false)});if(!pollData.anchorText){pollData.anchorText="surveys & polls"}pollData.createdDate=$("#"+data.pollId).data("createdDate");pollData.updatedDate=$("#"+data.pollId).data("updatedDate");qOPP();VOPP();ROPP("#OPP-premium-geo-loc",true);AOPP("#OPP-premium-ad-free",true);nOPP(500);}else if(data.resultCode==RESULT_CODE_NOT_LOGGED_IN){$('#OPP-dialog-login').dialog('option','buttons',{'Login':function(){sOPP(true);},Cancel:function(){$(this).dialog('close');}}).dialog('open');}},error:function(XMLHttpRequest,textStatus){BOPP("Error occurred, status: "+textStatus,true,$("#OPP-my-polls-validate-tips"));}});}(function($){$.fn.geoLocationReport=function(options){var self;var map;var lastResponseId="";var responsesLoaded;var notRecognizedLocations;var markers;var currentMarker;var geoLocationEnabled=false;var data;self=this.eq(0);self.removeClass("OPP-geo-map-preview").children().remove();var data=(options.data?$.extend(true,{},options.data):self.data("data"));self.data("data",data);geoLocationEnabled=(data.geoLocationEnabled||options.geoLocationEnabled?true:false);self.get(0).loadNextBlock=function(){if(!geoLocationEnabled){return;}$("#OPP-poll-id-"+data.pollId+"pglw").find(".OPP-geo-map-load-next-block").attr('disabled','disabled').addClass("ui-state-disabled");$.ajax({url:OPP_PG_BASEURL+"?command=getResponseLocationArray&pollId="+data.pollId+(lastResponseId?"&fromResponseId="+lastResponseId:""),type:"GET",dataType:"json",timeout:"10000",success:function(data,textStatus){if(data.resultCode==RESULT_CODE_OK){var options={responseLocations:data.responseLocations,choices:data.choices};addMarkers(map,options);var $nextBlockButton=$("#OPP-poll-id-"+data.pollId+"pglw").find(".OPP-geo-map-load-next-block");if(data.lastResponseId){lastResponseId=data.lastResponseId;$nextBlockButton.removeAttr('disabled').removeClass("ui-state-disabled");}responsesLoaded+=options.responseLocations.length;var responsesDisplayed=responsesLoaded-notRecognizedLocations;var responsesLoadedNote=responsesDisplayed+" / "+responsesLoaded;var $geoMapNote=$("#OPP-poll-id-"+data.pollId+"pglw").find(".OPP-geo-map-note");$geoMapNote.text(responsesLoadedNote);var tooltipText="Found "+responsesDisplayed+" locations out of last "+responsesLoaded+" responses";$geoMapNote.attr("title",tooltipText);}},error:function(XMLHttpRequest,textStatus){vOPP("Error loading locations","An error occured while loading locations. More details: "+textStatus);}});};self.get(0).adjustMapBig=function(){if(map.getZoom()<2){map.setZoom(2);map.setCenter(new google.maps.LatLng(20,0));}};self.get(0).adjustMapSmall=function(){if(map.getZoom()<=2){map.setZoom(1);map.setCenter(new google.maps.LatLng(50,0));}};self.get(0).getLastResponseId=function(){return lastResponseId;};var addMarkers=function(map,options){for(var i=0;i<options.responseLocations.length;i++){var location=options.responseLocations[i];var latitude=location.latitude;var longitude=location.longitude;if(latitude==0&&longitude==0){notRecognizedLocations++;}else{var myLatlng=new google.maps.LatLng(latitude,longitude);for(var m=0;m<markers.length;m++){if(myLatlng.lat()==markers[m].getPosition().lat()&&myLatlng.lng()==markers[m].getPosition().lng()){if(location.city){latitude+=(Math.random()-0.5)*0.1;longitude+=(Math.random()-0.5)*0.1;}else{latitude+=(Math.random()-0.5)*1;longitude+=(Math.random()-0.5)*1;}myLatlng=new google.maps.LatLng(latitude,longitude);}}var responseString=location.countryCode;if(location.city){responseString+=", "+location.city}responseString+="\n-----\n";for(var j=0;j<location.responseValues.length;j++){var choiceNum=location.responseValues[j];responseString+=options.choices[choiceNum]+'\n';}var marker=new google.maps.Marker({position:myLatlng,title:responseString,icon:(location.city?pinRedImage:pinRoseImage),shadow:pinShadow});marker.setMap(map);markers[currentMarker]=marker;currentMarker++;}}};if(geoLocationEnabled){var pinRedImage=new google.maps.MarkerImage('images/pinRed.png',new google.maps.Size(25,25),new google.maps.Point(0,0),new google.maps.Point(7,25));var pinRoseImage=new google.maps.MarkerImage('images/pinRose.png',new google.maps.Size(25,25),new google.maps.Point(0,0),new google.maps.Point(7,25));var pinShadow=new google.maps.MarkerImage('images/pinShadow.png',new google.maps.Size(25,25),new google.maps.Point(0,0),new google.maps.Point(7,25));var myOptions={zoom:1,center:new google.maps.LatLng(50,0),streetViewControl:false,mapTypeControl:false,mapTypeId:google.maps.MapTypeId.ROADMAP};map=new google.maps.Map(self.get(0),myOptions);responsesLoaded=0;notRecognizedLocations=0;markers=new Array();currentMarker=0;self.get(0).loadNextBlock();}else{$(this).append("<div id='OPP-geo-map-preview-msg'><div class='OPP-bold'>Location tracking is not enabled.</div>  <p>Locations will be collected and tracked only after feature is enabled.</div>");$(this).addClass("OPP-geo-map-preview");}$(this).parents(".OPP-geo-location-chart-wrapper").resize(function(){if(map){google.maps.event.trigger(map,"resize");}});this.parent().css("background-color",data.style.divAroundPollBgColor).css("-moz-border-radius",data.style.cornersStyle).css("border-radius",data.style.cornersStyle).css('-moz-box-shadow',data.style.pollShadow).css('-webkit-box-shadow',data.style.pollShadow).css('box-shadow',data.style.pollShadow).parent().append((geoLocationEnabled?"":"<span class='OPP-enable-geo-loc'>enable location tracking</span>")).find(".OPP-geo-map-title").css("color",data.style.pollQuestionColor);;this.parent().parent().find(".OPP-geo-map-note").css("color",data.style.pollQuestionColor);}})(jQuery);$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);function UOPP(o,n,min,max,highlight,tips){if(o.val().length>max||o.val().length<min){o.addClass('ui-state-error');BOPP("Length of "+n+" must be between "+min+" and "+max+".",highlight,tips);return false;}else{BOPP('&nbsp;',false,tips);return true;}};function SOPP(p1,p2,highlight,tips){if(p1.val()!=p2.val()){p1.addClass('ui-state-error');p2.addClass('ui-state-error');BOPP("Passwords are not identical",highlight,tips);return false;}else{BOPP('&nbsp;',false,tips);return true;}};function eOPP(o,regexp,n,highlight,tips){if(!(regexp.test(o.val()))){o.addClass('ui-state-error');BOPP(n,highlight,tips);return false;}else{BOPP('&nbsp;',false,tips);return true;}};function COPP(emailField,highlight,tips){if(UOPP(emailField,"email",6,200,highlight,tips)){return eOPP(emailField,/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,"Invalid e-mail address.",highlight,tips);}return false;};function aoOPP(emailField,highlight){BOPP('Creating account...',false,$("#OPP-register-validate-tips"),10000);var params={command:"addUser",email:emailField.val(),password:$("#OPP-register-password").val()};$.ajax({url:OPP_PG_BASEURL,type:"POST",data:params,dataType:"json",height:"500",timeout:"10000",success:function(data){if(data.resultCode==RESULT_CODE_OK){pollUserId=data.pollUserId;$("#OPP-dialog-account").dialog('close');OOPP('Account created','Account was created successfully. An email was sent to you with a link to activate your account.');OPPpollAddress=data.serverAddress;OPPpollPage=data.connectorPollPage;OPPpollPageJsp=data.connectorPollPageJsp;OPPembedScript=data.embedScript;OPPemail=emailField.val();$("#OPP-login-email").val(OPPemail);OPPaccStatus=data.accountStatus;LOPP("login");if($("#OPP-save-poll-button").attr('disabled')==true){yOPP();}return;}else if(data.resultCode==RESULT_CODE_EMAIL_EXISTS){emailField.addClass('ui-state-error');BOPP('E-mail address already exists.',highlight,$("#OPP-register-validate-tips"));return;}else{BOPP('An error has occurred. Please try again later.',true,$("#OPP-register-validate-tips"));}},error:function(XMLHttpRequest,textStatus){BOPP("Error occurred, status: "+textStatus,true,$("#OPP-register-validate-tips"));}});};function pOPP(passwordField,highlight,tips){if(UOPP(passwordField,"password",5,50,highlight,tips)){return eOPP(passwordField,/^([0-9a-zA-Z])+$/,"Password field only allow : a-z 0-9",highlight,tips);}return false;};function bTOPP(highlight){BOPP('Sending...',false,$("#OPP-request-pw-validate-tips"));var params={command:"emailExists",email:$("#OPP-request-pw-email").val()};$.ajax({url:OPP_PG_BASEURL,type:"POST",data:params,dataType:"json",timeout:"10000",success:function(data){if(data.resultCode==RESULT_CODE_OK){if(data.result=='true'){params={command:"requestPassword",email:$("#OPP-request-pw-email").val()};$.ajax({url:OPP_PG_BASEURL,type:"POST",data:params,dataType:"json",timeout:"10000",success:function(data){if(data.resultCode==RESULT_CODE_OK){$('#OPP-dialog-request-password').dialog('close');OOPP('Password sent','A new password has been sent to the specified e-mail address.');return;}else{BOPP('An error has occurred. Please try again later.',highlight,$("#OPP-request-pw-validate-tips"));return;}},error:function(XMLHttpRequest,textStatus){BOPP("Error occurred, status: "+textStatus,true,$("#OPP-request-pw-validate-tips"));}});}else{BOPP('E-mail does not exist.',true,$("#OPP-request-pw-validate-tips"));}}else{BOPP('An error has occurred. Please try again later.',highlight,$("#OPP-request-pw-validate-tips"));return;}},error:function(XMLHttpRequest,textStatus){BOPP("Error occurred, status: "+textStatus,true,$("#OPP-request-pw-validate-tips"));}});};function bzOPP(){var params={command:"updatePassword",password:$("#OPP-new-password1").val()};$.ajax({url:OPP_PG_BASEURL,type:"POST",data:params,dataType:"json",timeout:"10000",success:function(data){if(data.resultCode==RESULT_CODE_OK){$('#OPP-dialog-new-password').dialog('close');OOPP('New password set','Your new password is now set.');return;}else{BOPP('An error has occurred. Please try again later.',highlight,$("#OPP-new-password-tips"));return;}},error:function(XMLHttpRequest,textStatus){BOPP("Error occurred, status: "+textStatus,true,$("#OPP-new-password-tips"));}});};var oAuthWindow;var oAuthProvider;var OPP_SOCIAL_REDIRECT_URI=window.location.href+"socialLogin.html";var OPP_CLIENT_ID_FACEBOOK="150094718397820";var OPP_CLIENT_ID_GOOGLE="300361561803.apps.googleusercontent.com";var OPP_AUTHORIZATION_URL_FACEBOOK="https://www.facebook.com/dialog/oauth?display=popup"+"&client_id="+OPP_CLIENT_ID_FACEBOOK+"&scope=email"+"&redirect_uri="+encodeURI(OPP_SOCIAL_REDIRECT_URI)+"&response_type=token";ZOPP(OPP_AUTHORIZATION_URL_FACEBOOK);var OPP_AUTHORIZATION_URL_GOOGLE="https://accounts.google.com/o/oauth2/auth?"+"client_id="+OPP_CLIENT_ID_GOOGLE+"&response_type=token"+"&scope=https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"+"&redirect_uri="+encodeURI(OPP_SOCIAL_REDIRECT_URI);function gOPP(socialProvider){$('#OPP-dialog-login').dialog('close');$('#OPP-dialog-account').dialog('close');var winWidth=450;var winHeight=300;var authorizationUrl;if(socialProvider=="facebook"){authorizationUrl=OPP_AUTHORIZATION_URL_FACEBOOK;}else if(socialProvider=="google"){var winHeight=475;authorizationUrl=OPP_AUTHORIZATION_URL_GOOGLE;}var winX=window.innerWidth/2+window.screenX-winWidth/2;var winY=window.innerHeight/2+window.screenY-winHeight/2;var winParams="width="+winWidth+",height="+winHeight+",left="+winX+",top="+winY+",screenX="+winX+",screenY="+winY+",resizable=0";oAuthProvider=socialProvider;oAuthWindow=open(authorizationUrl,"oAuthWindow",winParams);};function bJOPP(verifyCode){var params={command:"socialLogin",provider:oAuthProvider,code:verifyCode};$.ajax({url:OPP_PG_BASEURL,type:"GET",data:params,dataType:"json",timeout:"30000",success:function(data,textStatus){if(data.resultCode==RESULT_CODE_OK){if(data.result=='true'){oAuthWindow.close();if(pollUserId!=data.pollUserId){pollUserId=data.pollUserId;OPPpollAddress=data.serverAddress;OPPpollPage=data.connectorPollPage;OPPpollPageJsp=data.connectorPollPageJsp;OPPembedScript=data.embedScript;OPPaccStatus=data.accountStatus;LOPP("login");}OPPremainingFunds=parseFloat(data.remainingFunds);}else{oAuthWindow.mOPP('Invalid login.');}}else{oAuthWindow.mOPP('An error has occurred. ErrorCode: '+data.resultCode+". "+data.resultCodeMessage);}},error:function(XMLHttpRequest,textStatus){oAuthWindow.mOPP("Error occurred, status: "+textStatus+". "+data.resultMessage);}});};function POPP(){var params={command:"updateUser",pollUserId:pollUserId,email:$("#OPP-update-acc-email").val(),firstName:$("#OPP-update-acc-first-name").val(),lastName:$("#OPP-update-acc-last-name").val(),address1:$("#OPP-update-acc-address1").val(),address2:$("#OPP-update-acc-address2").val(),city:$("#OPP-update-acc-city").val(),zipCode:$("#OPP-update-acc-zip-code").val(),province:$("#OPP-update-acc-province").val(),countryCode:$("#OPP-update-acc-country-code").val(),timezone:$("#OPP-update-acc-timezone").val(),password:$("#OPP-update-acc-password-2").val(),oldPassword:$("#OPP-update-acc-password").val()};QOPP();var bValid=true;if($("#OPP-update-acc-password-2").val()!=""){bValid=bValid&&pOPP($("#OPP-update-acc-password-2"),true,$("#OPP-update-acc-validate-tips"));bValid=bValid&&SOPP($("#OPP-update-acc-password-2"),$("#OPP-update-acc-password-3"),true,$("#OPP-update-acc-validate-tips"));}bValid=bValid&&COPP($("#OPP-update-acc-email"),true,$("#OPP-update-acc-validate-tips"));if(bValid){$.ajax({url:OPP_PG_BASEURL,type:"POST",data:params,dataType:"json",contentType:"application/x-www-form-urlencoded; charset=UTF-8",timeout:"10000",success:function(data,textStatus){if(data.resultCode==RESULT_CODE_OK){if(data.result=='true'){BOPP('Account information was saved.',true,$("#OPP-update-acc-validate-tips"),10000);OPPaccStatus=data.accountStatus;KOPP();$("#OPP-validate-email-button").hide();return;}else{BOPP('Error.',true,$("#OPP-update-acc-validate-tips"));return;}}else if(data.resultCode==RESULT_CODE_NOT_LOGGED_IN){$('#OPP-dialog-login').dialog('option','buttons',{'Login':function(){sOPP(true,POPP);},Cancel:function(){$(this).dialog('close');}}).dialog('open');}else if(data.resultCode==RESULT_CODE_INVALID_INPUT){BOPP('Could not save user information. Make sure that password and e-mail are correct.',true,$("#OPP-update-acc-validate-tips"));}else{BOPP('Could not save user information. Please try again later. ErrorCode: '+data.resultCode,true,$("#OPP-update-acc-validate-tips"));}},error:function(XMLHttpRequest,textStatus){BOPP("Error occurred when saving user information, status: "+textStatus,true,$("#OPP-update-acc-validate-tips"));}});}};function QOPP(){$("#OPP-update-acc-email").removeClass('ui-state-error');$("#OPP-update-acc-password").removeClass('ui-state-error');$("#OPP-update-acc-password-2").removeClass('ui-state-error');$("#OPP-update-acc-password-3").removeClass('ui-state-error');};function aIOPP(){$("#OPP-update-acc-email").val("");$("#OPP-update-acc-first-name").val("");$("#OPP-update-acc-last-name").val("");$("#OPP-update-acc-address1").val("");$("#OPP-update-acc-address2").val("");$("#OPP-update-acc-city").val("");$("#OPP-update-acc-zip-code").val("");$("#OPP-update-acc-province").val("");$("#OPP-update-acc-country-code").val("");$("#OPP-update-acc-timezone").val("");$("#OPP-update-acc-password").val("");$("#OPP-update-acc-password-2").val("");$("#OPP-update-acc-password-3").val("");OPPemail="";$("#OPP-remaining-funds").text("");OPPremainingFunds=0;QOPP();BOPP("",false,$("#OPP-update-acc-validate-tips"));};function bgOPP(){var params={command:"getUser"};$.ajax({url:OPP_PG_BASEURL,type:"GET",data:params,dataType:"json",timeout:"10000",success:function(data,textStatus){if(data.resultCode==RESULT_CODE_OK){$("#OPP-update-acc-email").val(data.email);$("#OPP-update-acc-first-name").val(data.firstName);$("#OPP-update-acc-last-name").val(data.lastName);$("#OPP-update-acc-address1").val(data.address1);$("#OPP-update-acc-address2").val(data.address2);$("#OPP-update-acc-city").val(data.city);$("#OPP-update-acc-zip-code").val(data.zipCode);$("#OPP-update-acc-province").val(data.province);$("#OPP-update-acc-country-code").val(data.countryCode);$("#OPP-update-acc-timezone").val(data.timezone);$("#OPP-update-acc-password").val("");$("#OPP-update-acc-password-2").val("");$("#OPP-update-acc-password-3").val("");$("#OPP-remaining-funds").text(Math.round(data.remainingFunds*100)/100);OPPremainingFunds=parseFloat(data.remainingFunds);OPPemail=data.email;if(data.firstName){$("#OPP-welcome-msg").html("Welcome, "+data.firstName);}else{$("#OPP-welcome-msg").html("Welcome, "+OPPemail);}$("#OPP-welcome-msg").show();}else{BOPP('Could not load user information. Please try again later. ErrorCode: '+data.resultCode,true,$("#OPP-update-acc-validate-tips"));}},error:function(XMLHttpRequest,textStatus){BOPP("Error occurred when loading user information, status: "+textStatus,true,$("#OPP-update-acc-validate-tips"));}});};function bIOPP(){if(OPPemail==$("#OPP-update-acc-email").val()){var params={command:"requestCode"};$.ajax({url:OPP_PG_BASEURL,type:"GET",data:params,dataType:"json",timeout:"10000",success:function(data,textStatus){if(data.resultCode==RESULT_CODE_OK){BOPP('An email with a new activation code has been sent to your e-mail address.',true,$("#OPP-update-acc-validate-tips"),8000);$("#OPP-validate-email-button").hide();}else{BOPP('Could not send e-mail. Please try again later. ErrorCode: '+data.resultCode,true,$("#OPP-update-acc-validate-tips"));}},error:function(XMLHttpRequest,textStatus){BOPP("Error occurred when loading user information, status: "+textStatus,true,$("#OPP-update-acc-validate-tips"));}});}else{vOPP('Invalid choice','You have changed your e-mail address. Press update to receive the activation code to your new e-mail address.');}};function acOPP(){$("#OPP-yes-no-message-value").html("Are you sure you want to delete your account?"+(0<OPPremainingFunds?"<br><br><div class='OPP-bold'>Note: Your have funds in your account!</div>":""));$("#OPP-yes-no-message").dialog({autoOpen:false,show:'scale',hide:'scale',modal:'true',title:'Confirm delete',close:function(){$(this).dialog('destroy');},buttons:{'Yes':function(){$(this).dialog('close');var params={command:"deleteUser",pollUserId:pollUserId,email:OPPemail};$.ajax({url:OPP_PG_BASEURL,type:"GET",data:params,dataType:"json",timeout:"5000",success:function(obj,textStatus){if(obj.resultCode==RESULT_CODE_OK){bnOPP();}else if(obj.resultCode==RESULT_CODE_NOT_LOGGED_IN){$('#OPP-dialog-login').dialog('option','buttons',{'Login':function(){sOPP(true);},Cancel:function(){$(this).dialog('close');}}).dialog('open');}else{BOPP("Could not delete account. Code: "+obj.resultCode,true,$("#OPP-update-acc-validate-tips"));}},error:function(data){BOPP("Could not delete account",true,$("#OPP-update-acc-validate-tips"));}});},'No':function(){$(this).dialog('close');}}}).dialog("open");};function ZOPP(text){var $OPPDebug=$('#OPP-debug');if(0==$OPPDebug.size()){$OPPDebug=$("<div id='OPP-debug'></div>").appendTo("body");}$OPPDebug.append(text);};String.prototype.bool=function(){return(/^true$/i).test(this);};Date.prototype.ISODateString=function(d){function pad(n){return n<10?'0'+n:n};if(!d)d=this;return d.getUTCFullYear()+'-'+pad(d.getUTCMonth()+1)+'-'+pad(d.getUTCDate())+'T'+pad(d.getUTCHours())+':'+pad(d.getUTCMinutes())+':'+pad(d.getUTCSeconds())+'Z'};function zOPP(time){ZOPP(time+"<br>");var date=new Date((time||"").replace(/-/g,"/").replace(/[TZ]/g," ")),diff=(((new Date()).getTime()-date.getTime())/1000),day_diff=Math.floor(diff/86400);if(isNaN(day_diff)||day_diff<0||day_diff>=31)return;return day_diff==0&&(diff<60&&"just now"||diff<120&&"1 minute ago"||diff<3600&&Math.floor(diff/60)+" minutes ago"||diff<7200&&"1 hour ago"||diff<86400&&Math.floor(diff/3600)+" hours ago")||day_diff==1&&"Yesterday"||day_diff<7&&day_diff+" days ago"||day_diff<31&&Math.ceil(day_diff/7)+" weeks ago";};if(typeof jQuery!="undefined")jQuery.fn.zOPP=function(){return this.each(function(){var date=zOPP(this.title);if(date)jQuery(this).text(date);});};$.fn.positionOn=function(element,halign,valign){return this.each(function(){var target=$(this);var position=element.position();var x=position.left;var y=position.top;if(halign=='right'){x-=(target.outerWidth()-element.outerWidth());}else if(halign=='center'){x-=target.outerWidth()/2-element.outerWidth()/2;}if(valign&&valign=='middle'){y-=target.outerHeight()/2-element.outerHeight()/2;}target.css({position:'absolute',zIndex:5000,top:y,left:x});});};(function($){$.fn.shadowEditor=function(method){var $self;var values={size:0,hoffset:0,voffset:0,blur:0,transparency:0,color:'',inset:false};var methods={init:function(options){$self=this;$self.data("values",values);$self.data("shadowStringField",options.shadowStringField);$self.html("<div id='OPP-shadow-editor'>"+"<div style='display: inline-block; width: 330px; padding-left:5px; vertical-align: top;'>"+"<div style='height: 8px; '></div>"+"<div style='width: 100px; display:inline-block; vertical-align: top;'>Size: </div>"+"<div id='OPP-shadow-size' style='width: 200px;display: inline-block; margin-bottom: 20px;'></div>"+"<div style='width: 100px; display:inline-block; vertical-align: top;'>H-offset: </div>"+"<div id='OPP-shadow-hoffset' style='width: 200px;display: inline-block; margin-bottom: 20px;'></div>"+"<div style='width: 100px; display:inline-block; vertical-align: top;'>V-offset: </div>"+"<div id='OPP-shadow-voffset' style='width: 200px;display: inline-block; margin-bottom: 20px;'></div>"+"<div style='width: 100px; display:inline-block; vertical-align: top;'>Blur: </div>"+"<div id='OPP-shadow-blur' style='width: 200px;display: inline-block; margin-bottom: 20px;'></div>"+"<div style='width:100px; display: inline-block; vertical-align: top;'>Transparency:</div>"+"<div id='OPP-shadow-transparency' style='width: 200px;display: inline-block; margin-bottom: 20px;'></div>"+"<div style='display: inline-block; width:100px'>Inside:</div>"+"<div id='OPP-shadow-inset-div' style='display: inline-block; width: 20px;'>"+"<input type='checkbox' id='OPP-shadow-inset' title='' class='ui-widget-content ui-corner-all'>"+"</div>"+"</div>"+"<div id='OPP-shadow-color-picker' style='display: inline-block;'>"+"</div>"+"</div>");createSlider($self.find("#OPP-shadow-size"),0,25);createSlider($self.find("#OPP-shadow-transparency"),0,100);createSlider($self.find("#OPP-shadow-hoffset"),-25,25);createSlider($self.find("#OPP-shadow-voffset"),-25,25);createSlider($self.find("#OPP-shadow-blur"),0,50);$self.data("colorPicker",$.farbtastic('#OPP-shadow-color-picker'));$self.data("colorPicker").linkTo(function(){updateField();});$("#OPP-shadow-inset").bind('click',function(){if(0<$('#OPP-shadow-inset-div :checked').length){inset='inset';}else{inset='';}updateField();});this.shadowEditor('applyShadowString');return this;},getShadowString:function(){$self=this;$self.data("values",($self.data("values")?$self.data("values"):values));values=$self.data("values");return getShadowString();},applyShadowString:function(){$self=this;$self.data("values",($self.data("values")?$self.data("values"):values));values=$self.data("values");var strValues=$($self.data("shadowStringField")).val().split(' ');values.hoffset=strValues[0].replace("px","");values.voffset=strValues[1].replace("px","");values.blur=strValues[2].replace("px","");values.size=strValues[3].replace("px","");values.transparency=GOPP(strValues[4]);values.color=fOPP(strValues[4]);values.inset=((strValues[5]=='inset')?true:false);$self.find("#OPP-shadow-hoffset").slider('value',values.hoffset);$self.find("#OPP-shadow-voffset").slider('value',values.voffset);$self.find("#OPP-shadow-blur").slider('value',values.blur);$self.find("#OPP-shadow-size").slider('value',values.size);$self.find("#OPP-shadow-transparency").slider('value',values.transparency);$self.data("colorPicker").setColor(values.color);$self.find('#OPP-shadow-inset').attr('checked',values.inset);return this;},};var createSlider=function(elem,minValue,maxValue){var updateSliderValues=function(event,ui){if(elem.is("#OPP-shadow-size")){values.size=ui.value;}else if(elem.is("#OPP-shadow-transparency")){values.transparency=ui.value;}else if(elem.is("#OPP-shadow-hoffset")){values.hoffset=ui.value;}else if(elem.is("#OPP-shadow-voffset")){values.voffset=ui.value;}else if(elem.is("#OPP-shadow-blur")){values.blur=ui.value;}updateField();};elem.slider({range:"min",step:1,min:minValue,max:maxValue,orientation:"hoffset",slide:updateSliderValues,change:updateSliderValues});};var updateField=function(){$($self.data("shadowStringField")).val(getShadowString()).trigger("change");};var getShadowString=function(){var color=MOPP($self.data("colorPicker").color,values.transparency);var boxShadowString=values.hoffset+'px '+values.voffset+'px '+values.blur+'px '+values.size+'px '+color+((0<$('#OPP-shadow-inset-div :checked').length)?' inset':'');return boxShadowString;};function MOPP(h,transparency){if(!h)return 'rgba(255,255,255,1)';var r=parseInt((bOPP(h)).substring(0,2),16);var g=parseInt((bOPP(h)).substring(2,4),16);var b=parseInt((bOPP(h)).substring(4,6),16);var a=(1-transparency/100).toFixed(2);var rgba='rgba('+r+','+g+','+b+','+a+')';return rgba;};function bOPP(h){return(h.charAt(0)=="#")?h.substring(1,7):h};function fOPP(rgba){var rgbArr=rgba.substring(5,rgba.length-1).split(',');return '#'+oOPP([rgbArr[0]])+oOPP(rgbArr[1])+oOPP(rgbArr[2]);};function GOPP(rgba){var rgbArr=rgba.substring(5,rgba.length-1).split(',');return(1-rgbArr[3])*100;};function oOPP(N){if(N==null)return "00";N=parseInt(N);if(N==0||isNaN(N))return "00";N=Math.max(0,N);N=Math.min(N,255);N=Math.round(N);return "0123456789ABCDEF".charAt((N-N%16)/16)+"0123456789ABCDEF".charAt(N%16);};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 shadowEditor');}}})(jQuery);(function($){$.fn.gradientEditor=function(method){var $self;var values={size:0,hoffset:0,voffset:0,blur:0,transparency:0,color:'',inset:false};var methods={init:function(options){$self=this;$self.data("values",values);$self.data("shadowStringField",options.shadowStringField);$self.html("<div id='OPP-shadow-editor'>"+"<div style='display: inline-block; width: 330px; padding-left:5px; vertical-align: top;'>"+"<div style='height: 8px; '></div>"+"<div style='width: 100px; display:inline-block; vertical-align: top;'>Size: </div>"+"<div id='OPP-shadow-size' style='width: 200px;display: inline-block; margin-bottom: 20px;'></div>"+"<div style='width: 100px; display:inline-block; vertical-align: top;'>H-offset: </div>"+"<div id='OPP-shadow-hoffset' style='width: 200px;display: inline-block; margin-bottom: 20px;'></div>"+"<div style='width: 100px; display:inline-block; vertical-align: top;'>V-offset: </div>"+"<div id='OPP-shadow-voffset' style='width: 200px;display: inline-block; margin-bottom: 20px;'></div>"+"<div style='width: 100px; display:inline-block; vertical-align: top;'>Blur: </div>"+"<div id='OPP-shadow-blur' style='width: 200px;display: inline-block; margin-bottom: 20px;'></div>"+"<div style='width:100px; display: inline-block; vertical-align: top;'>Transparency:</div>"+"<div id='OPP-shadow-transparency' style='width: 200px;display: inline-block; margin-bottom: 20px;'></div>"+"<div style='display: inline-block; width:100px'>Inside:</div>"+"<div id='OPP-shadow-inset-div' style='display: inline-block; width: 20px;'>"+"<input type='checkbox' id='OPP-shadow-inset' title='' class='ui-widget-content ui-corner-all'>"+"</div>"+"</div>"+"<div id='OPP-shadow-color-picker' style='display: inline-block;'>"+"</div>"+"</div>");$self.data("colorPicker",$.farbtastic('#OPP-shadow-color-picker'));$self.data("colorPicker").linkTo(function(){updateField();});$("#OPP-shadow-inset").bind('click',function(){if(0<$('#OPP-shadow-inset-div :checked').length){inset='inset';}else{inset='';}updateField();});this.shadowEditor('applyShadowString');return this;},getShadowString:function(){$self=this;$self.data("values",($self.data("values")?$self.data("values"):values));values=$self.data("values");return getShadowString();},applyShadowString:function(){$self=this;$self.data("values",($self.data("values")?$self.data("values"):values));values=$self.data("values");var strValues=$($self.data("shadowStringField")).val().split(' ');values.hoffset=strValues[0].replace("px","");values.voffset=strValues[1].replace("px","");values.blur=strValues[2].replace("px","");values.size=strValues[3].replace("px","");values.transparency=GOPP(strValues[4]);values.color=fOPP(strValues[4]);values.inset=((strValues[5]=='inset')?true:false);$self.find("#OPP-shadow-hoffset").slider('value',values.hoffset);$self.find("#OPP-shadow-voffset").slider('value',values.voffset);$self.find("#OPP-shadow-blur").slider('value',values.blur);$self.find("#OPP-shadow-size").slider('value',values.size);$self.find("#OPP-shadow-transparency").slider('value',values.transparency);$self.data("colorPicker").setColor(values.color);$self.find('#OPP-shadow-inset').attr('checked',values.inset);return this;},};var updateField=function(){$($self.data("shadowStringField")).val(getShadowString()).trigger("change");};var getShadowString=function(){var color=MOPP($self.data("colorPicker").color,values.transparency);var boxShadowString=values.hoffset+'px '+values.voffset+'px '+values.blur+'px '+values.size+'px '+color+((0<$('#OPP-shadow-inset-div :checked').length)?' inset':'');return boxShadowString;};function MOPP(h,transparency){if(!h)return 'rgba(255,255,255,1)';var r=parseInt((bOPP(h)).substring(0,2),16);var g=parseInt((bOPP(h)).substring(2,4),16);var b=parseInt((bOPP(h)).substring(4,6),16);var a=(1-transparency/100).toFixed(2);var rgba='rgba('+r+','+g+','+b+','+a+')';return rgba;};function bOPP(h){return(h.charAt(0)=="#")?h.substring(1,7):h};function fOPP(rgba){var rgbArr=rgba.substring(5,rgba.length-1).split(',');return '#'+oOPP([rgbArr[0]])+oOPP(rgbArr[1])+oOPP(rgbArr[2]);};function GOPP(rgba){var rgbArr=rgba.substring(5,rgba.length-1).split(',');return(1-rgbArr[3])*100;};function oOPP(N){if(N==null)return "00";N=parseInt(N);if(N==0||isNaN(N))return "00";N=Math.max(0,N);N=Math.min(N,255);N=Math.round(N);return "0123456789ABCDEF".charAt((N-N%16)/16)+"0123456789ABCDEF".charAt(N%16);};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 shadowEditor');}}})(jQuery);
