/* Copyright (c) Fotki Inc */

;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);(function($){$.fn.TextAreaExpander=function(minHeight,maxHeight){var hCheck=!($.browser.msie||$.browser.opera);function ResizeTextarea(e){e=e.target||e;var vlen=e.value.length,ewidth=e.offsetWidth;if(vlen!=e.valLength||ewidth!=e.boxWidth){if(hCheck&&(vlen<e.valLength||ewidth!=e.boxWidth))e.style.height="0px";var h=Math.max(e.expandMin,Math.min(e.scrollHeight,e.expandMax));e.style.overflow=(e.scrollHeight>h?"auto":"hidden");e.style.height=h+"px";e.valLength=vlen;e.boxWidth=ewidth;}
return true;};this.each(function(){if(this.nodeName.toLowerCase()!="textarea")return;var p=this.className.match(/expand(\d+)\-*(\d+)*/i);this.expandMin=minHeight||(p?parseInt('0'+p[1],10):0);this.expandMax=maxHeight||(p?parseInt('0'+p[2],10):99999);ResizeTextarea(this);if(!this.Initialized){this.Initialized=true;$(this).css("padding-top",0).css("padding-bottom",0);$(this).bind("keyup",ResizeTextarea).bind("focus",ResizeTextarea);}});return this;};})(jQuery);(function($){$.fn.charCount=function(options){var defaults={allowed:1000,warning:(2/3),id:'counter'};var options=$.extend(defaults,options);function calculate(obj)
{var s=obj.scrollTop;var text=$(obj).val();var len=text.length;try{if(len<options.allowed*(options.warning)){$('#'+options.id+"_cont").hide();return 1;}
$('#'+options.id+"_cont").show();if(len<options.allowed){$('#'+options.id).html((options.allowed-len));}else{$('#'+options.id).html('<span style="font-weight: bold;color:red">0</span>');var new_text=text.slice(0,options.allowed);$(obj).val(new_text);obj.scrollTop=s;}}catch(ex){return 0;}};this.each(function(){calculate(this);$(this).keyup(function(){calculate(this)});$(this).bind('cut paste',function(e){calculate(this)});$(this).bind("focus",function(e){calculate(this)});});};})(jQuery);var active_color='#000';var inactive_color='#ccc';function jqCommentButtons(){var $area;$('#ph_comment').live("click",function(){var visible=$('#top_reply').is(':visible');checkshare();hideOpenFields();if(visible){$('#top_reply').hide();$('#ph_comment').removeClass('button sel').addClass('button');}else{$('#top_reply').show();$('#ph_comment').removeClass('button').addClass('button sel');transfer_styles('top');input_default_value('top');$("#top_comment").focus().TextAreaExpander(50,800).charCount({allowed:max_cmsg_length,warning:(2/3),id:'max_cmt_top_reply'});correctScroll("top_reply_submit");checkAjaxForm('top');}});$("input[id^='reply_button_cancel_']").live("click",function(){$area=this.id.replace(/reply_button_cancel_/,'');$('#ph_comment').removeClass('button sel').addClass('button');$("#"+$area+"_comment").val('');var tar=$("#"+$area+"_reply");tar.hide();if($area!='top'){tar.html('');}
$("#comedit_"+$area).show();});$("div[id^='edit_button_']").live("click",function(){hideOpenFields();$('#comment_top').hide();$area=this.id.replace(/edit_button_/,'');reset_errors($area);$("#body_"+$area).hide();$("#precom_"+$area).hide();$("#comedit_"+$area).hide();$("#edit_comm_"+$area).show();$("#textarea_"+$area).focus().TextAreaExpander(50,800).charCount({allowed:max_cmsg_length,warning:(2/3),id:'max_cmt_'+$area});correctScroll($area+"_edit_submit");});$("div[class*='editable_comment'] a").live("click",function(){$(this).addClass('clickedon');});$("div[class*='editable_comment']").live("click",function(){var $kids=$(this).find('a');var clicked=false;if($kids.hasClass('clickedon')){clicked=true;}
if(clicked==false){hideOpenFields();$('#comment_top').hide();$area=this.id.replace(/body_/,'');reset_errors($area);$("#body_"+$area).hide();$("#precom_"+$area).hide();$("#comedit_"+$area).hide();$("#edit_comm_"+$area).show();$("#textarea_"+$area).focus().TextAreaExpander(50,800).charCount({allowed:max_cmsg_length,warning:(2/3),id:'max_cmt_'+$area});correctScroll($area+"_edit_submit");}else{$kids.removeClass('clickedon');}});$("a[class='hider']").click(function(){$(this).next('li').show();});$("input[id^='edit_button_cancel_']").live("click",function(){$area=this.id.replace(/edit_button_cancel_/,'');$("#edit_comm_"+$area).hide();$("#body_"+$area).show();$("#textarea_"+$area).val($("#comment_bak_"+$area).val());$("#precom_"+$area).show();$("#comedit_"+$area).show('fast');});$("a[id^='delete_button_']").live("click",function(){$("div[id^='delete_button_dialog_']").hide();$area=this.id.replace(/delete_button_/,'');$("#delete_button_dialog_"+$area).show();var el=$("#delete_button_dialog_"+$area);var wth=el.find('.inner-span').width()+20;if(wth>300){wth=300;}
el.find('.delete_dialog').each(function(){$(this).animate({"width":wth},20);});});$("a[id^='cancel_button_']").live("click",function(){$area=this.id.replace(/cancel_button_/,'');$("#delete_button_dialog_"+$area).stop().hide();});$("#ph_button_bottom").live("click",function(){hideOpenFields();$.scrollTo($("#ph_comment"),{offset:{top:-230}});$("#top_reply").show();$("#top_comment").focus();checkshare();checkAjaxForm('top');});$("input[id$='_anonymous']").live("click",function(){$area=this.id.replace(/_anonymous/,'');$('#'+$area+'_user_data_fields').hide('normal');$('#'+$area+'_user_data').hide();});$("input[id$='_guest']").live("click",function(){$area=this.id.replace(/_guest/,'');$('#'+$area+'_user_data').show();$('#'+$area+'_user_data_fields').show('fast');});$("input[id$='_member']").live("click",function(){$area=this.id.replace(/_member/,'');$('#'+$area+'_user_data_fields').hide('normal');$('#'+$area+'_user_data').hide();});$("#ph_share").live("click",function(){$("#comment_top").hide();$("#ph_comment").removeClass("button sel").addClass("button");});if(!isIE67()){$("div[id^='comment_']").live("mouseenter mouseleave",function(e){$area=this.id.replace(/comment_/,'');var id=$("#comedit_"+$area);var opened=false;var reply=$("#"+$area+"_reply");var edit=$("#edit_comm_"+$area);var del=$('#delete_button_dialog_'+$area);if((reply&&reply.is(":visible"))||(edit&&edit.is(":visible"))||(del&&del.is(":visible"))){opened=true;}
if(opened==false)
{if(e.type=='mouseenter'){id.clearQueue().show();}
if(e.type=='mouseleave'&&!isMobile()){id.clearQueue().hide();}}});}
}
function ajaxReplyDialog(id,entry_id){hideOpenFields();var tar=$("#"+id+"_reply");tar.show().html(progress_bar+'&nbsp;'+please_wait);$("#comedit_"+id).hide();$.ajax({type:"POST",data:{fcmd:'reply_dialog',id:id,entry_id:entry_id},success:function(obj){tar.html(obj);transfer_styles(id);input_default_value(id);$("#"+id+"_comment").focus().TextAreaExpander(50,800).charCount({allowed:max_cmsg_length,warning:(2/3),id:'max_cmt_'+id+'_reply'});correctScroll(id+"_reply_submit");checkAjaxForm(id);},error:function(obj){tar.html(obj.statusText);}});}
function checkAjaxForm(id){$("#post_error_"+id+"_reply").hide();$.ajax({type:"POST",data:{cmd:'spmsetcookie'},success:function(obj){if(!getCookie('spmcki')){$("#post_error_"+id+"_reply").show();}}});}
function hideOpenFields()
{$("div[id^='edit_comm_']").hide();$("div[id$='_reply']").each(function(){tar=$(this).attr("id").replace(/_reply/,'');$(this).hide();if(tar!='top'){$(this).html('');}});$("div[id^='body_']").removeClass('editable_area').show();}
function allowedToPost(id){var cook=getCookie('spmcki');if(cook==''||cook==null){$('#post_error_'+id).show();return 0;}else{$('#post_error_'+id).hide();return 1;}
return 1;}
function isEmpty(mytext){var re=/^\s{1,}$/g;if((mytext.length==0)||(mytext==null)||((mytext.search(re))>-1)){return true;}else{return false;}}
function reset_errors(comment_id){$('#response_error_'+comment_id).html('').hide();}
function correctScroll(id)
{var tar=$('#'+id);if(tar.length>0){var scrollpos=$(window).height()+$(window).scrollTop();var offset=tar.offset().top+20;if(offset>scrollpos){$.scrollTo({top:'+=100px',left:'0'},{duration:400});}}}
function saveComment(comment_id,entry_id,premoderate_mode){var comment=$('#textarea_'+comment_id).val();if($('#textarea'+comment_id).is(':disabled')){return;}
var prvt='0';if($('#private_'+comment_id).is(':checked')){prvt='1';}
if(isEmpty(comment)){$('#response_error_'+comment_id).html('Comment must not be empty.').show();}else if(comment.length>max_cmsg_length){$('#response_error_'+comment_id).html('Comment is too long.<br>Please modify your comment to fit '+max_cmsg_length+' character limit.').show();}else{$('#textarea_'+comment_id).attr('disabled','disabled').addClass('textarea_disabled');$('#'+comment_id+'_wait').show();$.ajax({type:"POST",data:{fcmd:'editcomment',id:comment_id,comment:comment,entry_id:entry_id,prvt:prvt},success:function(obj){$('#textarea_'+comment_id).removeAttr('disabled').removeClass('textarea_disabled');$('#'+comment_id+'_wait').hide();if(obj.indexOf('response|')>-1){if(obj.substr(9,2)=='ok'){var comment_plain=obj.substr(12);$('#body_'+comment_id).html(comment_plain).show();$('#textarea_'+comment_id).val(comment);$('#comment_bak_'+comment_id).val(comment);$('#edit_comm_'+comment_id).hide();reset_errors(comment_id);$("#precom_"+comment_id).show();$("#comedit_"+comment_id).show();if(prvt=='1'){$("#edit_private_"+comment_id).show();}else{$("#edit_private_"+comment_id).hide();}
if(premoderate_mode==1){alert('Thank you for your comment!  It will be posted upon approval.');}}}else{$('#textarea_'+comment_id).removeAttr('disabled').removeClass('textarea_disabled');$('#'+comment_id+'_wait').hide();$('#textarea_'+comment_id).val(comment);$('#response_error_'+comment_id).html('Unable to save edited comment.<br>'+obj).show();}},error:function(){alert('Error updating comment. ');$('#textarea_'+comment_id).val($('#body_'+comment_id).val());$('#body_'+comment_id).show();$('#edit_comm_'+comment_id).hide();$("#precom_"+comment_id).show();$("#comedit_"+comment_id).show();}});}}
function deleteComment(comment_id,entry_id){var comment_body=$('#body_'+comment_id).text();var delete_thread='0';if($('#delete_button_check_'+comment_id+':checked').length>0){delete_thread='1';}
$('#body_'+comment_id).html(progress_bar+' '+please_wait);$("#comedit_"+comment_id).hide();$.ajax({type:"POST",data:{fcmd:'deletecomment',id:comment_id,entry_id:entry_id,delete_thread:delete_thread},success:function(obj){$("#comedit_"+comment_id).show();if(obj.indexOf('response|')>-1){if(obj.substr(9)=='refresh'){document.location.reload();return;}
$('#comments').html(obj.substr(9));init_functions();if($('#gb_no_messages').length>0){var txt=$.trim($('#comments').text());if(!txt||txt==''){$('#gb_no_messages').show();}}}else{alert('Unable delete comment. '+obj);$('#body_'+comment_id).html(comment_body);}},error:function(obj){$("#comedit_"+comment_id).show();alert('Error deleting comment. '+obj.status+':'+obj.statusText);}});}
function acceptComment(comment_id,entry_id){var comment_body=$('#body_'+comment_id).text();$('#body_'+comment_id).html(progress_bar+' '+please_wait);$("#comedit_"+comment_id).hide();$.ajax({type:"POST",data:{fcmd:'acceptcomment',id:comment_id,entry_id:entry_id},success:function(obj){$("#comedit_"+comment_id).show();if(obj.indexOf('response|')>-1){if(obj.substr(9)=='refresh'){document.location.reload();return;}
$('#comments').html(obj.substr(9));}else{alert('Unable to accept comment.');$('#body_'+comment_id).html(comment_body);}},error:function(){$("#comedit_"+comment_id).show();alert('Error accepting comment. ');}});}
function hideComment(comment_id){var comment_body=$('#body_'+comment_id).text();$('#body_'+comment_id).html(progress_bar+' '+please_wait);$('#comedit_'+comment_id).hide();$.ajax({type:"POST",data:{fcmd:'hidecomment',id:comment_id},success:function(obj){$('#comedit_'+comment_id).show();if(obj.indexOf('response|')>-1){if(obj.substr(9)=='refresh'){document.location.reload();return;}
$('#comments').html(obj.substr(9));}else{alert('Unable delete comment. '+obj);$('#body_'+comment_id).html(comment_body);}},error:function(){$('#comedit_'+comment_id).show();alert('Error deleting comment. ');}});}
function checkMsgLength(ref,id)
{var s=ref.scrollTop;var text=$(ref).val();try{if(text.length<max_cmsg_length*2/3){$('#'+id+"_cont").hide();return 1;}
$('#'+id+"_cont").show();if(text.length<max_cmsg_length){$('#'+id).html((max_cmsg_length-text.length));}else{$('#'+id).html('<span style="font-weight: bold;color:red">0</span>');var new_text=text.slice(0,max_cmsg_length);$(ref).val(new_text);ref.scrollTop=s;}}catch(ex){return 0;}}
function postFromCookie(name){var nm=name;if(getCookie(nm)){$('#top_comment').val(getCookie(nm));}}
function clearCookie(name){var nm=name;if(getCookie(nm)){deleteCookie(name,'','fotki.com');}}
function resetCommentForm(id){$('#'+id+'comment_length').show();$('#'+id+'comment_private').show();$('#'+id+'post_error').show();$('#'+id+'submit').show();$('#'+id+'comment_textarea').show();$('#'+id+'all_audio').hide();$('#'+id+'as_audio').hide();}
function showHidePersonalFields(id,a){var tmp=document.getElementById(id+'_user_data');if(a=='chide'){tmp.className="chide";}else{tmp.className="cshow";}}
function hideCommentsForm(id){$('#ph_share').removeClass('button sel').addClass('button');$('#ph_comment').removeClass('button sel').addClass('button');$('#'+id+'_reply').hide();$('#response_error_'+id).hide();}
function checkshare(){$('#ph_share').removeClass('button sel').addClass('button');$('#photo_share').hide();}
function getstyle(obj,cAttribute){if(obj.currentStyle){this.getstyle=function(obj,cAttribute){return obj.currentStyle[cAttribute];};}else{this.getstyle=function(obj,cAttribute){return window.getComputedStyle(obj,null)[cAttribute];};}
return getstyle(obj,cAttribute);}
function rgb2hex(rgb){rgb=rgb.match(/^rgba\((\d+),\s*(\d+),\s*(\d+)\)$/);function hex(x){return parseInt(x).toString(16);}
return"#"+hex(rgb[1])+hex(rgb[2])+hex(rgb[3]);}
function getElementColour(elementName){var tryId=document.getElementById(elementName);if(tryId&&typeof(delete_dialog_bg)!='undefined'){delete_dialog_bg=$('#'+elementName).css('backgroundColor');if(delete_dialog_bg=='transparent'||delete_dialog_bg.toString()=='rgba(0, 0, 0, 0)'){delete_dialog_bg='#fff';}}}
function addComment(id,entry_id,premoderate_mode,not_friend,realid,comment_type){var comment=$('#'+id+'_comment').val();if($('#'+id+'_comment').is(':disabled')){return;}
var name=$('#'+id+'_name_field').val();var email=$('#'+id+'_email_field').val();var parent_id=$('#'+id+'_parent_id').text();var member=$('#'+id+'_member').val();var guest=$('#'+id+'_guest').val();if(guest){if(name==default_name){name='';}
if(email==default_email){email='';}
if(name==''&&email==''){guest='anonymous';}}
var user_type=member||guest;if(user_type==''){member=$('#'+id+'_member').val();user_type=member||'anonymous';}
var prvt='0';if($('#private_'+realid).is(':checked')){prvt='1';}
var notify=$('#select_notify_'+id+' option:selected').val();if(prvt=='1'){notify=0;}
if(!member&&!permission_comments_write){var var_id;if(id=='top'){var_id='';}else{var_id='_'+id;}
setCookie('txt_comment'+var_id,comment,'','','fotki.com','');alert("You're not quite done! "+"\n"+"\n"+
"To post your reply, please log in or sign up! "+"\n"+"\n"+
"As a Fotki member, you'll be able to reply on others' comments in forums and blogs, keep your own blogs and forums, create albums, submit your work to Fotki contests, and vote on other Fotkins' submissions.");document.location=current_address;return;}
$(".comments_avatar_new").each(function(){if($(this).data('qtip')){$(this).qtip("destroy");}});if(comment_type=='audio'){return'user_type='+user_type+'::name='+name+'::email='+email+'::prvt='+prvt;}
if(isEmpty(comment)){$('#response_error_'+realid).html('Please, write your comment').show();}else if(comment.length>max_cmsg_length){$('#response_error_'+realid).html('Comment is too long.<br>Please modify your comment to fit '+max_cmsg_length+' character limit.');}
else{$('#'+id+'_comment').attr("disabled","disabled").addClass('textarea_disabled');$('#'+realid+'_wait').show();var compage=1;var parse=''+window.location;var reg=new RegExp(/\?commentpage=(\d+).*/);var mm=reg.exec(parse);if(mm&&mm[1]){compage=''+mm[1];}
$.ajax({type:"POST",data:{fcmd:'postcomment',comment:comment,user_type:user_type,name:name,prvt:prvt,email:email,parent:parent_id,notify:notify,commentpage:compage,entry_id:entry_id||''},success:function(obj){$('#'+id+'_comment').val('').removeAttr("disabled").removeClass('textarea_disabled');$('#'+realid+'_wait').hide();if(obj.indexOf('response|')>-1){var resp_text=new Array();resp_text=obj.substr(9).split("||");var redirect_comment_id=resp_text.shift();var comments_body=resp_text.join("||");if(redirect_comment_id!='redirect'){$('#comments').html('').html(comments_body);init_functions();if(id=='top'||id=='bottom'){hideCommentsForm('top');}
if(notify>0){$('#show_notified_users').show();}
reset_errors(realid);if(id=='top'){reset_errors('top_reply');}
if(premoderate_mode==1){alert('Thank you for your comment!  It will be posted upon approval.');}}
$('#'+id+'_name_field').val(default_name);$('#'+id+'_email_field').val(default_email);$('#private_'+realid).attr('checked',false);$('#gb_no_messages').hide();if(redirect_comment_id=='redirect'){var endloc=''+window.location;if(endloc.match(/\?commentpage=(\d).*/)){endloc=endloc.replace(/\?commentpage=(\d).*/,"");window.location=endloc+'#'+comments_body;}
if(endloc.match(/\?reply_to=.*/)){endloc=endloc.replace(/\?reply_to=.*/,"");window.location=endloc;}}else{var endloc=''+window.location;if(endloc.match(/\?commentpage=(\d).*/)&&needScroll==1){endloc=endloc.replace(/\?commentpage=(\d).*/,"");window.location=endloc+'#'+redirect_comment_id;}else if(endloc.match(/\?reply_to=.*/)){endloc=endloc.replace(/\?reply_to=.*/,"");window.location=endloc+'#'+redirect_comment_id;}else{if(typeof(needScroll)!='undefined'&&needScroll==1){$.scrollTo($("#comment_"+redirect_comment_id),{offset:{top:-200}});}
$("#comment_"+redirect_comment_id).fadeOut('normal').fadeIn('normal').fadeOut('normal').fadeIn('normal');}}}else{var var_id;if(id=='top'){var_id='';}else{var_id='_'+id;}
setCookie('txt_comment'+var_id,comment,'','','fotki.com','');$('#'+id+'_comment').val(comment);if(obj==''){obj='Unknown error has occured. Please refresh your page.';}
$('#response_error_'+realid).html('Unable to add comment.<br>'+obj).show();}},error:function(obj){$('#'+id+'_comment').val('').removeAttr("disabled").removeClass('textarea_disabled');$('#'+realid+'_wait').hide();var error_msg=obj.status+':'+obj.statusText;if(error_msg==''){error_msg='Unknown error has occured. Please refresh your page.';}
$('#response_error_'+realid).html('Error adding comment. <br>Server returned the following error message:<br>'+error_msg);}});}}
function reportAsSpam(comment_id,entry_id){if(!confirm('Are you sure you want to report this as spam?')){return;}
$("#spam_report_"+comment_id).hide();$("#spam_sending_"+comment_id).show();if(!comment_id||!comment_id){$("#spam_sending_"+comment_id).hide();$("#spam_error_"+comment_id).show();return;}
$.ajax({type:"POST",data:{fcmd:'report_as_spam',id:comment_id,entry_id:entry_id},success:function(obj){$("#spam_sending_"+comment_id).hide();if(obj.indexOf('response|')>-1){if(obj=='response|ok'){$("#spam_success_"+comment_id).show();}else{$("#spam_error_"+comment_id).show();}}else{$("#spam_error_"+comment_id).html(obj);$("#spam_error_"+comment_id).show();}},error:function(obj){$("#spam_sending_"+comment_id).hide();$("#spam_error_"+comment_id).show();}});}
function button_reply(id){$('#delete_button_dialog_'+id).hide();$('#delete_button_'+id).show();}
function button_delete(id,entry_id){$('#delete_button_dialog_'+id).hide();$('#delete_button_'+id).show();deleteComment(id,entry_id);}
function input_default_value(id){var tar=$('#'+id+'_reply').find("input.default-value");tar.css("color",inactive_color);var default_values=new Array();tar.focus(function(){if(!default_values[this.id]){default_values[this.id]=this.value;}
if(this.value==default_values[this.id]){this.value='';this.style.color=active_color;}
$(this).blur(function(){if(this.value==''){this.style.color=inactive_color;this.value=default_values[this.id];}});});}
function transfer_styles(id){var lheight=$('div .gettransfer').css('height');$('#'+id+'_reply').find('div .transfer').css('line-height',lheight);}
function isMobile(){if((navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPod/i))||(navigator.userAgent.match(/iPad/i))||(navigator.userAgent.match(/BlackBerry/i))||(navigator.userAgent.match(/Android/i))){return 1;}
return 0;}
function isIE67(){if($.browser.msie&&$.browser.version<8){return true;}
return false;}
function qtipAvatar(){var popevent='mouseenter';var hoverdelay=400;if(isIE67()||isMobile()){popevent='click';hoverdelay=0;}
$("div .comments_avatar_new").each(function(){if($(this).data('qtip')){$(this).qtip("destroy");}
var $avatar_id=this.id.replace(/avatar_/,'');$(this).qtip({content:{text:$('#grab_'+$avatar_id).html()},show:{when:popevent,delay:hoverdelay,solo:true,effect:{length:0}},hide:{when:'mouseleave',delay:100,fixed:true,effect:{length:0}},position:{container:$('#comments'),adjust:{resize:false,scroll:false,screen:false,y:3,x:10},corner:{target:'rightTop',tooltip:'leftTop'}},style:{'padding':'4px 4px 4px 4px','margin':0,'opacity':'0.95',width:{max:200},border:{width:2,radius:6},tip:{corner:'leftTop',size:{x:10,y:10}},name:'light'}});});}
function init_functions(){if(typeof(delete_dialog_bg)!='undefined'){getElementColour('top_nav_select');$('div .b_replace, b .b_replace').css('background',delete_dialog_bg);}
if(!isMobile()&&!isIE67()){$('div[id^="comedit_"]').hide();}
if(location.hostname.match(/contests/)){$('#top_reply').show();input_default_value('top');transfer_styles('top');$('#ph_comment').removeClass('button').addClass('button sel');if($("#top_comment").length>0){$("#top_comment").focus().TextAreaExpander(50,800).charCount({allowed:max_cmsg_length,warning:(2/3),id:'max_cmt_top_reply'});checkAjaxForm('top');}}
setSortOrder();qtipAvatar();}
function setupAJAX(){var url=window.location.href;if(url.indexOf("#")>-1){url=url.substr(0,url.indexOf("#"));}
$.ajaxSetup({url:url});}
function setSortOrder(){$('#comment_sort').change(function(){var tar=$('#comment_sort option:selected');setCookie('comment_sort',tar.val());location.reload();});}
function preventIEClick(){if(isIE67()){return false;}
return true;}
$(document).ready(jqCommentButtons);$(document).ready(setupAJAX);$(document).ready(init_functions);