
var askp={};askp.dialog_index=10;askp.dialog_open=function(d_id){w_width=document.documentElement.clientWidth;w_height=document.documentElement.clientHeight;var dialog_screen=$("#dialog_screen");dialog_screen.css({"z-index":(askp.dialog_index-1)});dialog_screen.show();var dialog=$(d_id);var d_width=dialog.attr("d_width");var d_height=dialog.attr("d_height");if(d_height=="e"){d_height=w_height-140;}
else{if(d_height>=(w_height-90))
d_height=w_height-90;}
var d_left=Math.round((w_width/2)-(d_width/2));var d_top=Math.round((w_height/2)-(d_height/2))-40;if(d_top<10)
d_top=10;dialog.css({"background-color":"#ffffff","top":d_top,"left":d_left,"position":"fixed","_position":"absolute","width":d_width+"px","height":d_height+"px","z-index":askp.dialog_index});dialog.show();askp.dialog_index+=2;}
askp.dialog_close=function(d_id){var dialog=$(d_id);dialog.hide();askp.dialog_index-=2;if(askp.dialog_index==10){$("#dialog_screen").hide();$("#dialog_screen").css({"z-index":(askp.dialog_index-3)});}
else{$("#dialog_screen").css({"z-index":(askp.dialog_index-3)});}}
askp.dialog_close_all=function(){$("[dialog]").hide();askp.dialog_index=10;}
askp.tooltip_close=function(t_id){$(t_id).hide();}
askp.tooltip_close_all=function(){$("[tooltip_click]").hide("slow");$("[tooltip_hover]").hide("slow");}
askp.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options=$.extend({},options);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=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}};askp.test_alphanum=function(str){if(str.match(/[^a-zA-Z0-9 ]/))
return false;else
return true;}
askp.test_alphanum_strict=function(str){if(str.match(/[^a-zA-Z0-9]/))
return false;else
return true;}
askp.test_int=function(str){if(str.match(/[^0-9]/))
return false;else
return true;}
askp.number_format=function(a){var b=0;var c=".";var d=",";var k='';if(a.indexOf('-')==0){k='-';a=a*-1;}
a=Math.round(a*Math.pow(10,b))/Math.pow(10,b);var e=a+'';var f=e.split('.');if(!f[0])f[0]='0';if(!f[1])f[1]='';if(f[1].length<b){var g=f[1];for(var i=f[1].length+1;i<=b;i++){g+='0';}
f[1]=g;}
if(d!=''&&f[0].length>3){var h=f[0];f[0]='';for(var j=3;j<h.length;j+=3){i=h.slice(h.length-j,h.length-j+3);f[0]=d+i+f[0]+'';}
j=h.substr(0,(h.length%3==0)?3:(h.length%3));f[0]=j+f[0];}
c=(b<=0)?'':c;if(f[1]!="")
return k+f[0]+c+f[1];else
return k+f[0];}
askp.round_k=function(num){if(num>=1000000){num/=1000000.0;num=Math.round(num);return num+"M";}
else if(num>=1000){num/=1000.0;num=Math.round(num);return num+"K";}
else
return num;}
askp.escape_html=function(str){return str.split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;")}
askp.nl2br=function(str){return str.replace(/\n/ig,"<br/>");}
askp.jsonp_send=function(param,callback){param.jtoken=askp.cookie("jtoken");$.getJSON(askp.url_jsonp+'?jcb=?',param,function(ret){callback(ret,param);});};askp.img_error=function(source){source.src="http://www.askpedia.com/images/user_default.jpg";source.onerror="";return true;}
askp.validate_ask=function(form_mode){$("#ask_error").html("");if(form_mode=="anon"){$("signup_username").val("");$("signup_password").val("");$("signup_email").val("");$("#signup_error").html("");$("#signup_error").hide();$("#signup_button").show();$("#signup_loader").hide();$("#login_username").val("");$("#login_password").val("");$("#login_error").html("");$("#login_error").hide("");}
if($.trim($("#ask_subject").val()).length<=0){$("#ask_error").html("Please Enter Question Subject");return false;}
if($.trim($("#ask_subject").val()).length<=10){$("#ask_error").html("Please Enter a Longer, more Descriptive Question Subject");return false;}
if($("#ask_subject").val().length>100){$("#ask_error").html("Question Subject is too long");return false;}
if($("#ask_details").val().length>1000){$("#ask_error").html("Question Details is too long");return false;}
if($("#ask_category").val()==""){$("#ask_error").html("Select Category Tag");return false;}
if(askp.test_alphanum($("#ask_tags").val())==false){$("#ask_error").html("Tags must consist of letters and numbers only");return false;}
if($("#ask_tags").val().length>50){$("#ask_error").html("Too many Tags");return false;}
if($.trim($("#ask_reward").val())==""){$("#ask_error").html("Enter Question Reward");return false;}
if(askp.test_int($("#ask_reward").val())==false){$("#ask_error").html("Enter an Integer number for Question Reward");return false;}
if($("#ask_reward").val()<1){$("#ask_error").html("Minimum Reward is 1 Point");return false;}
if(parseInt($("#ask_reward").val())>parseInt($("#ask_reward_max").val())){$("#ask_error").html("Not enough Points for Question Reward");return false;}
if(parseInt($("#ask_reward").val())>2000){$("#ask_error").html("Maximum Reward is 2000 Points");return false;}
if(form_mode=="session"){$("#ask_preview_photo").attr("src",$("#ask_photo").val());$("#ask_preview_username").html(askp.escape_html($("#ask_username").val()));$("#ask_preview_subject").html(askp.escape_html($("#ask_subject").val()));$("#ask_preview_reward").html(askp.number_format(askp.escape_html($("#ask_reward").val())));$("#ask_preview_details").html(askp.nl2br(askp.escape_html($("#ask_details").val())));var tags_preview=askp.escape_html($("#ask_tags").val());if($.trim(tags_preview)!="")
$("#ask_preview_tags").html("<b>"+askp.escape_html($("#ask_category").val())+"</b> ("+tags_preview+")");else
$("#ask_preview_tags").html("<b>"+askp.escape_html($("#ask_category").val())+"</b>");}
askp.dialog_open('#d_ask_preview');}
askp.validate_ask_signup=function(){$("#signup_error").html("");$("#signup_error").hide();$("#login_error").html("");$("#login_error").hide();var username=$("#signup_username").val();var password=$("#signup_password").val();var email=$("#signup_email").val();username=$.trim(username);email=$.trim(email);if(username.length==0){$("#signup_error").html("Enter a Username");$("#signup_error").show();return;}
if((username.length<4)||(username.length>16)){$("#signup_error").html("Username must be between 4 and 16 characters");$("#signup_error").show();return;}
if(askp.test_alphanum_strict(username)==false){$("#signup_error").html("Username must consist of letters and numbers only");$("#signup_error").show();return;}
if(password.length==0){$("#signup_error").html("Enter a Password");$("#signup_error").show();return;}
if((password.length<4)||(password.length>16)){$("#signup_error").html("Password must be between 4 and 16 characters");$("#signup_error").show();return;}
if(askp.test_alphanum_strict(password)==false){$("#signup_error").html("Password must consist of letters and numbers only");$("#signup_error").show();return;}
if(email.length==0){$("#signup_error").html("Enter Email");$("#signup_error").show();return;}
$("#signup_button").hide();$("#signup_loader").show();var param={};param.action="validate_signup";param.username=username;param.password=password;param.email=email;askp.jsonp_send(param,askp.validate_ask_signup_process);}
askp.validate_ask_signup_process=function(ret,param){if(ret.status=="OK"){$("#ask_session_mode").val("signup");$("#ask_session_username").val(param.username);$("#ask_session_password").val(param.password);$("#ask_session_email").val(param.email);$("#ask_form").submit();}
else{$("#signup_error").html(ret.error);$("#signup_error").show();$("#signup_loader").hide();$("#signup_button").show();return;}}
askp.validate_ask_login=function(){$("#signup_error").html("");$("#signup_error").hide();$("#login_error").html("");$("#login_error").hide();var username=$("#login_username").val();var password=$("#login_password").val();username=$.trim(username);if(username.length==0){$("#login_error").html("Enter a Username");$("#login_error").show();return;}
if((username.length<4)||(username.length>16)){$("#login_error").html("Username must be between 4 and 16 characters");$("#login_error").show();return;}
if(askp.test_alphanum_strict(username)==false){$("#login_error").html("Username must consist of letters and numbers only");$("#login_error").show();return;}
if(password.length==0){$("#login_error").html("Enter a Password");$("#login_error").show();return;}
$("#login_button").hide();$("#login_loader").show();var param={};param.action="validate_login";param.username=username;param.password=password;askp.jsonp_send(param,askp.validate_ask_login_process);}
askp.validate_ask_login_process=function(ret,param){if(ret.status=="OK"){$("#ask_session_mode").val("login");$("#ask_session_username").val(param.username);$("#ask_session_password").val(param.password);$("#ask_form").submit();}
else{$("#login_error").html(ret.error);$("#login_error").show();$("#login_loader").hide();$("#login_button").show();return;}}
askp.qlisting_filter_sort_change=function(){var redir=$("#context_url").val()+"status="+$("#filter_show").val()+"&order="+$("#filter_sort").val();window.location.href=redir;}
askp.qlisting_filter_show_change=function(){var redir=$("#context_url").val()+"status="+$("#filter_show").val()+"&order="+$("#filter_sort").val();window.location.href=redir;}
askp.text_counter=function(field,countfield,maxlimit){if($(field).val().length>maxlimit){$(field).val($(field).val().substring(0,maxlimit));$(countfield).html((maxlimit-$(field).val().length)+' Characters Left');}
else
$(countfield).html((maxlimit-$(field).val().length)+' Characters Left');}
askp.expand_shrink=function(field,min_height,max_height,expand_link,expand_name,shrink_name){if($(field).height()==min_height){$(field).height(max_height);$(expand_link).html(shrink_name);}
else{$(field).height(min_height);$(expand_link).html(expand_name);}}
askp.question_add_details_submit=function(){var param={};param.action="question_add_details";param.qid=$("#question_add_details_qid").val();param.details=$("#question_add_details_i").val();if($.trim(param.details).length==0){$("#question_add_details_error").html("Please Enter additional Question Details");return false;}
if(param.details.length>500){$("#question_comment_error").html("Question Details are too Long");return false;}
$("#question_add_details_submit_button").attr("disabled",true);$("#question_add_details_submit_loader").show();askp.jsonp_send(param,askp.question_add_details_process);}
askp.question_add_details_process=function(ret,param){$("#question_add_details_error").html("");$("#question_add_details_submit_button").removeAttr("disabled");$("#question_add_details_submit_loader").hide();if(ret.status=="ERROR"){$("#question_add_details_error").html(ret.error);return;}
$("#question_add_details_i").val("");$("#question_add_details_counter").html("Limit 500 Characters");$("#question_add_details_form").hide();$("#question_add_details_link_r").show();$("#question_details_b").html(ret.html);}
askp.answer_question_preview=function(login_check){var param={};param.qid=$("#answer_question_qid").val();param.pid=$("#answer_question_pid").val();param.cluster=$("#answer_question_cluster").val();param.details=$("#answer_question_i").val();param.source=$("#answer_question_source_i").val();if(login_check==true){param.signup_username=$("#answer_question_signup_username_i").val();param.signup_password=$("#answer_question_signup_password_i").val();param.signup_email=$("#answer_question_signup_email_i").val();param.login_username=$("#answer_question_login_username_i").val();param.login_password=$("#answer_question_login_password_i").val();}
if($.trim(param.details).length==0){$("#answer_question_error").html("Please Enter an Answer");return false;}
if(param.details.length>2000){$("#answer_question_error").html("Answer is too Long");return false;}
if(param.source.length>100){$("#answer_question_error").html("Source is too Long");return false;}
if(login_check===true){if((param.login_username.length==0)&&(param.signup_username.length==0)){$("#answer_question_error").html("Login or Sign Up for New Account");return false;}
if(param.login_username.length>0){if(param.login_password.length==0){$("#answer_question_error").html("Enter Login Password");return false;}}
else{if(param.signup_username.length>0){if(askp.test_alphanum_strict(param.signup_username)==false){$("#answer_question_error").html("Sign Up Username must consist of letters and numbers only");return false;}
if(param.signup_password.length==0){$("#answer_question_error").html("Choose a Sign Up Password");return false;}
if(askp.test_alphanum_strict(param.signup_password)==false){$("#answer_question_error").html("Sign Up Password must consist of letters and numbers only");return false;}
if(param.signup_email.length==0){$("#answer_question_error").html("Enter Sign Up Email");return false;}}}
var v_param={};v_param.action="answer_validate_login";v_param.login_username=param.login_username;v_param.login_password=param.login_password;v_param.signup_username=param.signup_username;v_param.signup_password=param.signup_password;v_param.signup_email=param.signup_email;v_param.qid=param.qid;v_param.pid=param.pid;v_param.cluster=param.cluster;$("#answer_question_submit_button").attr("disabled",true);$("#answer_question_submit_loader").show();askp.jsonp_send(v_param,askp.answer_question_validate_login_process);return false;}
askp.answer_question_preview_show();}
askp.answer_question_validate_login_process=function(ret,param){$("#answer_question_submit_button").removeAttr("disabled");$("#answer_question_submit_loader").hide();$("#answer_question_error").html("");if(ret.status=="ERROR"){$("#answer_question_error").html(ret.error);return false;}
$("#answer_question_username").val(ret.username);$("#answer_question_photo").val(ret.photo);askp.answer_question_preview_show();}
askp.answer_question_preview_show=function(){$("#answer_preview_photo").attr("src",$("#answer_question_photo").val());$("#answer_preview_from_username").html($("#answer_question_username").val());if($("#answer_question_name").val()!=="")
$("#answer_preview_from_name").text($("#answer_question_name").val());if($("#answer_question_profession").val()!=="")
$("#answer_preview_from_profession").text(" / "+$("#answer_question_profession").val());$("#answer_preview_details").html(askp.nl2br(askp.escape_html($("#answer_question_i").val())));var source_val=$("#answer_question_source_i").val();if(source_val!==""){$("#answer_preview_source").text(source_val);$("#answer_preview_source_r").show();}
else{$("#answer_preview_source").html("");$("#answer_preview_source_r").hide();}
askp.dialog_open("#d_answer_preview");}
askp.answer_add_details_submit=function(){var param={};param.action="answer_add_details";param.aid=$("#answer_add_details_aid").val();param.details=$("#answer_add_details_i").val();if($.trim(param.details).length==0){$("#answer_add_details_error").html("Please Enter additional Answer Details");return false;}
if(param.details.length>1000){$("#answer_comment_error").html("Answer Details are too Long");return false;}
$("#answer_add_details_submit_button").attr("disabled",true);$("#answer_add_details_submit_loader").show();askp.jsonp_send(param,askp.answer_add_details_process);}
askp.answer_add_details_process=function(ret,param){$("#answer_add_details_error").html("");$("#answer_add_details_submit_button").removeAttr("disabled");$("#answer_add_details_submit_loader").hide();if(ret.status=="ERROR"){$("#answer_add_details_error").html(ret.error);return;}
$("#answer_add_details_i").val("");$("#answer_add_details_counter").html("Limit 1000 Characters");$("#answer_add_details_form").hide();$("#answer_add_details_link_r").show();$("#answer_details_"+param.aid).html(ret.html);}
askp.question_comment=function(){var param={};param.action="question_comment";param.qid=$("#question_comment_qid").val();param.comment=$("#question_comment_i").val();if($.trim(param.comment).length==0){$("#question_comment_error").html("Please Enter Comment");return false;}
if(param.comment.length>200){$("#question_comment_error").html("Comment is too Long");return false;}
$("#question_comment_button").attr("disabled",true);$("#question_commment_submit_loader").show();askp.jsonp_send(param,askp.question_comment_process);}
askp.question_comment_process=function(ret,param){$("#question_comment_error").html("");$("#question_comment_button").removeAttr("disabled");$("#question_commment_submit_loader").hide();if(ret.status=="ERROR"){$("#question_comment_error").html(ret.error);return;}
$("#question_comment_i").val("");$("#question_clisting").html(ret.html);}
askp.question_clisting=function(start){var param={};param.action="question_clisting";param.qid=$("#question_comment_qid").val();param.cluster=$("#question_comment_cluster").val();param.start=start;$("#question_clisting_loader").show();askp.jsonp_send(param,askp.question_clisting_process);}
askp.question_clisting_process=function(ret,param){$("#question_clisting_loader").hide();if(ret.status=="ERROR"){$("#question_clisting_error").html(ret.error);return;}
$("#question_clisting").html(ret.html);window.location.href="#clisting";}
askp.question_alisting=function(start){var param={};param.action="question_alisting";param.qid=$("#alisting_qid").val();param.cluster=$("#alisting_cluster").val();param.status=$("#alisting_filter_status").val();param.order=$("#alisting_filter_order").val();param.start=start;$("#question_alisting_loader").show();askp.jsonp_send(param,askp.question_alisting_process);}
askp.question_alisting_process=function(ret,param){$("#question_alisting_loader").hide();if(ret.status=="ERROR"){$("#question_alisting_error").html(ret.error);$("#alisting_filter_order").one('change',function(){askp.question_alisting(0)});$("#alisting_filter_status").one('change',function(){askp.question_alisting(0)});return;}
$("#question_alisting").html(ret.html);window.location.href="#alisting";}
askp.answer_comment=function(aid){var param={};param.action="answer_comment";param.qid=$("#answer_comment_qid_"+aid).val();param.aid=$("#answer_comment_aid_"+aid).val();param.cluster=$("#answer_comment_cluster_"+aid).val();param.details=$("#answer_comment_i_"+aid).val();if($.trim(param.details).length==0){$("#answer_comment_error_"+aid).html("Please Enter Comment");return false;}
if(param.details.length>500){$("#answer_comment_error_"+aid).html("Comment is too Long");return false;}
$("#answer_comment_button_"+aid).attr("disabled",true);$("#answer_commment_submit_loader_"+aid).show();askp.jsonp_send(param,askp.answer_comment_process);}
askp.answer_comment_process=function(ret,param){$("#answer_comment_error_"+param.aid).html("");$("#answer_comment_button_"+param.aid).removeAttr("disabled");$("#answer_commment_submit_loader_"+param.aid).hide();if(ret.status=="ERROR"){$("#answer_comment_error_"+param.aid).html(ret.error);return;}
$("#answer_comment_i_"+param.aid).val("");$("#answer_clisting_"+param.aid).html(ret.html);}
askp.answer_clisting=function(aid,start){var param={};param.action="answer_clisting";param.aid=aid;param.start=start;askp.jsonp_send(param,askp.answer_clisting_process);}
askp.answer_clisting_process=function(ret,param){if(ret.status=="ERROR"){$("#answer_clisting_error_"+param.aid).html(ret.error);return;}
$("#answer_clisting_"+param.aid).html(ret.html);}
askp.answer_select_best_preview=function(aid){$("#select_best_preview_reward").html($("#question_reward").html());$("#select_best_preview_photo").attr("src",$("#answer_photo_img_"+aid).attr("src"));$("#select_best_preview_username").html($("#answer_username_"+aid).html());$("#select_best_preview_from_name").html($("#answer_from_name_"+aid).html());$("#select_best_preview_compliment_c").html($("#answer_compliment_c_"+aid).html());$("#select_best_preview_details").html($("#answer_details_"+aid).html());$("#select_best_preview_aid").val(aid);$("#select_best_preview_button").removeAttr("disabled");$("#select_best_preview_error").html("");askp.dialog_open("#d_select_best_preview");}
askp.answer_select_best=function(){var param={};param.action="select_best_answer";param.aid=$("#select_best_preview_aid").val();$("#select_best_preview_button").attr("disabled",true);askp.jsonp_send(param,askp.answer_select_best_process);}
askp.answer_select_best_process=function(ret,param){if(ret.status=="ERROR"){$("#select_best_preview_error").html(ret.error);$("#select_best_preview_button").removeAttr("disabled");return;}
var redir=$("#question_url").attr("href");var ret_url=$("#ret_url").attr("href");if(ret_url=="#")
window.location.href=redir
else
window.location.href=redir+"/_/ret_url="+askp.php_urlencode(askp.php_urlencode(ret_url));}
askp.flag_question_show=function(qid){$("#flag_question_loader").show();$("#flag_question_form").hide();$("#flag_question_already").hide();$("#flag_question_preview").hide();$("#flag_question_error").hide();$("#flag_question_error").html("");$("#flag_question_qid").val(qid);$("#flag_question_photo_img").attr("src",$("#question_photo_img").attr("src"));$("#flag_question_subject").text($("#question_subject").text());$("#flag_question_username").text($("#question_username").text());$("#flag_question_reward_c").html($("#question_reward_c").html());$("#flag_question_error").html("");$("#flag_question_reason").val("");$("#flag_question_submit_error").html("");askp.dialog_open("#d_flag_question");var param={};param.action="get_flag_question";param.qid=qid;askp.jsonp_send(param,askp.flag_question_show_process);}
askp.flag_question_show_process=function(ret,param){$("#flag_question_loader").hide();$("#flag_question_submit_loader").hide();if(ret.status=="OK"){$("#flag_question_error").html("");if(ret.flag_exists=="Y"){$("#flag_question_form").hide();$("#flag_question_already_reason").text(ret.reason);$("#flag_question_already").show();$("#flag_question_preview").show();}
else{$("#flag_question_form").show();$("#flag_question_already").hide();$("#flag_question_preview").show();}}
else{$("#flag_question_form").hide();$("#flag_question_already").hide();$("#flag_question_preview").hide();$("#flag_question_error").html(ret.error);$("#flag_question_error").show();}}
askp.flag_question_submit=function(){$("#flag_question_submit_error").html("");$("#flag_question_submit_button").attr("disabled","disabled");$("#flag_question_submit_loader").show();var param={};param.action="flag_question";param.qid=$("#flag_question_qid").val();param.reason=$("#flag_question_reason").val();askp.jsonp_send(param,askp.flag_question_submit_process);}
askp.flag_question_submit_process=function(ret,param){$("#flag_question_submit_button").removeAttr("disabled");$("#flag_question_submit_loader").hide();if(ret.status=="OK"){$("#question_about_flag_active").hide();$("#question_about_flag_flagged").show();askp.dialog_close("#d_flag_question");}
else{$("#flag_question_submit_error").html(ret.error);}}
askp.flag_listing_show=function(content,cluster,id){$("#flag_"+content+"_loader").show();$("#flag_"+content+"_form").hide();$("#flag_"+content+"_already").hide();$("#flag_"+content+"_preview").hide();$("#flag_"+content+"_error").hide();$("#flag_"+content+"_error").html("");$("#flag_"+content+"_id").val(id);$("#flag_"+content+"_cluster").val(cluster);$("#flag_"+content+"_photo_img").attr("src",$("#"+content+"_photo_img_"+id).attr("src"));$("#flag_"+content+"_details").html($("#"+content+"_details_"+id).html());$("#flag_"+content+"_username").text($("#"+content+"_username_"+id).text());$("#flag_"+content+"_error").html("");$("#flag_"+content+"_reason").val("");$("#flag_"+content+"_submit_error").html("");askp.dialog_open("#d_flag_"+content);var param={};param.action="get_flag_listing";param.content=content;param.id=id;askp.jsonp_send(param,askp.flag_listing_show_process);}
askp.flag_listing_show_process=function(ret,param){$("#flag_"+param.content+"_loader").hide();$("#flag_"+param.content+"_submit_loader").hide();if(ret.status=="OK"){$("#flag_"+param.content+"_error").html("");if(ret.flag_exists=="Y"){$("#flag_"+param.content+"_form").hide();$("#flag_"+param.content+"_already_reason").text(ret.reason);$("#flag_"+param.content+"_already").show();$("#flag_"+param.content+"_preview").show();}
else{$("#flag_"+param.content+"_form").show();$("#flag_"+param.content+"_already").hide();$("#flag_"+param.content+"_preview").show();}}
else{$("#flag_"+param.content+"_form").hide();$("#flag_"+param.content+"_already").hide();$("#flag_"+param.content+"_preview").hide();$("#flag_"+param.content+"_error").html(ret.error);$("#flag_"+param.content+"_error").show();}}
askp.flag_listing_submit=function(content){$("#flag_"+content+"_submit_error").html("");$("#flag_"+content+"_submit_button").attr("disabled","disabled");$("#flag_"+content+"_submit_loader").show();var param={};param.action="flag_listing";param.content=content;param.id=$("#flag_"+content+"_id").val();param.cluster=$("#flag_"+content+"_cluster").val();param.reason=$("#flag_"+content+"_reason").val();askp.jsonp_send(param,askp.flag_listing_submit_process);}
askp.flag_listing_submit_process=function(ret,param){$("#flag_"+param.content+"_submit_button").removeAttr("disabled");$("#flag_"+param.content+"_submit_loader").hide();if(ret.status=="OK"){$("#"+param.content+"_flag_active_"+param.id).hide();$("#"+param.content+"_flag_flagged_"+param.id).show();askp.dialog_close("#d_flag_"+param.content);}
else{$("#flag_"+param.content+"_submit_error").html(ret.error);}}
askp.compliment_question_show=function(qid){$("#compliment_question_loader").show();$("#compliment_question_form").hide();$("#compliment_question_already").hide();$("#compliment_question_preview").hide();$("#compliment_question_error").hide();$("#compliment_question_error").html("");$("#compliment_question_qid").val(qid);$("#compliment_question_photo_img").attr("src",$("#question_photo_img").attr("src"));$("#compliment_question_subject").text($("#question_subject").text());$("#compliment_question_username").text($("#question_username").text());$("#compliment_question_reward_c").html($("#question_reward_c").html());$("#compliment_question_error").html("");$("#compliment_question_comment").val("");$("#compliment_question_submit_error").html("");$('#compliment_question_counter').html("Limit: 200 Characters");askp.dialog_open("#d_compliment_question");var param={};param.action="get_compliment_question";param.qid=qid;askp.jsonp_send(param,askp.compliment_question_show_process);}
askp.compliment_question_show_process=function(ret,param){$("#compliment_question_loader").hide();$("#compliment_question_submit_loader").hide();if(ret.status=="OK"){$("#compliment_question_error").html("");if(ret.compliment_exists=="Y"){$("#compliment_question_form").hide();$("#compliment_question_already_comment").text(ret.comment);$("#compliment_question_already").show();$("#compliment_question_preview").show();}
else{$("#compliment_question_form").show();$("#compliment_question_already").hide();$("#compliment_question_preview").show();}}
else{$("#compliment_question_form").hide();$("#compliment_question_already").hide();$("#compliment_question_preview").hide();$("#compliment_question_error").html(ret.error);$("#compliment_question_error").show();}}
askp.compliment_question_submit=function(){$("#compliment_question_submit_error").html("");$("#compliment_question_submit_button").attr("disabled","disabled");$("#compliment_question_submit_loader").show();var param={};param.action="compliment_question";param.qid=$("#compliment_question_qid").val();param.comment=$("#compliment_question_comment").val();askp.jsonp_send(param,askp.compliment_question_submit_process);}
askp.compliment_question_submit_process=function(ret,param){$("#compliment_question_submit_button").removeAttr("disabled");$("#compliment_question_submit_loader").hide();if(ret.status=="OK"){$("#question_about_compliment_active").hide();$("#question_about_compliment_complimented").show();askp.dialog_close("#d_compliment_question");askp.question_clisting(0);}
else{$("#compliment_question_submit_error").html(ret.error);}}
askp.compliment_listing_show=function(content,id){$("#compliment_"+content+"_loader").show();$("#compliment_"+content+"_form").hide();$("#compliment_"+content+"_already").hide();$("#compliment_"+content+"_preview").hide();$("#compliment_"+content+"_error").hide();$("#compliment_"+content+"_error").html("");$("#compliment_"+content+"_id").val(id);$("#compliment_"+content+"_photo_img").attr("src",$("#"+content+"_photo_img_"+id).attr("src"));$("#compliment_"+content+"_details").html($("#"+content+"_details_"+id).html());$("#compliment_"+content+"_username").text($("#"+content+"_username_"+id).text());$("#compliment_"+content+"_error").html("");$("#compliment_"+content+"_comment").val("");$("#compliment_"+content+"_submit_error").html("");$('#compliment_answer_counter').html("Limit: 500 Characters");askp.dialog_open("#d_compliment_"+content);var param={};param.action="get_compliment_listing";param.content=content;param.id=id;askp.jsonp_send(param,askp.compliment_listing_show_process);}
askp.compliment_listing_show_process=function(ret,param){$("#compliment_"+param.content+"_loader").hide();$("#compliment_"+param.content+"_submit_loader").hide();if(ret.status=="OK"){$("#compliment_"+param.content+"_error").html("");if(ret.compliment_exists=="Y"){$("#compliment_"+param.content+"_form").hide();$("#compliment_"+param.content+"_already").show();$("#compliment_"+param.content+"_preview").show();}
else{$("#compliment_"+param.content+"_form").show();$("#compliment_"+param.content+"_already").hide();$("#compliment_"+param.content+"_preview").show();}}
else{$("#compliment_"+param.content+"_form").hide();$("#compliment_"+param.content+"_already").hide();$("#compliment_"+param.content+"_preview").hide();$("#compliment_"+param.content+"_error").html(ret.error);$("#compliment_"+param.content+"_error").show();}}
askp.compliment_listing_submit=function(content){$("#compliment_"+content+"_submit_error").html("");$("#compliment_"+content+"_submit_button").attr("disabled","disabled");$("#compliment_"+content+"_submit_loader").show();var param={};param.action="compliment_listing";param.content=content;param.id=$("#compliment_"+content+"_id").val();param.comment=$("#compliment_"+content+"_comment").val();askp.jsonp_send(param,askp.compliment_listing_submit_process);}
askp.compliment_listing_submit_process=function(ret,param){$("#compliment_"+param.content+"_submit_button").removeAttr("disabled");$("#compliment_"+param.content+"_submit_loader").hide();if(ret.status=="OK"){$("#"+param.content+"_compliment_active_"+param.id).hide();$("#"+param.content+"_compliment_complimented_"+param.id).show();askp.answer_clisting(param.id,0);askp.dialog_close("#d_compliment_"+param.content);}
else{$("#compliment_"+param.content+"_submit_error").html(ret.error);}}
askp.profile_listing_filter_sort_change=function(){var redir=$("#context_url").val()+"status="+$("#filter_show").val()+"&order="+$("#filter_sort").val();window.location.href=redir;}
askp.profile_listing_filter_show_change=function(){var redir=$("#context_url").val()+"status="+$("#filter_show").val()+"&order="+$("#filter_sort").val();window.location.href=redir;}
askp.feed_listing_more=function(start){$("#flisting_more_"+start).hide();$("#flisting_loader_"+start).show();var param={};param.action="feed_listing";param.start=start;askp.jsonp_send(param,askp.feed_listing_more_process);}
askp.feed_listing_more_process=function(ret,param){$("#flisting_loader_"+param.start).hide();if(ret.status=="OK"){$("#flisting_b").append(ret.html);}
else{$("#flisting_error").html(ret.error);}}
askp.rank_listing_more=function(mode,period,start){$("#rlisting_more_"+start).hide();$("#rlisting_loader_"+start).show();var param={};param.action="rank_listing";param.mode=mode;param.period=period;param.start=start;askp.jsonp_send(param,askp.rank_listing_more_process);}
askp.rank_listing_more_process=function(ret,param){$("#rlisting_loader_"+param.start).hide();if(ret.status=="OK"){$("#rlisting_b").append(ret.html);}
else{$("#rlisting_error").html(ret.error);}}
askp.search_tab=function(mode){if(mode=="askpedia"){$("#search_x").removeClass("search_allqa_b");$("#search_x").addClass("search_askp_b");$("#mode_x").val("askpedia");$("#cx_x").val($("#cx_askpedia").val());$("#button_x").removeClass("search_allqa_button1");$("#button_x").addClass("search_askp_button1");}
else if(mode=="allqa"){$("#search_x").removeClass("search_askp_b");$("#search_x").addClass("search_allqa_b");$("#mode_x").val("allqa");$("#cx_x").val($("#cx_allqa").val());$("#button_x").removeClass("search_askp_button1");$("#button_x").addClass("search_allqa_button1");}}
askp.search_mode_select_change=function(){var mode=$("#mode_select").val();if(mode=="askpedia"){$("#search_bar_q").removeClass("search_bar_allqa_q");$("#search_bar_q").addClass("search_bar_askp_q");$("#search_bar_button").removeClass("search_allqa_button2");$("#search_bar_button").addClass("search_askp_button2");$("#cx_x").val($("#cx_askpedia").val());}
else if(mode=="allqa"){$("#search_bar_q").removeClass("search_bar_askp_q");$("#search_bar_q").addClass("search_bar_allqa_q");$("#search_bar_button").removeClass("search_askp_button2");$("#search_bar_button").addClass("search_allqa_button2");$("#cx_x").val($("#cx_allqa").val());}}
askp.wall_post_submit=function(){$("#wall_post_error").html("");$("#wall_post_submit_button").hide();$("#wall_post_loader").show();var param={};param.action="wall_post";param.cluster=$("#wall_post_cluster").val();param.wid=$("#wall_post_wid").val();param.details=$("#wall_post_i").val();askp.jsonp_send(param,askp.wall_post_submit_process);}
askp.wall_post_submit_process=function(ret,param){$("#wall_post_submit_button").show();$("#wall_post_loader").hide();if(ret.status=="OK"){$("#wall_post_i").val("");askp.text_counter('#wall_post_i','#wall_post_counter',500);$("#profile_listing").html("");var wid=$("#wall_post_wid").val();askp.get_wall_post_listing(wid,0);return;}
else{$("#wall_post_error").html(ret.error);return;}}
askp.wall_post_remove=function(wpid){var param={};param.action="wall_post_remove";param.wpid=wpid;askp.jsonp_send(param,askp.wall_post_remove_process);}
askp.wall_post_remove_process=function(ret,param){if(ret.status=="OK"){$("#wall_post_flag_remove_"+param.wpid).hide();$("#wall_post_flag_removed_"+param.wpid).show();$("#wall_post_"+param.wpid).css("opacity","0.5");}}
askp.get_wall_post_listing=function(wid,start){$("#profile_listing_loader").show();var param={};param.action="wall_post_listing";param.wid=wid;param.start=start;askp.jsonp_send(param,askp.get_wall_post_listing_process);}
askp.get_wall_post_listing_process=function(ret,param){$("#profile_listing_loader").hide();$("#wlisting_more_"+param.start).hide();if(ret.status=="OK"){$("#profile_listing").append(ret.html);}
else{$("#profile_listing").append("<div class='error_b'>"+ret.error+"</div>");}}
askp.wall_post_comment_submit=function(wpid){$("#wall_post_comment_error_"+wpid).html("");$("#wall_post_comment_submit_button_"+wpid).hide();$("#wall_post_comment_loader_"+wpid).show();var param={};param.action="wall_post_comment";param.cluster=$("#wall_post_cluster_"+wpid).val();param.wid=$("#wall_post_comment_wid_"+wpid).val();param.wpid=wpid;param.details=$("#wall_post_comment_i_"+wpid).val();askp.jsonp_send(param,askp.wall_post_comment_submit_process);}
askp.wall_post_comment_submit_process=function(ret,param){$("#wall_post_comment_submit_button_"+param.wpid).show();$("#wall_post_comment_loader_"+param.wpid).hide();if(ret.status=="OK"){$("#wall_post_comments_"+param.wpid).html(ret.html);return;}
else{$("#wall_post_comment_error_"+param.wpid).html(ret.error);return;}}
askp.wall_post_comment_remove=function(wpcid){var param={};param.action="wall_post_comment_remove";param.wpcid=wpcid;askp.jsonp_send(param,askp.wall_post_comment_remove_process);}
askp.wall_post_comment_remove_process=function(ret,param){if(ret.status=="OK"){$("#wall_post_comment_flag_remove_"+param.wpcid).hide();$("#wall_post_comment_flag_removed_"+param.wpcid).show();$("#wall_post_comment_"+param.wpcid).css("opacity","0.5");}}
askp.wall_get_blocked_users=function(wid){var param={};param.action="wall_get_blocked_users";param.wid=wid;askp.jsonp_send(param,askp.wall_get_blocked_users_process);}
askp.wall_get_blocked_users_process=function(ret,param){if(ret.status=="OK"){$("#wall_user_block_listing").html(ret.html);}
else{$("#wall_user_block_error").html(ret.error);}}
askp.wall_block_user=function(){$("#wall_user_block_error").html("");var param={};param.action="wall_block_user";param.username=$("#wall_block_username_i").val();askp.jsonp_send(param,askp.wall_block_user_process);}
askp.wall_block_user_process=function(ret,param){if(ret.status=="OK"){$("#wall_user_block_listing").html(ret.html);$("#wall_block_username_i").val("");}
else{$("#wall_user_block_error").html(ret.error);}}
askp.wall_unblock_user=function(username){$("#wall_user_block_error").html("");var param={};param.action="wall_unblock_user";param.username=username
askp.jsonp_send(param,askp.wall_unblock_user_process);}
askp.wall_unblock_user_process=function(ret,param){if(ret.status=="OK"){$("#wall_user_block_listing").html(ret.html);$("#wall_block_username_i").val("");}
else{$("#wall_user_block_error").html(ret.error);}}
askp.cash_out_show=function(){askp.dialog_open('#d_cash_out');}
askp.cash_out_submit=function(){$("#cash_out_error").html("");$("#cash_out_button").hide();$("#cash_out_loader").show();var param={};param.action="points_cash_out";param.email1=$("#cash_out_email1").val();param.email2=$("#cash_out_email2").val();param.points=$("#cash_out_points").val();askp.jsonp_send(param,askp.cash_out_submit_process);}
askp.cash_out_submit_process=function(ret,param){$("#cash_out_error").html("");$("#cash_out_button").show();$("#cash_out_loader").hide();if(ret.status=="OK"){$("#cash_out_email1").val("");$("#cash_out_email2").val("");$("#cash_out_points").val("");$("#cash_out_balance").html(ret.balance);$("#home_points_balance").html(ret.balance);$("#msg_top").html(ret.msg);$("#msg_top").show();askp.dialog_close("#d_cash_out");}
else{$("#cash_out_error").html(ret.error);$("#cash_out_balance").html(ret.balance);$("#home_points_balance").html(ret.balance);}}
askp.fb_share=function(uri,subj_enc){uri=window.location.href;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(uri),'Share_on_Facebook','toolbar=0, status=0, width=626, height=436');}
askp.buy_points_show=function(){askp.dialog_open('#d_buy_points');}
askp.php_urlencode=function(str){var histogram={},unicodeStr='',hexEscStr='';var ret=(str+'').toString();var replacer=function(search,replace,str){var tmp_arr=[];tmp_arr=str.split(search);return tmp_arr.join(replace);};histogram["'"]='%27';histogram['(']='%28';histogram[')']='%29';histogram['*']='%2A';histogram['~']='%7E';histogram['!']='%21';histogram['%20']='+';histogram['\u00DC']='%DC';histogram['\u00FC']='%FC';histogram['\u00C4']='%D4';histogram['\u00E4']='%E4';histogram['\u00D6']='%D6';histogram['\u00F6']='%F6';histogram['\u00DF']='%DF';histogram['\u20AC']='%80';histogram['\u0081']='%81';histogram['\u201A']='%82';histogram['\u0192']='%83';histogram['\u201E']='%84';histogram['\u2026']='%85';histogram['\u2020']='%86';histogram['\u2021']='%87';histogram['\u02C6']='%88';histogram['\u2030']='%89';histogram['\u0160']='%8A';histogram['\u2039']='%8B';histogram['\u0152']='%8C';histogram['\u008D']='%8D';histogram['\u017D']='%8E';histogram['\u008F']='%8F';histogram['\u0090']='%90';histogram['\u2018']='%91';histogram['\u2019']='%92';histogram['\u201C']='%93';histogram['\u201D']='%94';histogram['\u2022']='%95';histogram['\u2013']='%96';histogram['\u2014']='%97';histogram['\u02DC']='%98';histogram['\u2122']='%99';histogram['\u0161']='%9A';histogram['\u203A']='%9B';histogram['\u0153']='%9C';histogram['\u009D']='%9D';histogram['\u017E']='%9E';histogram['\u0178']='%9F';ret=encodeURIComponent(ret);for(unicodeStr in histogram){hexEscStr=histogram[unicodeStr];ret=replacer(unicodeStr,hexEscStr,ret);}
return ret.replace(/(\%([a-z0-9]{2}))/g,function(full,m1,m2){return"%"+m2.toUpperCase();});}
askp.php_urldecode=function(str){var histogram={},ret=str.toString(),unicodeStr='',hexEscStr='';var replacer=function(search,replace,str){var tmp_arr=[];tmp_arr=str.split(search);return tmp_arr.join(replace);};histogram["'"]='%27';histogram['(']='%28';histogram[')']='%29';histogram['*']='%2A';histogram['~']='%7E';histogram['!']='%21';histogram['%20']='+';histogram['\u00DC']='%DC';histogram['\u00FC']='%FC';histogram['\u00C4']='%D4';histogram['\u00E4']='%E4';histogram['\u00D6']='%D6';histogram['\u00F6']='%F6';histogram['\u00DF']='%DF';histogram['\u20AC']='%80';histogram['\u0081']='%81';histogram['\u201A']='%82';histogram['\u0192']='%83';histogram['\u201E']='%84';histogram['\u2026']='%85';histogram['\u2020']='%86';histogram['\u2021']='%87';histogram['\u02C6']='%88';histogram['\u2030']='%89';histogram['\u0160']='%8A';histogram['\u2039']='%8B';histogram['\u0152']='%8C';histogram['\u008D']='%8D';histogram['\u017D']='%8E';histogram['\u008F']='%8F';histogram['\u0090']='%90';histogram['\u2018']='%91';histogram['\u2019']='%92';histogram['\u201C']='%93';histogram['\u201D']='%94';histogram['\u2022']='%95';histogram['\u2013']='%96';histogram['\u2014']='%97';histogram['\u02DC']='%98';histogram['\u2122']='%99';histogram['\u0161']='%9A';histogram['\u203A']='%9B';histogram['\u0153']='%9C';histogram['\u009D']='%9D';histogram['\u017E']='%9E';histogram['\u0178']='%9F';for(unicodeStr in histogram){hexEscStr=histogram[unicodeStr];ret=replacer(hexEscStr,unicodeStr,ret);}
ret=decodeURIComponent(ret);return ret;}