var open_div=null;var dlh=null;var pk=null;var st=null;var date=null;$(document).ready(function(){if($.browser.msie){$('#rss_img').attr({'src':'/img/rss/feed-icon-14x14.png','height':'14px','width':'14px'});$(document).pngFix();}
rk=$('#rasp_conteiner');pk=$('div#post_conteiner',rk);st=$("#show_title",rk);$("div.movie_description",$("div#movie_soon")).slideUp();$("div.movie_raspisanie",$('div#rasp_content')).slideUp();$("div.movie_title",$('div#movie_soon')).click(function(){t=$(this);t.siblings("div.movie_title_open").addClass("movie_title").removeClass("movie_title_open");if(t.attr("class")=="movie_title_open")t.removeClass("movie_title_open").addClass("movie_title").next("div.movie_description:visible").slideUp("slow");else t.removeClass("movie_title").addClass("movie_title_open").next("div.movie_description:hidden").slideDown("slow").siblings("div.movie_description:visible").slideUp();});$("div.movie_poster",pk).live("click",function(){open_div=this.id.substring(13);$("#movie_rasp_"+open_div+":visible").slideUp("slow",function(){open_div=null;$("div.movie_poster:visible",pk).fadeTo("fast",1);st.text("");});if(open_div!=null)$("#movie_rasp_"+open_div+":hidden").slideDown("slow").siblings("div.movie_raspisanie:visible").slideUp("slow");t=$(this);t.fadeTo("fast",1).siblings("div.movie_poster:visible").fadeTo("fast",0.5).css({'margin':'0px 3px 6px 0px','border':'1px solid #666'});st.html('&laquo;<a href="/movie/'+this.id.substring(13)+'">'+t.attr("title")+"</a>&raquo;");if(date!=null)window.location='#date/'+date+'/rasp/'+open_div;else window.location='#rasp/'+open_div;currentAnchor=document.location.hash;}).live("mouseover",function(){t=$(this);st.html('&laquo;<a href="/movie/'+this.id.substring(13)+'">'+t.attr("title")+"</a>&raquo;");if(open_div!=null&&open_div!=this.id.substring(13)&&$('#movie_poster_'+open_div,pk).length!=0)t.fadeTo("fast",0.75);else if(open_div!=null&&$('#movie_poster_'+open_div,pk).length==0)open_div=null;if($.browser.msie)t.css({'border':'2px solid #BA291A','margin':'-1px 3px 7px 0px'});else t.css({'border':'2px solid #BA291A','margin':'-1px 2px 5px -1px'});}).live("mouseout",function(){t=$(this);if($("#movie_rasp_"+this.id.substring(13)).css("display")!="block"){st.text("");t.css({'border':'1px solid #666','margin':'0px 3px 6px 0px'});if(open_div!=null&&open_div!=this.id.substring(13))t.fadeTo("fast",0.5);}
if(open_div!=null&&$('#movie_poster_'+open_div,pk).length!=0)st.html('&laquo;<a href="/movie/'+open_div+'">'+$('#movie_poster_'+open_div,pk).attr("title")+"</a>&raquo;");else if(open_div!=null&&$('#movie_poster_'+open_div,pk).length==0)open_div=null;});$('div.kinomir_info',$('div#kinomir_news')).hover(function(){t=this;$('span.km_in',this).css({'border-bottom':'#C80A24 1px solid','color':'#C80A24'});ntm=setTimeout(function(){$('#news_short_text_id_'+t.id.substring(8)).html(' '+$('#news_short_text_id_'+t.id.substring(8)).attr("title"));},750);},function(){$('span#news_short_text_id_'+this.id.substring(8)).html('...');if(ntm){clearTimeout(ntm);}
$('span.km_in',this).css({'border-bottom':'none','color':'black'});}).click(function(){document.location.href='/news/'+this.id.substring(8);});$('.d3d',$('div#rasp_content')).live('mouseover',function(){if($(this).attr('title'))$(this).attr({'title':$(this).attr('title')+', в 3D!'});$(this).css('background-color','#eee');}).live('mouseout',function(){$(this).css('background-color','#fff');if($(this).attr('title'))$(this).attr({'title':$(this).attr('title').substring(0,($(this).attr('title').length-7))});});$('#rss_img').hover(function(){$(this).attr({'src':'/img/rss/'+Math.round(50*Math.random())+'.png'});},function(){});$('span#date_select',rk).live("mouseover",function(){if(dlh){clearTimeout(dlh);}
dl=$("#date_list");if(dl.length==0){ds_pos=$('span#date_select').findPos();ds_pos.y=ds_pos.y+21;$(document.body).append($('<div id="date_list" style="position: absolute; z-index: 500; cursor: pointer; left: '+ds_pos.x+'px; top: '+ds_pos.y+'px; background-color: white;"><div class="header" style="margin:5px 0px 0px 0px">Завтра в кино</div><div class="header" style="margin:5px 0px 0px 0px">Послезавтра...</div></div>'));dl=$("#date_list");dl.empty().load('/ajax/rd',null,function(){$('div.cd').click(function(){dl.hide();pos=$('div.holygrail').findPos();pos.height=pos.height+38;$(document.body).append($('<div id="gr_lay" style="position: absolute; z-index: 1000; top: 0px; left: 0px; width: '+pos.width+'px; height: '+pos.height+'px; background: #cccccc url(\'/img/login_processbar.gif\') no-repeat 50% 350px;"></div>').animate({opacity:0},0).animate({opacity:0.9},1500));date=this.id.substring(1,3)+'_'+this.id.substring(4,6)+'_'+this.id.substring(7,12);$.get("/ajax/cd",{year:this.id.substring(7,12),monthe:this.id.substring(1,3),day:this.id.substring(4,6)},function(data){rk.empty();$(data).appendTo(rk);st=$("#show_title",rk);pk=$('div#post_conteiner',rk);if(open_div!=null&&$("#movie_poster_"+open_div,pk).length==1){if($.browser.msie)$("#movie_poster_"+open_div,pk).click().css({'border':'2px solid #BA291A','margin':'-1px 3px 7px 0px'});else $("#movie_poster_"+open_div,pk).click().css({'border':'2px solid #BA291A','margin':'-1px 2px 5px -1px'});}else{open_div=null;window.location='#date/'+date;}
currentAnchor=document.location.hash;if($.browser.msie){$(document).pngFix();}
$('#logo').attr({onclick:"location.href='/'"}).css({'cursor':'pointer'}).click(function(){window.location='/';});$('#gr_lay').remove();});});});dl.hover(function(){if(dlh){clearTimeout(dlh);}},function(){dlh=setTimeout(function(){dl.animate({opacity:0},1000,null,function(){dl.hide();})},500);});}else{dl.show();dl.animate({opacity:100},1000);}}).live("mouseout",function(){dlh=setTimeout(function(){dl.animate({opacity:0},1000,null,function(){dl.hide();})},500);});$('#vcard > .fn',$('#footer')).css({'border-bottom':'1px dashed','cursor':'pointer'});$('#vcard',$('#footer')).click(function(){$('.adr, .tel, .email',$(this)).slideDown("slow",function(){window.scrollBy(0,50);});$('.fn',this).css({'border-bottom':'none'});}).hover(function(){},function(){$('.adr, .tel, .email',$(this)).slideUp("slow");$('.fn',this).css({'border-bottom':'1px dashed'});});setInterval("an_check()",300);});var currentAnchor=null;var cur_d=null;function an_check(){if(document.location.hash!=''&&currentAnchor!=document.location.hash){var an=document.location.hash.substring(1);if(an.length==1){ktr(an,$('#o'+an));}else{var splits=an.split('/');for(i=0,len=splits.length;i<len;i+=2){if(splits[i]=='date'){date=splits[i+1];}
if(splits[i]=='rasp'){open_div=splits[i+1];}}
if(date!=null&&cur_d!=date){$('#logo').attr({onclick:"location.href='/'"}).css({'cursor':'pointer'}).click(function(){window.location='/';});dat=date.split('_');pos=$('div.holygrail').findPos();pos.height=pos.height+38;$(document.body).append($('<div id="gr_lay" style="position: absolute; z-index: 1000; top: 0px; left: 0px; width: '+pos.width+'px; height: '+pos.height+'px; background: #cccccc url(\'/img/login_processbar.gif\') no-repeat 50% 350px;"></div>').animate({opacity:0},0).animate({opacity:0.9},1500));$.get("/ajax/cd",{year:dat[2],monthe:dat[0],day:dat[1]},function(data){rk.empty();$(data).appendTo(rk);st=$("#show_title",rk);pk=$('div#post_conteiner',rk);if(open_div!=null&&$("#movie_poster_"+open_div,pk).length==1){if($.browser.msie)$("#movie_poster_"+open_div,pk).click().css({'border':'2px solid #BA291A','margin':'-1px 3px 7px 0px'});else $("#movie_poster_"+open_div,pk).click().css({'border':'2px solid #BA291A','margin':'-1px 2px 5px -1px'});}else if(open_div!=null&&$("#movie_poster_"+open_div,pk).length==0){window.location='#date/'+date;open_div=null;}
if($.browser.msie){$(document).pngFix();}
$('#gr_lay').remove();});cur_d=date;}else if(date==null||cur_d!=date){if(open_div!=null&&$("#movie_poster_"+open_div,pk).length==1){$("#movie_poster_"+open_div).click();}
else if(open_div!=null&&$("#movie_poster_"+open_div).length==0){open_div=null;window.location='';}}}
currentAnchor=document.location.hash;}}
var s_id=null;function show_all_actors(B,A){if(s_id==null){$(B).html(A);s_id=B;timeout=setTimeout(show_all_actors,10000);}else{$(s_id).html("...");s_id=null;if(timeout){clearTimeout(timeout)}}}
function login_form(){if($("#login_form").length==0){$(document.body).append($('<div id="login_form"><div id="x_button" onClick="login_form();"></div><div style="margin: 20px 60px 0px 60px;"><form id="UserLoginForm" method="post" action="/users/login" autocomplete="off"><fieldset style="display:none;"><input type="hidden" name="_method" value="post" /></fieldset><div class="input text" style="margin-bottom: 5px;"><label for="UserLogin">Имя:</label></div><div><input name="data[User][login]" size="28" type="text" maxlength="25" value="" id="UserLogin" /></div><div class="input password" style="margin: 10px 0px 5px 0px;"><label for="UserPassword">Пароль:</label></div><div><input size="28" type="password" name="data[User][password]" value="" id="UserPassword" /></div><div style="margin: 20px auto 0px auto; width: 61px;" class="submit"><input id="submit" style="border: none;" name="submit" type="image" lang="ru" value="submit" src="/img/inter.png" alt="Вход" /></div><input type="hidden" name="data[User][remember_me]" value="1" id="UserRememberMe" /></form></div><div style="margin-right: 25px; font-size: 0.7em; float: right;"><a href="/users/register">Зарегистрироваться...</a></div></div>'));if(ismobile==1)$('#login_form').show();else $('#login_form').center().show();$('input#UserLogin').focus();pos=$('div.holygrail').findPos();var options={url:'/users/login',success:function(data,statusText){window.location.reload();},error:function(XMLHttpRequest,textStatus,errorThrown){alert("Неверное имя пользователя или пароль...");$('#login_form').remove();$('div#gr_lay').remove();},beforeSubmit:function(formData,jqForm,options){$('#login_form').animate({opacity:0},1000);pos.height=pos.height+38;$(document.body).append($('<div id="gr_lay" style="position: absolute; z-index: 1000; top: 0px; left: 0px; width: '+pos.width+'px; height: '+pos.height+'px; background: #cccccc url(\'/img/login_processbar.gif\') no-repeat 50% 350px;"></div>').animate({opacity:0},0).animate({opacity:0.9},1500));return true;}};$('form#UserLoginForm').ajaxForm(options);var check_options={url:"/users/user_validate",type:'POST',dataType:null,success:function(data,statusText){if(data=='ok')$('form#UserLoginForm input#UserLogin').css('background-color','#339933');else{$('form#UserLoginForm input#submit').attr("disabled","disabled");alert('Пользователь не найден, вам необходимо зарегистрироваться!');}},error:function(XMLHttpRequest,textStatus,errorThrown){alert('Пользователь не найден, вам необходимо зарегистрироваться!');}};$('form#UserLoginForm input#UserLogin').blur(function(){if(this.value!='')$('form#UserLoginForm').ajaxSubmit(check_options);return false;});}else{$('#login_form').remove();}}
function reg_form(){if($("#login_form").length!=0)$('#login_form').remove();if($('#reg_form').length==0){$(document.body).append($("<div id=\"reg_form\" style=\"position: absolute; z-index: 200; top: 150px; left: 350px; width: 340px; height: 198px; background: url('/img/bg_inter.png');\"><div id=\"x_button\" style=\"position: relative; float: right; clear: both; z-index: 201; top: 0px; left: 0px; width: 12px; height: 12px; margin: 10px 10px 0px 0px; background: url('/img/x.png') no-repeat; cursor: pointer;\" onClick=\"reg_form();\"></div><div id=\"reg_user_inner\" style=\"margin: 50px 60px 0px 60px;\"><form name=\"reg\" method=\"post\" action=\"/login/\" onSubmitt=\"reg_user(this.email.value); return false;\"><div style=\"font-size: 1.1em; color: #666666; margin-bottom: 5px;\">E-mail:</div><div><input style=\"font-weight: bold;\" name=\"email\" type=\"text\"></div><div style=\"margin: 20px auto; width: 72px;\"><input style=\"border: none;\" name=\"submit\" type=\"image\" lang=\"ru\" value=\"submit\" src=\"/img/inter.png\" alt=\"Вход\"></div></form></div></div>"));if($('#login_form').length!=0){$('form#UserLoginForm input#UserLogin').value();$('#login_form').remove();}}
else $("#reg_form").remove();}
var Alert={show:function(title,text,class_name){if(!$('#ajax_alert').attr('id')){$('<div id="ajax_alert"></div>').appendTo(document.body);}
$('<div class="item '+class_name+'"><h2>'+title+'</h2>'+text+'</div>')
.prependTo($('#ajax_alert'))
.fadeIn('slow')
.animate({opacity:1.0},4500)
.fadeOut('slow',function(){$(this).remove();});}}
function ktr(kt,di){rc=$('div#rasp_content',rk);if(rc.length==1){sk=$(di);wh=$('span#where_show');if(kt=='e'){$("div.ktid_506:hidden",rc).show();if($("div.ktid_2:visible,div.ktid_4:visible",rc).length>0){wh.html("кинотеатре &laquo;Европа&raquo;");$("div.ktid_2:visible,div.ktid_4:visible",rc).hide();sk.css({'color':'#000','text-decoration':'none'}).siblings().css({'color':'#888','text-decoration':'line-through'});}else{wh.text("кино");$("div.ktid_2:hidden,div.ktid_4:hidden",rc).show();sk.css({'color':'#000','text-decoration':'none'}).siblings().css({'color':'#000','text-decoration':'none'});}}else if(kt=='r'){$("div.ktid_4:hidden",rc).show();if($("div.ktid_2:visible,div.ktid_506:visible",rc).length>0){wh.html("кинотеатре &laquo;Родина&raquo;");$("div.ktid_2:visible,div.ktid_506:visible",rc).hide();sk.css({'color':'#000','text-decoration':'none'}).siblings().css({'color':'#888','text-decoration':'line-through'});}else{wh.text("кино");$("div.ktid_2:hidden,div.ktid_506:hidden",rc).show();sk.css({'color':'#000','text-decoration':'none'}).siblings().css({'color':'#000','text-decoration':'none'});}}else if(kt=='m'){$("div.ktid_2:hidden",rc).show();if($("div.ktid_506:visible,div.ktid_4:visible",rc).length>0){wh.html("кинотеатре &laquo;Мир&raquo;");$("div.ktid_506:visible,div.ktid_4:visible",rc).hide();sk.css({'color':'#000','text-decoration':'none'}).siblings().css({'color':'#888','text-decoration':'line-through'});}else{wh.text("кино");$("div.ktid_506:hidden,div.ktid_4:hidden",rc).show();sk.css({'color':'#000','text-decoration':'none'}).siblings().css({'color':'#000','text-decoration':'none'});}}
$("div.movie_raspisanie",rc).each(function(){hide_div=this.id.substring(11);if($('div.kt_rasp:visible',this).length<2){$("#movie_poster_"+hide_div+":visible",pk).hide("slow").css({'margin':'0px 3px 6px 0px','border':'1px solid #666'});if(open_div!=null&&hide_div==open_div){open_div=null;$("div.movie_poster",pk).fadeTo("fast",1);st.text("");}
$("#movie_rasp_"+hide_div+":visible",rc).slideUp("slow");}else{$("#movie_poster_"+hide_div+":hidden",pk).show("slow");}});}else{location.replace('/#'+kt);}}
function kktr(kt,d){var id=null;rc=$('div#rasp_content',rk);$(".movie_raspisanie",rc).each(function(index){jQuery.removeData(this,'v');});wh=$('span#where_show');if((typeof($(d).data('ot'))=='undefined'||$(d).data('ot')==null)||$(d).data('ot')==0){if(kt=='e'){kt=506;wh.html("кинотеатре &laquo;Европа&raquo;");}
if(kt=='r'){kt=4;wh.html("кинотеатре &laquo;Родина&raquo;");}
if(kt=='m'){kt=2;wh.html("кинотеатре &laquo;Мир&raquo;");}
$(d).css({'color':'#000','text-decoration':'none'}).data('ot',1).siblings().css({'color':'#888','text-decoration':'line-through'});$("div.ktid_"+kt,rc).show().siblings().hide().parent().data('v',1);$(".kt_rasp",rc).each(function(index){jQuery.removeData(this,'ot');});$(d).data('ot',1);}else{$(d).css({'color':'#000','text-decoration':'none'}).data('ot',0).siblings().css({'color':'#000','text-decoration':'none'});$(".kt_rasp").show().parent().data('v',1);wh.text("кино");$(d).data('ot',0);}
$(".movie_raspisanie",rc).each(function(index){hide_div=this.id.substring(11);if($(this).data('v')==0||(typeof($(this).data('v'))=='undefined'||$(this).data('v')==null)){$("#movie_poster_"+hide_div+":visible",pk).hide("slow").css({'margin':'0px 3px 6px 0px','border':'1px solid #666'});$("#movie_rasp_"+hide_div+":visible",rc).slideUp("slow");if(open_div!=null&&hide_div==open_div){console.log('inif: '+hide_div+' '+open_div);open_div=null;$("div.movie_poster",pk).fadeTo("fast",1);st.text("");}}else{$("#movie_poster_"+hide_div+":hidden",pk).show("slow");if(open_div==null)$("div.movie_poster:visible",pk).fadeTo("fast",1);}});}
jQuery.fn.extend({findPos:function(){obj=$(this).get(0);var D=obj.offsetLeft||0;var C=obj.offsetTop||0;var A=obj.offsetWidth||0;var B=obj.offsetHeight||0;while(obj=obj.offsetParent){D+=obj.offsetLeft;C+=obj.offsetTop}
return{x:D,y:C,height:B,width:A}}});var l=0;jQuery.fn.center=function(){w=this;w.css("position","absolute");w.css("top",($(window).height()-this.height())/2+$(window).scrollTop()+"px");w.css("left",($(window).width()-this.width())/2+$(window).scrollLeft()+"px");if(l==0){l=1;$(window).scroll(function(){w.center();});}
return w;}
