
$(function(){$('#delete-promt').dialog({autoOpen:false,height:25,width:300,modal:true,resizable:false});prepareButtons();});function prepareButtons()
{$('.fg-button').hover(function(){$(this).addClass("ui-state-hover");},function(){$(this).removeClass("ui-state-hover");});}
function onlineTooltip()
{$('#online > span').each(function(i){$(this).simpletip({content:UsersTooltip[i],persistent:true});});}
function message()
{$('#dialog-message').dialog({resizable:false,modal:true,buttons:{'Закрыть':function(){$(this).dialog('close');}}});}
function addComment(obj)
{var text=$('#comment').val();if(trim(text)=='')
return;$(obj).hide();ajaxLoader('#comment-table',true);$.post('http://'+document.location.host+document.location.pathname+'/comment/add',{'text':text},function(data){if(data!='error')
{$('#comment-table').html(data);$('#comment').val('');ajaxLoader('#comment-table',false);$.scrollTo('#comment-table');$(obj).show();}});}
function getComments()
{ajaxLoader('#comment-table',true);$.get('http://'+document.location.host+document.location.pathname+'/comment/get',function(data){if(data!='error')
{$('#comment-table').html(data);ajaxLoader('#comment-table',false);if(window.location.hash)
{$.scrollTo('#row-'+str_replace('#','',window.location.hash));}}});}
function ajaxLoader(element,state)
{if(state)
{$(element).block({message:'<img src="'+media_location+'/img/ajax-loader.gif" />'});}
else
{$(element).unblock();}}
function nl2br(str,is_xhtml)
{var breakTag=(is_xhtml||typeof is_xhtml==='undefined')?'<br />':'<br>';return(str+'').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,'$1'+breakTag+'$2');}
function str_replace(search,replace,subject,count)
{f=[].concat(search),r=[].concat(replace),s=subject,ra=r instanceof Array,sa=s instanceof Array;s=[].concat(s);if(count){this.window[count]=0;}
for(i=0,sl=s.length;i<sl;i++){if(s[i]===''){continue;}
for(j=0,fl=f.length;j<fl;j++){temp=s[i]+'';repl=ra?(r[j]!==undefined?r[j]:''):r[0];s[i]=(temp).split(f[j]).join(repl);if(count&&s[i]!==temp){this.window[count]+=(temp.length-s[i].length)/f[j].length;}}}
return sa?s:s[0];}
function trim(str,charlist){var whitespace,l=0,i=0;str+='';if(!charlist){whitespace=" \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000";}else{charlist+='';whitespace=charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g,'$1');}
l=str.length;for(i=0;i<l;i++){if(whitespace.indexOf(str.charAt(i))===-1){str=str.substring(i);break;}}
l=str.length;for(i=l-1;i>=0;i--){if(whitespace.indexOf(str.charAt(i))===-1){str=str.substring(0,i+1);break;}}
return whitespace.indexOf(str.charAt(0))===-1?str:'';}
function sendComment(obj)
{var text=$('#comment').val();if(trim(text)=='')
return;if($('#name').length>0)
{var name=$('#name').val();if(trim(name)=='')
return;}
else
{name='';}
$(obj).hide();ajaxLoader('#question-form',true);$.post(http_location+'/radio/questions/send',{'text':text,'name':name},function(data){if(data!='error')
{$('#comment').hide();$('#name').hide();$('#question-form').html('<h3>Ваш вопрос был отправлен!</h3>');ajaxLoader('#question-form',false);}});}
function downloadGallery(url,obj)
{$(obj).hide();window.location=http_location+'/gallery/download/'+url;}
function setMeetingRegisterForm()
{$('p[type=field] select').change(function()
{recalcPrice();});$('p[type=field] input[type=checkbox]').click(function(){recalcPrice();});$('#MeetingsParticipantsType').change(function(){changeType();recalcPrice();});changeType();recalcPrice();}
function recalcPrice()
{var TotalPrice=parseInt($('#MeetingsPayment').val());var TotalHtml='<label>Орг взнос</label><span>'+TotalPrice+'</span>руб.<br />';$('p[type=field] select option:selected').each(function(){if($(this).parent().parent().css('display')!='none')
{price=parseInt($(this).attr('price'));if(price>0)
{TotalPrice+=price;TotalHtml+='<label>'+$(this).html()+'</label><span>'+price+'</span>руб.<br />';}}});$('p[type=field] input[type=checkbox]').each(function()
{if($(this).parent().css('display')!='none')
{if($(this).is(':checked'))
{price=parseInt($(this).attr('price'));if(price>0)
{TotalPrice+=price;TotalHtml+='<label>'+$(this).parent().text().replace('*','')+'</label><span>'+price+'</span>руб.<br />';}}}});$('#total-sum').html(TotalPrice);$('#totals').html(TotalHtml);}
function changeType()
{var type=$('#MeetingsParticipantsType option:selected').val();switch(type)
{case'organizer':case'participant':$('p[show=guest]').hide();$('p[show=participant]').show();break;case'guest':$('p[show=guest]').show();$('p[show=participant]').hide();break;}}
