var weekday_cut_rus=['вс','пн','вт','ср','чт','пт','сб'];var month_noun_rus=['января','февраля','марта','апреля','мая','июня','июля','августа','сентября','октября','ноября','декабря']
var maps;var taketrip_popup_flash;function closePopup(){$('body').find('.taketrip_popup_window').remove();$('body').find('.taketrip_popup_block').remove();$('body').css({'overflow-y':'auto','width':''});$('#bottom_panel').css({'width':''});}
var listener=function(){var object;var currentEvent;var t=this;this.listen={clicker:function(target,event){object=target;currentEvent=event;if(event.button==0){registerClickFunction.apply(t)}}}
var registerClickFunction=function(){var _class=object.attr('class')
if(_class.indexOf('cmd-')>=0){iMatch=_class.match(/cmd-([a-zA-Z_]+)(?:\s|$)/)
if(iMatch){if(typeof this.cmd[iMatch[1]]=='function'){this.cmd[iMatch[1]](object,currentEvent);}}}}
var registerMouseOverFunction=function(){var _class=object.attr('class');if(_class){if(_class.indexOf('over-')>=0){iMatch=_class.match(/over-([a-zA-Z]+)(?:\s|$)/);if(iMatch){if(typeof this.over[iMatch[1]]=='function'){this.over[iMatch[1]](object,currentEvent);}}
if(_class.indexOf('hover-')>=0){iHover=_class.match(/hover-([a-zA-Z_]+)(?:\s|$)/)
if(iHover){object.addClass(iHover[1])
object.unbind('mouseover').mouseout(function(){object.removeClass(iHover[1]);})}}}}}
var registerMouseOutFunction=function(){var _class=object.attr('class');if(_class.indexOf('out-')>=0){iMatch=_class.match(/out-([a-zA-Z_]+)(?:\s|$)/);if(iMatch){if(typeof this.out[iMatch[1]]=='function'){this.out[iMatch[1]](object,currentEvent);}}}}
this.cmd={}
this.over={}
this.out={}}
events=new listener()
$(document).ready(function(){$(document).bind('click',function(e){events.listen.clicker($(e.target),e);});if(navigator.appName.indexOf('Microsoft')!=-1){maps=window.mapsIe;}else{maps=window.document.maps;}
$('.edit_label').mouseover(function(){$(this).find('.i').addClass('i_hover');$(this).find('.t').addClass('t_hover');});$('.edit_label').mouseout(function(){$(this).find('.i').removeClass('i_hover');$(this).find('.t').removeClass('t_hover');});window.setTimeout(function(){$('.skype_name_highlight_offline').html('');$('.skype_name_highlight_online').html('');},800);$('.search_container').mouseover(function(){$('.search_choice').show();$('input[name="search"]').parent().addClass('active_w');});$('.search_container').mouseout(function(){$('.search_choice').hide();$('input[name="search"]').parent().removeClass('active_w');});$('input[name="search"]').blur(function(){});$('.search_choice').find('.item').click(function(){$('.search_choice').find('div').each(function(){$(this).removeClass('sel');$(this).find('i').removeClass('s');$(this).addClass('item_hover');});$(this).addClass('sel');$(this).find('i').addClass('s');$(this).removeClass('item_hover');$('.search_container').attr('type',$(this).attr('type'));});email_input=true;email_remind_input=true;password_input=true;$('.checkbox').mouseover(function(){$(this).find('i').addClass('sel');});$('.checkbox').mouseout(function(){$(this).find('i').removeClass('sel');});$(".checkbox").click(function(){var id=$(this).attr('id');if($('.checkbox_form').find('#'+id).length>1){$(this).find('i').addClass('active');$('.checkbox_form').find('#'+id).each(function(index,obj){if($(obj).find('i').attr('class')=="box inline active"){$(obj).find('i').removeClass('active');}});}
else{if($(this).find('i').attr('class')=="box inline active sel"||$(this).find('i').attr('class')=="box inline active"){$(this).find('i').removeClass('active');$(this).find('i').removeClass('sel');}
else{$(this).find('i').addClass('active');}}});$('.follow').mouseover(function(){$(this).find('.ico').addClass('ico_hover');$(this).find('.ico_false').addClass('ico_false_hover');$(this).find('.txt').addClass('txt_blue');});$('.follow').mouseout(function(){$(this).find('.ico').removeClass('ico_hover');$(this).find('.ico_false').removeClass('ico_false_hover');$(this).find('.txt').removeClass('txt_blue');});$('.scheme').find('.moving').hover(function(){var transport_name=$(this).attr('transport_name');var pre_obj=$(this).attr('pre_obj');var next_obj=$(this).attr('next_obj');var text=$(this).attr('text');var media=$(this).attr('media');var comments=$(this).attr('comments');var money=$(this).attr('money');var mood=$(this).attr('mood');$(this).prepend('<div class="scheme_info_label"><div class="border"><div class="content"><b>'+transport_name+'</b><br>из: <b>'+pre_obj+'</b><br>в:&nbsp;&nbsp;&nbsp;<b>'+next_obj+'</b>'
+'<div class="marginT5"><div class="ico_small ico_small_text_'+text+' inline"></div>'
+'<div class="ico_small ico_small_media_'+media+' inline"></div>'
+'<div class="ico_small ico_small_comments_'+comments+' inline"></div>'
+'<div class="ico_small ico_small_money_'+money+' inline"></div>'
+'<div class="ico_small ico_small_mood_'+mood+' inline"></div>'
+'</div></div></div><div class="arrow"></div></div>');},function(){$(this).find('.scheme_info_label').remove();});$('.scheme').find('.point').hover(function(){var address=$(this).attr('address');var media=$(this).attr('media');var text=$(this).attr('text');var comments=$(this).attr('comments');var house=$(this).attr('house');var eat=$(this).attr('eat');var other=$(this).attr('other');var mood=$(this).attr('mood');var weather=$(this).attr('weather');$(this).prepend('<div class="scheme_info_label scheme_info_label_point"><div class="border"><div class="content"><div class="bold" style="height:45px;">'+address+'</div>'
+'<div><div class="ico_small ico_small_text_'+text+' inline"></div>'
+'<div class="ico_small ico_small_media_'+media+' inline"></div>'
+'<div class="ico_small ico_small_comments_'+comments+' inline"></div>'
+'<div class="ico_small ico_small_house_'+house+' inline"></div>'
+'<div class="ico_small ico_small_eat_'+eat+' inline"></div>'
+'<div class="ico_small ico_small_other_'+other+' inline"></div>'
+'<div class="ico_small ico_small_weather_'+weather+' inline"></div>'
+'<div class="ico_small ico_small_mood_'+mood+' inline"></div></div></div></div><div class="arrow"></div></div>');},function(){$(this).find('.scheme_info_label').remove();});if($('input[name="current_trip"]').val()){var obj=$('#'+$('input[name="current_trip"]').val());obj.addClass('current_trip');var color=obj.attr('color');if($(obj).attr('current_user')=='true'){var link_img='';}else{var link_img=' link_img_'+color+'_hover';}
obj.append('<div class="ico_map_'+color+link_img+' cmd-show_trip_map"></div>');}
$(".show_ico_map").hover(function(){var color=$(this).attr('color');if($(this).attr('current_user')=='true'){var link_img='';}else{var link_img=' link_img_'+color+'_hover';}
if(!$(this).hasClass('current_trip')){$(this).append('<div class="ico_map_'+color+link_img+' cmd-show_trip_map"></div>');}},function(){var color=$(this).attr('color');if(!$(this).hasClass('current_trip')){$(this).find('.ico_map_'+color).remove();}});$(".show_ico_map").click(function(){var trip_id=$(this).attr('id');if(!$(this).hasClass('current_trip')){$('.show_ico_map').each(function(index,obj){if($(obj).hasClass('current_trip')){var color=$(obj).attr('color');$(obj).removeClass('current_trip');$(obj).find('.ico_map_'+color).remove();}});$(this).addClass('current_trip');showTripMap(trip_id);}
pageTop($(this));});});function showTripMap(trip_id,order,type){if(maps.mapShowTrip){if(order&&type){maps.mapShowTrip(trip_id,order,type);}
else{maps.mapShowTrip(trip_id,-1,'s');}};}
events.cmd.add_point_manual=function(obj){var object=$(obj).attr('obj');var type=$(obj).attr('type');window.location.href='#';maps.addPointManual(object,type);}
function returnDataPointManual(obj,type,value,x,y,country_name_code,address,time_zone,country_name,zoom){var objectSuggest=$(obj);objectSuggest.parents('.add_point').find('#hidden_geo').attr({'value':value,'x':x,'y':y,'country_name_code':country_name_code,'address':address+', '+country_name,'time_zone':time_zone,'zoom':zoom});objectSuggest.find('#suggest_input').val(address+', '+country_name);objectSuggest.find('.suggest_body_select').hide();objectSuggest.removeClass('suggest_white_active');objectSuggest.parents('.block').find('.image_point').css({'background':'url("/media/images/countrys/50x50/'+country_name_code.toLowerCase()+'.png")'});window.location.href='#add_route';if(type=='point_edit'){var order=objectSuggest.parents('.obj').attr('id');objectSuggest.parents('.container').find('.image_point').css({'background':'url("/media/images/countrys/50x50/'+country_name_code.toLowerCase()+'.png")'});objectSuggest.parents('.container').find('.p').css({'background':'url("/media/images/countrys/50x50/'+country_name_code.toLowerCase()+'.png")'});objectSuggest.parents('.container').find('.name').html(address+', '+country_name);changePoint(order,value,(address+', '+country_name),country_name_code,x,y,zoom,time_zone);}}
events.cmd.post_massage=function(obj){var object=$(obj).parents('.post_massage');var title=object.find('#title').val();var user_id=object.attr('user_id');var text=object.find('#text').val()
if(!user_id){$('#user_suggest').addClass('suggest_white_active');}
if(user_id&&text){$.blockUI();$(obj).removeClass('cmd-post_massage');$.post('/user/messages/post_massage',{title:title,user_id:user_id,text:text},function(e){window.location.href='/user/messages';});}}
events.cmd.send_feedback=function(obj){var validate=new ValidateForms(obj,'fail_w');var obj=$(obj);var form=obj.parents('.form');var email=validate.init('email','email').val();var title=validate.init('title','rus_eng').val();var message=form.find('textarea[name="message"]').val();if(!message){alert('напишите сообщение');}
if(validate.okay){$.blockUI();$.post('/send_feedback',{email:email,title:title,message:message},function(e){$.unblockUI();$('.post').hide();$('.status').show();if(e=='ok'){$('.status').text('СООБЩЕНИЕ ОТПРАВЛЕНО');}else{$('.status').text('СООБЩЕНИЕ НЕ ОТПРАВЛЕНО, ПОПРОБУЙТЕ ПОЗЖЕ');}
form.find('textarea[name="message"]').val('');form.find('input[name="title"]').val('');form.find('input[name="email"]').val('');});}}
function authInfoVk(response){if(response.session){$('#manage_vk').html('<input type="hidden" name="vkontakte" value="id'+response.session.mid+'"><a href="http://vkontakte.ru/id'+response.session.mid+'" class="marginL5 link_violet_hover" style="vertical-align:-6px;">'+response.session.mid+'</a><span class="link_violet_hover pointer marginL10 cmd-vk_logout" style="vertical-align:-6px;">выйти</span>');}else{$('#manage_vk').html('<span id="vk_id" class="marginL5 link_violet_hover pointer cmd-vk_login" style="vertical-align:-6px;">соединить</span>');}}
events.cmd.vk_logout=function(obj){VK.Auth.logout(function(response){VK.Auth.getLoginStatus(authInfoVk);});};events.cmd.vk_login=function(obj){VK.Auth.login(authInfoVk);};function authInfoFb(response){if(response.session){$('#manage_fb').html('<input type="hidden" name="facebook" value="'+response.session.uid+'"><a href="http://www.facebook.com/profile.php?id='+response.session.uid+'" class="marginL5 link_violet_hover" style="vertical-align:-6px;">'+response.session.uid+'</a><span id="fb_logout" class="link_violet_hover pointer marginL10 cmd-fb_logout" style="vertical-align:-6px;">выйти</span>');}else{$('#manage_fb').html('<span id="fb_id" class="marginL5 link_violet_hover pointer cmd-fb_login" style="vertical-align:-6px;">соединить</span>');}}
events.cmd.fb_logout=function(obj){FB.logout(authInfoFb);};events.cmd.fb_login=function(obj){FB.login(authInfoFb);};events.cmd.lj_login=function(obj){$('#popup').togglePopup('','','','','','livejournal','','','300','80',true,'fixed');};events.cmd.lj_logout=function(obj){$.post('/lj_logout',{},function(e){$('#manage_lj').html('<span class="marginL5 link_violet_hover pointer cmd-lj_login" style="vertical-align:-6px;">соединить</span>');});}
events.cmd.change_email=function(obj){var w=$(obj).parents('.form').width();var h=$(obj).parents('.form').height();var validate=new ValidateForms(obj,'fail_w');var password=validate.init('password','null').val();var email=validate.init('email','email').val();if(validate.okay){$(obj).parents('.form').prepend('<div class="preloader_popup" style="position:absolute; width:'+w+'px; height:'+h+'px;"><div style="margin-left:130px; margin-top:15px;" class="preloader"></div></div>');$.post('/change_email',{password:password,email:email},function(e){$('.preloader_popup').remove();if(e=='pass'){validate.init('password','email_base').val();}
if(e=='email'){validate.init('email','email_base').val();}
if(e=='change_email'){$(obj).parents('.form').html('<div style="text-align:center; line-height:70px;">На '+email+' выслано письмо с активацией.</div>');setTimeout(function(){$('#popup').closePopup()},5000);}});}};events.cmd.reload_inbox=function(obj){$('#inbox').load('/user/messages?partial=1&page=0&box=inbox');}
events.cmd.inbox_delete_massage=function(obj){var id=$(obj).parents('.messages').attr('id');$.post('/user/messages/inbox/delete_message',{id:id},function(e){$('#inbox').load('/user/messages?partial=1&page=0&box=inbox');});}
events.cmd.reload_outbox=function(obj){$('#outbox').load('/user/messages?partial=1&page=0&box=outbox');}
events.cmd.outbox_delete_massage=function(obj){var id=$(obj).parents('.messages').attr('id');$.post('/user/messages/outbox/delete_message',{id:id},function(e){$('#outbox').load('/user/messages?partial=1&page=0&box=outbox');});}
events.cmd.inbox_delete_massage_details=function(obj){$.post('/user/messages/inbox/delete_message',{id:$(obj).attr('id')},function(e){window.location.href="/user/messages";});}
events.cmd.outbox_delete_massage_details=function(obj){$.post('/user/messages/outbox/delete_message',{id:$(obj).attr('id')},function(e){window.location.href="/user/messages";});}
events.cmd.re_massage=function(obj){var user_id=obj.attr('user_id');var re=obj.attr('re');var text=obj.parents('.comments').find('#text').val();var title=obj.parents('.comments').find('.title').find('span').html();if(text){$(obj).removeClass('cmd-re_massage');$.post('/user/messages/inbox/re_message',{user_id:user_id,text:text,title:title,re:re},function(e){window.location.href="/user/messages";});}}
events.cmd.show_media=function(obj){var object_type=$(obj).attr('object_type');var media_id=$(obj).attr('media_id');var object_id=$(obj).attr('object_id');$('#popup').togglePopup([],[],media_id,object_id,object_type,'media','bind','','','',true,'fixed');return false;}
events.cmd.change_pass=function(obj){var w=$(obj).parents('.form').width();var h=$(obj).parents('.form').height();var validate=new ValidateForms(obj,'fail_w');var password=validate.init('password','null').val();var password_new=validate.init('password_new','null').val();var password_confirm=validate.init('password_confirm','null').val();if(validate.okay){if(password_new!=password_confirm){validate.init('password_new','email_base').val();validate.init('password_confirm','email_base').val();}else{$(obj).parents('.form').prepend('<div class="preloader_popup" style="position:absolute; width:'+w+'px; height:'+h+'px;"><div style="margin-left:130px; margin-top:35px;" class="preloader"></div></div>');$.post('/change_pass',{password:password,password_new:password_new},function(e){$('.preloader_popup').remove();if(e=='false'){validate.init('password','email_base').val();}else{$(obj).parents('.form').html('<div style="text-align:center; line-height:90px;">Пароль изменен.</div>');setTimeout(function(){$('#popup').closePopup()},1000);}});}}}
events.cmd.connect_livejournal=function(obj){var w=$(obj).parents('.form').width();var h=$(obj).parents('.form').height();var validate=new ValidateForms(obj,'fail_w');var lj_login=validate.init('lj_login','null').val();var lj_pass=validate.init('lj_pass','null').val();if(validate.okay){$(obj).parents('.form').prepend('<div class="preloader_popup" style="position:absolute; width:'+w+'px; height:'+h+'px;"><div style="margin-left:130px; margin-top:35px;" class="preloader"></div></div>');$.post('/connect_livejournal',{lj_login:lj_login,lj_pass:lj_pass},function(e){if(e=='true'){$('.preloader_popup').remove();$('#popup').closePopup()
$('#manage_lj').html('<a href="http://'+lj_login+'.livejournal.com/" class="marginL5 link_violet_hover" style="vertical-align:-6px;">'+lj_login+'</a><span id="lj_logout" class="link_violet_hover pointer marginL10 cmd-lj_logout" style="vertical-align:-6px;">выйти</span>');}else{validate.init('lj_login','email_base').val();validate.init('lj_pass','email_base').val();$('.preloader_popup').remove();}});}}
function follow(obj,id,status){if(status=='True'){$.post('/user/follow_del',{user_id:id},function(e){if(e=='true'){window.location.reload();}});}else{$.post('/user/follow_to',{user_id:id},function(e){if(e=='true'){window.location.reload();}});}}
events.cmd.re_activation=function(obj){$(obj).removeClass('cmd-re_activation');$(obj).removeClass('pointer');$(obj).removeClass('link_blue_hover');$(obj).html('Письмо выслано.');$.post('/re_activation',{},function(e){$(obj).html('Письмо выслано.');});};events.cmd.registration=function(obj){var validate=new ValidateForms(obj,'fail_w');var obj=$(obj);var form=obj.parents('.form');var first_name=validate.init('first_name','rus_eng').val();var last_name=validate.init('last_name','rus_eng').val();var day=validate.init('day','day').val();var year=validate.init('year','year').val();var month=form.find('#month').attr('value');var email=validate.init('email','email').val();var password=validate.init('password','null').val();var captcha=validate.init('captcha','null').val();var captchaH=validate.init('captchaH','null').val();var time_zone=form.find('input[name="time_zone"]').val();var sex=form.find('input[name="sex"]').val();var affiliate=validate.init('affiliate','null').val();if(validate.okay){$.blockUI();$.post('/registration_post',{first_name:first_name.toString(),last_name:last_name.toString(),email:email.toString(),password:password.toString(),captcha:captcha,captchaH:captchaH,day:day,month:month,year:year,time_zone:time_zone,affiliate:affiliate,sex:sex},function(e){$.unblockUI();if(e.error=='false'){window.location.href="/user/"+e.id;}
else{validate.init(e.error,'email_base').val();}
if(e.error=='error'){alert('Не удалось зарегистрироваться, попробуйте позднее.')}},'json');}}
function reload_photo_video(){$("#photo_video").load("reload_photo_video",function(e){});}
function show_details_from_flash(obj,trip_id,type,id,order){show_details($('#'+obj),trip_id,type,id,order);}
function show_details(obj,trip_id,type,id,order,p_geo_id){if($('.result').attr('type')=='trips'){window.location.href='/trip/'+trip_id+'/'+type+'/'+id+'/'+order+'/normal';}
else{location.hash="!/trip/"+trip_id+"/"+type+"/"+id+"/"+order+"/normal";$("#detals_container").html('<div align="center"><div class="preloader"></div></div>');$("#user_this_place").html('');$("#detals_container").load("/trip/"+trip_id+"/"+type+"/"+id+"/"+order+"/ajax",function(e){});$('.scheme').find('.s').each(function(obj){$(this).addClass('opacity50_hover');$(this).addClass('opacity50');});$(obj).find('.s').removeClass('opacity50');maps.centerMap(order,type);return false;}}
events.cmd.search_go=function(obj){var validate=new ValidateForms(obj,'fail');var search=validate.init('search','null').val();var type=$(obj).parents('.form').find('.search_container').attr('type');if(validate.okay){window.location.href='/search/'+search+"/"+type;}}
function pageTop(obj){var anchor=$(this);$('html, body').stop().animate({scrollTop:0},500);return false;}
String.prototype.rkeys=function(dict){var text=this;for(var key in dict){text=text.split('['+key+']').join(dict[key]);}
return text}
function switch_language(type){$.get('/language/'+type,'',function(){window.location.reload();});}
function centerDocument(obj){var marginLeft=($(document).width()/2)-($(obj).width()/2);var marginTop=$(document).scrollTop()+($(window).height()/2)-($(obj).height()/2);return[marginLeft,marginTop];}
function show_edit_label(obj){$(obj).find('.edit_label').show();}
function hide_edit_label(obj){$(obj).find('.edit_label').hide();}
function login(obj){var validate=new ValidateForms(obj,'fail');var email=validate.init('email','email').val();var pass=validate.init('password','null').val();if(validate.okay){$.post('/log_in',{email:email,pass:pass},function(e){if(e=='0'){validate.init('email','email_base').val();validate.init('password','email_base').val();}
else{window.location.reload();}});}}
function remind_pass(obj){var validate=new ValidateForms(obj,'fail');var email=validate.init('email_remind','email').val();if(validate.okay){$.blockUI();$.post('/remind_pass',{email:email},function(e){if(e=='false'){$.unblockUI();validate.init('email_remind','email_base').val();}
else{$.unblockUI();$(".remind_pass").hide();$(".message_pass").show();}});}}
function remind_pass_show(obj){email_input=true;email_remind_input=true;password_input=true;$(".entry_site").hide();$(".remind_pass").show();}
function entry_site_show(obj){email_input=true;email_remind_input=true;password_input=true;$("#password").parent().show();$(".entry_site").show();$(".remind_pass").hide();$(".message_pass").hide();}
function ValidateForms(obj,form_type){this.okay=true;this.form=$(obj).parents('.form');this.setNormall=function(obj){obj.parent().removeClass(form_type)
obj.removeClass('text_w');}
this.setBad=function(obj){obj.parent().addClass(form_type);obj.addClass('text_w');}
this.init=function(object,type){var el=this.form.find('[name="'+object+'"]');this.setNormall(el);el.focus(function(){el.parent().removeClass(form_type);});switch(type){case'digit':if(!el.val().match(/^\d{1,11}$/)){this.okay=false;this.setBad(el);}
break;case'null':if(!el.val()){this.okay=false;this.setBad(el);}
break;case'rus_eng':if(!el.val().match(/^[а-яА-Яa-zA-Z0-9_]+?$/)){this.okay=false;this.setBad(el);}
break;case'email':if(!el.val().match(/^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$/)){this.okay=false;this.setBad(el);}
break;case'phone':if(!el.val().match(/^[0-9\s-\(\)-\+]+$/)){this.okay=false;this.setBad(el);}
break;case'email_base':this.okay=false;this.setBad(el);case'day':if(!el.val().match(/^\d{1,11}$/)||el.val()>31||el.val()<1||!el.val()){this.okay=false;this.setBad(el);}
break;case'year':if(!el.val().match(/^\d{1,11}$/)||el.val()>2100||el.val()<1900||!el.val()){this.okay=false;this.setBad(el);}
break;case'hour':if(!el.val().match(/^\d{1,11}$/)||el.val()>23||el.val()<-1||!el.val()){this.okay=false;this.setBad(el);}
break;case'minute':if(!el.val().match(/^\d{1,11}$/)||el.val()>59||el.val()<-1||!el.val()){this.okay=false;this.setBad(el);}
break;default:if(!el.val()){this.okay=false;this.setBad(el);}
break;}
return el;}}
events.cmd.select_item=function(obj){var object_id=$(obj).parents('.select_white').attr('id');var object=$(obj).parents('.body_select').attr('object');$(obj).parents('.body_select').hide();$(obj).parents('.select_white').find('.cont').html($(obj).html());$(obj).parents('.select_white').find('input').val($(obj).attr('d'));$(obj).parents('.select_white').attr('value',$(obj).attr('d'));$(obj).parents('.select_white').removeClass('select_white_active')
if(object){if($(obj).attr('d')=='none_choose'){$('#'+object).hide();}
else{$('#'+object).show();}}
if(typeof select_function=='function'){select_function(object_id,$(obj).attr('d'));}};$(document).mousedown(function(e){if(!$(e.target).parents('.select_white')[0]){$('.body_select').hide();$('.select_white').removeClass('select_white_active')}});events.cmd.show_select=function(obj){if($(obj).parents('.select_white').attr('ajax')=='False'){$('.select_white').removeClass('fail_select');$('.body_select').hide();$('.select_white').removeClass('select_white_active')
if($(obj).parents('.select_white').hasClass('select_white_active')){$(obj).parents().find('.body_select').hide();$(obj).parents('.select_white').removeClass('select_white_active');}
else{$(obj).parent().parent().find('.body_select').show();$(obj).parents('.select_white').addClass('select_white_active');}}
else{$(obj).parent().parent().find('.body_select').show();$(obj).parents('.select_white').addClass('select_white_active');var container=$(obj).parents('.select_white').find('.body').find('div');if($(obj).parents('.select_white').attr('full')!='true'){$.post('/get_currency',{},function(e){$(obj).parents('.select_white').attr({'full':'true'});for(var a=0;a<e.length;a++){$(container).append('<div d="'+e[a].code_int+'" onclick="events.cmd.select_item(this)" class="item" title="'+e[a].name+'"><span class="inline flags '+e[a].country+'"></span><span class="paddingL5">'+e[a].code_char+'</span></div>');}},'json');}}}
events.cmd.add_comments=function(obj){var object=$(obj).parents('.comments').find('.comments_block');var text=$(obj).parents('.comments').find('#comment_form');if(text.val()){$.post('/add_comments',{text:text.val(),type:obj.attr('type'),id:obj.attr('id'),u:obj.attr('u'),t:obj.attr('t')},function(json){object.append('<div class="item borderB paddingB10"><div class="inline img"><a href="/user/'+json.user_id+'" class="link_yellow_hover"><img src="/media/user/avatars/a_25x25/'+json.avatar+'"></a></div><div class="inline name"><a href="/user/'+json.user_id+'" class="link_yellow_hover">'+json.first_name+'<br>'+json.last_name+'</a></div><div class="inline text">'+json.text+'<div class="data">оставлен только что</div></div><div class="cmd-del_comments inline pointer" id="'+json.id+'"></div></div>');text.val('');},'json');}}
events.cmd.del_comments=function(obj){$.post('/del_comments',{id:$(obj).attr('id')},function(json){$(obj).parents('.item').fadeOut('fast',function(){$(this).remove();});});}
Cursors=new CursorsClass();function CursorsClass(){this.cursor=function(obj,add,remove){$(document.body).addClass(add);$(obj).removeClass(remove);}
this.clear=function(obj,add,remove){$(document.body).removeClass(add);$(obj).addClass(remove);}}
function Select(){this.zindex=2000;this.full_box=function(name){var div=$(document.createElement("div")).addClass('selectbox');var hidden=$(document.createElement("input")).attr("type","hidden").attr("name",name)
hidden.appendTo(div)
return div}
this.row_box=function(){return $(document.createElement("div")).addClass('open');}
this.current_box=function(){return $(document.createElement("div")).addClass('current');}
cursor=this;$(document).mousedown(function(e){if(!$(e.target).parents('.selectbox')[0])$('.selectbox .open').hide();});this.row=function(id,name,image){var div=$(document.createElement("div")).addClass('row');if(image){var img=$(document.createElement("img"));img.attr("src",image);img.appendTo(div);}
div.attr("pid",id)
var text=$(document.createElement("div")).addClass('text');text.html(name);text.appendTo(div);return div;}
this.load=function(obj){if(obj){obj.each(function(){o=$(this);var json=[];var width=o.width();var sel=false;var selected=false;o.find('option').each(function(){if($(this).attr("selected")){sel=true;selected=true;}
else
sel=false;json.push({"id":$(this).attr("value"),"value":$(this).html(),"selected":sel})});cursor.generate({object:o,json:json,width:width,selected:selected,name:o.attr("name")});});}}
this._init_=function(obj){cursor=this;this.load(obj);}
this.generate=function(options){var width=options.width;var obj=options.object;var json=options.json;var name=options.name;if(json){width=options.width;var full_box=this.full_box(name);var current_box=this.current_box();var row_box=this.row_box();var iter=0;if(width)
full_box.css({width:width});if(json.length<=7){row_box.css({width:width+'px'});current_box.css({width:(width-10)+'px',zIndex:this.zindex});}
else{row_box.css({width:width+28+'px',overflowY:"scroll",height:"163px",zIndex:this.zindex});current_box.css({width:width+'px'});}
this.zindex++;for(var i in json){var img=false;var id=json[i].id;var value=json[i].value;if(json.img)img=json.img;var cur_row=this.row(id,value,img);if((iter==0&&!options.selected)||(json[i].selected==true)){cur_row.appendTo(current_box);current_box.appendTo(full_box);full_box.find('input').val(id)}
else cur_row.appendTo(row_box);cur_row.click(function(){var currentSelected=current_box.find('.row');if($(this).parent()[0]!=current_box[0]){var old=currentSelected.clone(true);full_box.find('input').val($(this).attr("pid"));currentSelected.replaceWith($(this));old.prependTo(row_box);row_box.hide();}});iter++;}
row_box.appendTo(full_box);row_box.hide();current_box.click(function(){if(row_box.css("display")=="none"){$('.selectbox .open').hide();row_box.show();row_box.scrollTop(0)}
else row_box.hide();})
if(obj)
obj.replaceWith(full_box);return full_box;}}}
function transport_select(obj){var current=$(obj);current.find('.list div').each(function(){$(this).click(function(){var objSheme=$('.scheme').find('#m'+$(this).parents('.tranport_list').attr('order')).find('div');objSheme.attr('class','m cmd-edite_route');objSheme.addClass('m t_30_'+$(this).attr('pid'));current.parents('.block').find('[name=transport]').val($(this).attr('pid'));current.parents('.block').find('[name=transport]').attr({'title':$(this).attr('title')});current.parents('.block').find('.image_moving').attr('class','image_moving');current.parents('.block').find('.image_moving').addClass('t_50_'+$(this).attr('pid'));});});}
function Search(){var cursor=this;var replaceObjects={};this.init=function(obj){var b=this;$(obj).each(function(){var o=$(this);cursor.bindClick(o);});}
this.search_form={timeout:false,box:function(oldObject){var div=$(document.createElement("div")).addClass('geo_search');div.html('<input type="text" style="width:150px;" class="form" name="form"><input type="submit" name="cancel" class="bt" style="width:50px;" value="кансел"/><input type="button" class="bt" value="okey"/><br>');var hidden=$(document.createElement("input")).attr("type","hidden").attr("name","geo_id").appendTo(div);var resultDiv=$(document.createElement("div")).addClass('geo_result');resultDiv.css({display:"none"});resultDiv.appendTo(div)
cursor=this;div.find('input[name="form"]').click(function(){this.select()}).keyup(function(){cursor.req(div,resultDiv,cursor.row,resultDiv.width(),oldObject)})
this.obj=div;div.find('input[name="cancel"]').click(function(){var f=cursor.box(oldObject);div.replaceWith(oldObject);oldObject.click(function(){var f=cursor.box(oldObject);oldObject.replaceWith(f);return false;});return false;})
return div},req:function(obj,resultDiv,tpl,rWidth,oldObject){resultDiv.empty();resultDiv.hide();clearTimeout(this.timeout);var text=obj.find('input[name="form"]').val();var geo_id=obj.find('input[name="geo_id"]')
this.timeout=setTimeout(function(){geo_id.val('');if(text){$.post('/point/search',{text:text},function(json){if(json.length>0){if(json.length<=7)
resultDiv.css({"overflow-y":"hidden"});else
resultDiv.css({"overflow-y":"scroll"});resultDiv.show();for(var i in json)
tpl(obj,json[i].id,json[i].address,oldObject,json[i].country_name_code).appendTo(resultDiv)}
else{resultDiv.hide();geo_id.val('');resultDiv.empty()}},'json');}},300);},row:function(obj,id,name,oldObject,country_name_code){var roww=$(document.createElement("div")).addClass('row');roww.html(name);var old=oldObject;var cur=cursor;roww.click(function(){old.find('a').html(name);old.find('input').val(id);obj.parent().parent().find('.image_point').removeClass('fail');obj.parent().parent().find('.image_point').removeClass('default');obj.parent().parent().find('.image_point').css({'background':'url("/media/images/countrys/50x50/'+country_name_code.toLowerCase()+'.png") no-repeat'});obj.replaceWith(old);old.click(function(){var f=cur.box(old);old.replaceWith(f);return false;});})
return roww}}
this.bindClick=function(object){var cur=cursor;object.click(function(){var f=cur.search_form.box(object);object.replaceWith(f);return false;});}}
Alert=new AlertClass();function AlertClass(){this.save=function(x,y,text){$('.alert_save').append('<div class="save_alert">'+text+'</div>');$('.alert_save').find('.save_alert').css({'top':y+'px','left':x+'px'});$('.save_alert').fadeIn(100).fadeTo(300,1).fadeOut(2000);}
this.ok=function(func){if(typeof this.function_ok=='function'){this.function_ok();this.function_ok='';$('.alert_confirm').html('');}else{$('.alert_confirm').html('');}}
this.function_ok='';this.confirm=function(x,y,text,func){var alertHTML='<div class="confirm_alert"><table border="0" cellpadding="0" cellspacing="0"><tr><td class="l_u"></td><td class="u"></td><td class="r_u"></td></tr><tr><td class="l"></td><td class="body" align="center" valign="center"><div>'+text+'</div><div class="marginT5"><span class="marginR15 link_blue_hover pointer" onclick="Alert.ok(this)"><b>ДА</b></span><span class="link_blue_hover pointer" onclick="Alert.hide();"><b>НЕТ</b></span></div></td><td class="r"></td></tr><tr><td class="l_d"></td><td class="d"></td><td class="r_d"></td></tr></table></div>';$('.alert_confirm').html('');$('.alert_confirm').append(alertHTML);$('.alert_confirm').find('.confirm_alert').css({'top':y+'px','left':x+'px'});if(func){this.function_ok=func;}}
this.hide=function(){$('.alert_confirm').html('');}}
var currentMedia;var comments_show=true;var position='absolute';$.fn.togglePopup=function(arrayMedia,param,current_id,object_id,object_type,popupType,type,else_param,width,height,block,position){if(block){$('.block_test').show();}
if(position){$('.popup').css({'position':position});}else{$('.popup').css({'position':'absolute'});}
if(width){$('#popup').find('.u').attr({'width':width});$('#test').attr({'width':width});$('#pre_content').attr({'width':width});$('.header_popup').css({'width':width-97+'px'});}
if(height){$('#test').attr({'height':height});$('#pre_content').attr({'height':height});}
if(!Array.indexOf){Array.prototype.indexOf=function(obj){for(var i=0;i<this.length;i++){if(this[i]==obj){return i;}}
return-1;}}
switch(popupType){case'media':for(a=0;a<arrayMedia.length;a++){if(arrayMedia[a].id==current_id){currentMedia=a;break;}}
$(this).postMedia(arrayMedia,current_id,object_id,object_type,type);break;case'friends':$(this).postFriends(else_param);break;case'pass':$(this).postPass(else_param);break;case'email':$(this).postEmail(else_param);break;case'livejournal':$(this).postLivejournal(else_param);break;case'show_photo':$(this).postShowPhoto(else_param);break;}
$(this).alignCenter();$(this).show();}
$.fn.postMedia=function(arrayMedia,current_id,object_id,object_type,type){$('#comments_contants').html('');$('#comments').show();$('.manager').html('<input type="button" value="" class="inline prev" />'+
'<input type="button" value="" class="inline next" />'+
'<input type="button" value="" onclick="$(\'#popup\').closePopup(); return false;" class="inline close" />');$('.prev').click(function(){$(this).prevMedia(arrayMedia);});$('.next').click(function(){$(this).nextMedia(arrayMedia);});$("#popup_content").html('<div class="preloader"></div>');$.post('/show_photo_video',{id:current_id,object_id:object_id,object_type:object_type,type:type},function(e){comments_show=true;if(e.comments_length){$('#comments').find('span').html('комментарии ('+e.comments_length.length+')');}else{$('#comments').find('span').html('комментарии');}
var avatar;if(e.user_avatar==null){avatar='/media/no_avatar.gif';}else{avatar='/media/user/avatars/a_25x25/'+e.user_avatar;}
switch(type){case'bind':if(arrayMedia.length!=1){$('.prev').show();$('.next').show();}
if(e.about){var about=e.about;}
else{var about='Нет названия';}
if(e.object_type=='m'){var obj='<a class="point_address link_yellow_hover" href="/trip/'+e.trip_id+'/m/'+e.object_id+'/'+e.order+'/normal">'+e.moving_transport+'</a> — '+e.point_address;}
else{var obj='<a class="point_address link_yellow_hover" href="/trip/'+e.trip_id+'/p/'+e.object_id+'/'+e.order+'/normal">'+e.point_address+'</a>';}
$('.header_popup').html('<div class="inline userpic"><a href="/user/'+e.user_id+'"><img src="'+avatar+'"></a></div>'+
'<div class="inline name"><a class="link_yellow_hover" href="/user/'+e.user_id+'">'+e.user_first_name+'<br>'+e.user_last_name+'</a></div>'+
'<div class="inline tripname">'+
'<div class="about">'+about+'</div>'+
'<div class="trip_title"><a class="point link_yellow_hover" href="/trip/'+e.trip_id+'">'+e.trip_title+'</a>  — '+obj+'</div>'+
'</div>');switch(e.type){case'youtube':$('#popup_content').html('<div trip_id="'+e.trip_id+'" id="'+current_id+'"><object>'+
'<param name="movie" value="http://www.youtube.com/v/'+e.video_id+'?version=3&color1=0xFFFFFF&color2=0xFFFFFF&feature=player_embedded">'+
'<param name="allowFullScreen" value="true">'+
'<param name="allowScriptAccess" value="always">'+
'<embed src="http://www.youtube.com/v/'+e.video_id+'?version=3&color1=0xFFFFFF&color2=0xFFFFFF&feature=player_embedded" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="385"></object></div>');break;case'vimeo':$('#popup_content').html('<div trip_id="'+e.trip_id+'" id="'+current_id+'">'+
'<object width="640" height="385">'+
'<param name="allowfullscreen" value="true" />'+
'<param name="allowscriptaccess" value="always" />'+
'<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+e.video_id+'&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=&fullscreen=1&autoplay=0&loop=0" />'+
'<embed src="http://vimeo.com/moogaloop.swf?clip_id='+e.video_id+'&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=&fullscreen=1&autoplay=0&loop=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="640" height="385"></embed></object>'+
'</div>');break;case null:$('#popup_content').html('<div trip_id="'+e.trip_id+'" id="'+current_id+'"><img class="pointer next_img" trip_id="'+e.trip_id+'" id="'+current_id+'" src="/media/user/photo/p_660x495/'+e.filename+'"></div>');$('.next_img').click(function(){$(this).nextMedia(arrayMedia);});break;}
break;case'bind_inbox':if(e.about){var about=e.about;}
else{var about='Нет названия';}
if(e.object_type=='m'){var obj='<a class="point_address link_yellow_hover" href="/trip/'+e.trip_id+'/m/'+e.object_id+'/'+e.order+'/normal">'+e.moving_transport+'</a> — '+e.point_address;}
else{var obj='<a class="point_address link_yellow_hover" href="/trip/'+e.trip_id+'/p/'+e.object_id+'/'+e.order+'/normal">'+e.point_address+'</a>';}
$('.header_popup').html('<div class="inline userpic"><a href="/user/'+e.user_id+'"><img src="'+avatar+'"></a></div>'+
'<div class="inline name"><a class="link_yellow_hover" href="/user/'+e.user_id+'">'+e.user_first_name+'<br>'+e.user_last_name+'</a></div>'+
'<div class="inline tripname">'+
'<div class="about">'+about+'</div>'+
'<div class="trip_title"><a class="point link_yellow_hover" href="/trip/'+e.trip_id+'">'+e.trip_title+'</a>  — '+obj+'</div>'+
'</div>');switch(e.type){case'youtube':$('#popup_content').html('<div trip_id="'+e.trip_id+'" id="'+current_id+'"><object>'+
'<param name="movie" value="http://www.youtube.com/v/'+e.video_id+'?version=3&color1=0xFFFFFF&color2=0xFFFFFF&feature=player_embedded">'+
'<param name="allowFullScreen" value="true">'+
'<param name="allowScriptAccess" value="always">'+
'<embed src="http://www.youtube.com/v/'+e.video_id+'?version=3&color1=0xFFFFFF&color2=0xFFFFFF&feature=player_embedded" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="385"></object></div>');break;case'vimeo':$('#popup_content').html('<div trip_id="'+e.trip_id+'" id="'+current_id+'">'+
'<object width="640" height="385">'+
'<param name="allowfullscreen" value="true" />'+
'<param name="allowscriptaccess" value="always" />'+
'<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+e.video_id+'&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=&fullscreen=1&autoplay=0&loop=0" />'+
'<embed src="http://vimeo.com/moogaloop.swf?clip_id='+e.video_id+'&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=&fullscreen=1&autoplay=0&loop=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="640" height="385"></embed></object>'+
'</div>');break;case null:$('#popup_content').html('<div trip_id="'+e.trip_id+'" id="'+current_id+'"><img trip_id="'+e.trip_id+'" id="'+current_id+'" src="/media/user/photo/p_660x495/'+e.filename+'"></div>');break;}
break;default:if(e.about){var about=e.about;}
else{var about='Нет названия';}
$('.header_popup').html('<div class="inline userpic"><a href="/user/'+e.user_id+'"><img src="'+avatar+'"></a></div>'+
'<div class="inline name"><a class="link_yellow_hover" href="/user/'+e.user_id+'">'+e.user_first_name+'<br>'+e.user_last_name+'</a></div>'+
'<div class="inline tripname" trip="'+e.trip_id+'">'+
'<div class="about">'+about+'</div>'+
'<div class="trip_title"><a class="trip_title link_yellow_hover" href="/trip/'+e.trip_id+'">'+e.trip_title+'</a></div>'+
'</div>');switch(e.type){case'youtube':$('#popup_content').html('<div trip_id="'+e.trip_id+'" id="'+current_id+'"><object>'+
'<param name="movie" value="http://www.youtube.com/v/'+e.video_id+'?version=3&color1=0xFFFFFF&color2=0xFFFFFF&feature=player_embedded">'+
'<param name="allowFullScreen" value="true">'+
'<param name="allowScriptAccess" value="always">'+
'<embed src="http://www.youtube.com/v/'+e.video_id+'?version=3&color1=0xFFFFFF&color2=0xFFFFFF&feature=player_embedded" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="385"></object></div>');break;case'vimeo':$('#popup_content').html('<div trip_id="'+e.trip_id+'" id="'+current_id+'">'+
'<object width="640" height="385">'+
'<param name="allowfullscreen" value="true" />'+
'<param name="allowscriptaccess" value="always" />'+
'<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+e.video_id+'&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=&fullscreen=1&autoplay=0&loop=0" />'+
'<embed src="http://vimeo.com/moogaloop.swf?clip_id='+e.video_id+'&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=&fullscreen=1&autoplay=0&loop=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="640" height="385"></embed></object>'+
'</div>');break;case null:$('#popup_content').html('<div trip_id="'+e.trip_id+'" id="'+current_id+'"><img src="/media/user/photo/p_660x495/'+e.filename+'?i='+Math.random()+'"></div>');break;}
break;}},"json");}
$.fn.alignCenter=function(){var centerDivWidth=($(document).width()/2)-($(this).width()/2);var screenWidth=$(document).width();var marginLeftPr=centerDivWidth/screenWidth*100+'%';var centerDivHeight=($(window).height()/2)-($(this).height()/2);var screenHeight=$(document).height();var marginTopPr=centerDivHeight/screenHeight*100+'%';return $(this).css({'left':marginLeftPr,'top':marginTopPr});};$.fn.closePopup=function(){$('.block_test').hide();$(this).hide();$('.header_popup').html('');$('#popup_content').html('');$('#comments').hide();$.unblockUI();};$.fn.nextMedia=function(arrayMedia){if(currentMedia<arrayMedia.length-1){currentMedia++;}else{currentMedia=0;}
$(this).postMedia(arrayMedia,arrayMedia[currentMedia].id,arrayMedia[currentMedia].object_id,arrayMedia[currentMedia].object_type,'bind');};$.fn.prevMedia=function(arrayMedia){if(currentMedia>0){currentMedia--;}else{currentMedia=arrayMedia.length-1;}
$(this).postMedia(arrayMedia,arrayMedia[currentMedia].id,arrayMedia[currentMedia].object_id,arrayMedia[currentMedia].object_type,'bind');};$.fn.postFriends=function(else_param){$('.header_popup').html('');$('#popup_content').html('');$('#comments_contants').html('');$('#comments').hide();$("#popup_content").load("/trip/show_friends",{trip_id:else_param},function(e){});}
$.fn.postShowPhoto=function(else_param){if(else_param.title=='добавить описание'){var title='нет названия'}else{var title=else_param.title;}
$('.header_popup').html('<span style="font-weight:bold; line-height:30px; padding-left:3px;">'+title+'</span>');switch(else_param.object_type){case'youtube':$('#popup_content').html('<object>'+
'<param name="movie" value="http://www.youtube.com/v/'+else_param.video_id+'?version=3&color1=0xFFFFFF&color2=0xFFFFFF&feature=player_embedded">'+
'<param name="allowFullScreen" value="true">'+
'<param name="allowScriptAccess" value="always">'+
'<embed src="http://www.youtube.com/v/'+else_param.video_id+'?version=3&color1=0xFFFFFF&color2=0xFFFFFF&feature=player_embedded" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="385"></object>');break;case'vimeo':$('#popup_content').html('<object width="640" height="385">'+
'<param name="allowfullscreen" value="true" />'+
'<param name="allowscriptaccess" value="always" />'+
'<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+else_param.video_id+'&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=&fullscreen=1&autoplay=0&loop=0" />'+
'<embed src="http://vimeo.com/moogaloop.swf?clip_id='+else_param.video_id+'&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=&fullscreen=1&autoplay=0&loop=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="640" height="385"></embed></object>');break;case'photo':$("#popup_content").html('<img src="/media/user/photo/p_660x495/'+else_param.path+'?'+Math.ceil(100*Math.random())+'">');break;}}
$.fn.postPass=function(else_param){$('.header_popup').html('<span style="font-weight:bold; line-height:30px; padding-left:3px;">СМЕНА ПАРОЛЯ</span>');$("#popup_content").html('<div class="preloader"></div>');$("#popup_content").load("get_pass_tpl",function(e){});}
$.fn.postEmail=function(else_param){$('.header_popup').html('<span style="font-weight:bold; line-height:30px; padding-left:3px;">СМЕНА E-MAIL</span>');$("#popup_content").html('<div class="preloader"></div>');$("#popup_content").load("get_mail_tpl",function(e){});}
$.fn.postLivejournal=function(else_param){$('.header_popup').html('<span style="font-weight:bold; line-height:30px; padding-left:3px;">СОЕДЕНЕНИЕ С LIVEJOURNAL</span>');$("#popup_content").html('<div class="preloader"></div>');$("#popup_content").load("get_livejournal_tpl",function(e){});}
$.fn.showComments=function(){$("#comments_contants").html('<div class="preloader" style="margin-left:320px;"></div>');$('.popup').css({'position':'absolute'});switch(comments_show){case true:$("#comments_contants").load("/show_photo_video_comments/"+$('#popup_content').find('div').attr('id')+"/"+$('#popup_content').find('div').attr('trip_id'),function(e){});comments_show=false;break;case false:$("#comments_contants").html('');comments_show=true;break;}}
function popupFlashShow(id,object_type,object_id){taketrip_popup_flash(id);}
events.cmd.like_bt=function(obj){$(obj).removeClass('like_bt_sel');var object_id=$(obj).attr('object_id');var type=$(obj).attr('type');$.post('/like',{object_id:object_id,type:type},function(e){var length=parseInt($(obj).attr('length'));if(e=='True'){$(obj).addClass('like_bt_sel');$(obj).attr({'length':length+1});$(obj).html(length+1);}else{$(obj).removeClass('like_bt_sel');$(obj).attr({'length':length-1});$(obj).html(length-1);}});}
events.cmd.send_invite_site=function(obj){var validate=new ValidateForms(obj,'fail_w');var emails=$('input[name="email"]').val().replace(/ /g,'');if(emails){var message=$('textarea[name="message"]').val();emails=emails.split(',');for(key in emails){if(!emails[key].match(/^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$/)){validate.init('email','email_base').val();return;}}
$(obj).removeClass('cmd-send_invite_site');$.blockUI();$.post('/user/send_invite_site',{emails:emails.join(','),message:message},function(e){$(obj).addClass('cmd-send_invite_site');$('input[name="email"]').val('');$.unblockUI();alert('приглашения отправлены');});}}
