messages.noName='Имя обязательно должно присутствовать';messages.noRecord='Вы не можете редактировать этого таланта';messages.namePresent='Талант с таким именем у вас уже присутствует';function deleteTalent(linkObj,talentId)
{jQuery('#popup_delete_talent_yes').attr('href',linkObj.href);jQuery('#popup_delete_talent').find('div p span').html(jQuery('#talent_'+talentId).html());showPopup(linkObj,'popup_delete_talent');return false;}
function toggleContactForm()
{jQuery('#contact_text').toggle();jQuery('#contact_text_form').toggle();jQuery('#contact_text_edit_link').toggle();}
function toggleStationsForm()
{jQuery('#stations_text_edit_link').toggle();jQuery('#stations_form').toggle();}
function updateContactInfo(form)
{jQuery('#contact_button_edit').attr('disabled',true);jQuery.post(jQuery(form).attr('action'),jQuery(form).serialize(),function(answer)
{jQuery('#contact_button_edit').attr('disabled',false);if(answer.done==false){jQuery('#popup_simple p:first').html(messages[answer.error]);showPopup(form,'popup_simple');setTimeout("closePopup('popup_simple')",2000);return;}
if(answer.talent.contactFIO)
jQuery('#contactFIO').show().find('span').html(answer.talent.contactFIO);else
jQuery('#contactFIO').hide().find('span').html('');if(answer.talent.contactEmail)
jQuery('#contactEmail').show().find('span').html(answer.talent.contactEmail);else
jQuery('#contactEmail').hide().find('span').html('');if(answer.talent.contactPhone)
jQuery('#contactPhone').show().find('span').html(answer.talent.contactPhone);else
jQuery('#contactPhone').hide().find('span').html('');jQuery('#talent_name_header').html(answer.talent.name);toggleContactForm();},'json');return false;}
function renameTalentSong(form)
{form=jQuery(form);form.find('input[type=submit]').attr('disabled',true);jQuery.post(form.attr('action'),form.serialize(),function(answer){form.find('input[type=submit]').attr('disabled',false);if(answer.done){jQuery('#song_name').html(answer.SongName);closePopup('popup_talent_song_rename');return;}
jQuery('#popup_simple p:first').html('Что-то не срослось. Перегрузите страницу и попробуйте снова');showPopup(form,'popup_simple');setTimeout("closePopup('popup_simple')",2000);return;},'json');return false;}
function toggleStations()
{jQuery('#stations_top').replaceWith(jQuery('#stations_city').toggle());}
function toggleStationsCity(cityId)
{jQuery('#stations_city tbody').hide();jQuery('#stations_city_'+cityId).show();}
function setHitNumber(talentSongId)
{jQuery.get('/actions.html?action=get_sms_number&song_id='+talentSongId+'&ref_type=2',function(answer){if(answer)
{jQuery('#hitId').html(answer.hitId);if(answer.text)
jQuery('#sms_hit_text').value=answer.text;jQuery('#smshit').toggle();}},"json");}
function saveSmsText()
{jQuery('#sms_saved').hide();jQuery('#sms_saving').show();jQuery('#save_sms_button').disabled=true;jQuery.post(jQuery('#sms-text-form').action,jQuery('#sms-text-form').serialize(true),function(answer){if(answer){jQuery('#sms_saving').hide();jQuery('#sms_saved').show();jQuery('#save_sms_button').disabled=false;}},"json");}
function toggleTalentLink(){jQuery('#talent_link_title_link').toggle();jQuery('#talent_text_title_link').toggle();jQuery('#talent_link_title_blog').toggle();jQuery('#talent_text_title_blog').toggle();jQuery('#talent_input_link').toggle();jQuery('#talent_input_blog').toggle();jQuery('#talent_input_blog_preview').toggle();}
function talentAddFormCallback($form,answer)
{hide_errors($form);if(answer.done){location.href=answer.redirect_url;}
else{show_errors($form,answer.error);}}
function hide_errors($form)
{var $=jQuery;$('.error',$form).remove();}
function show_errors($form,errors)
{var $=jQuery,errorMessage;for(var inputClassName in errors)
{errorMessage=errors[inputClassName];show_error($('.'+inputClassName,$form).closest('tr'),errorMessage);}}
function show_error($el,message)
{if($el.length)
{var $=jQuery;$('<tr class="noborder error">\
     <td></td>\
     <td>\
      <div class="form-error">\
       <div class="top"></div>\
       <div class="text">'+message+'</div>\
      </div>\
     </td>\
    </tr>').insertAfter($el);}}
