function getCityTime(){var date=new Date();var h=date.getHours();if((h>=0&&h<6)||(h>=20))return 2;else if(h>=8&&h<18)return 0;else return 1;} function MoveableTempImage(image){this.image=image;this.step=function(now,fx){$(this.image).css("left",now);} this.timeChanged=function(time){};} function City(container,width,height){this.container=container;this.h=height;this.w=width;this.objects=new Array();this.pages=0;this.x_offset=0;this.page=0;this.lastCityTime=getCityTime();this.bgColorTime=['day','sunset','night'];$(window).resize(jQuery.proxy(function(){if(typeof(this.rightHandle)!="undefined")this.rightHandle.remove();if(typeof(this.leftHandle)!="undefined")this.leftHandle.remove();this.addHandles();},this));this.height=function(height){this.h=height;} this.setSkyBg=function(){$('body').removeClass().addClass(this.bgColorTime[this.lastCityTime]);} this.getCityImage=function(){var key="city-"+this.h+"-"+this.lastCityTime;var img=$.jStorage.get(key,null);if(img==null){jQuery.ajax({url:'back-city.php?t=city&h='+this.h+'&wh='+this.lastCityTime,success:jQuery.proxy(function(result){$.jStorage.set(key,result,{TTL:86400000});},this),async:false,dataType:"text"});img=$.jStorage.get(key,null);} return $('').attr("src","data:image/jpeg;base64,"+img);} this.citify=function(){$(this.container).html("");$("#city").height(this.h);$("#city").width(this.w);this.setImages();this.startDayNightTimer();} this.setImages=function(){this.setSkyBg();var cityImg=this.getCityImage();$(cityImg).load(jQuery.proxy(function(){if(this.cityImg){var mti=new MoveableTempImage(cityImg);this.objects.push(mti);$(this.cityImg).before(cityImg);$(this.cityImg).fadeOut(8000,jQuery.proxy(function(){this.cityImg=cityImg;removeFromArray(this.objects,mti);},this));}else{this.cityImg=cityImg;$(this.container).append(this.cityImg);$(this.cityImg).hide().fadeIn(1000,jQuery.proxy(function(){this.addHandles();this.pages=Math.ceil($(this.cityImg).width()/ $(container).width());},this));this.addObjects();$("#cityLoading").fadeOut(300,function(){$(this).remove();});} $(cityImg).css("left",(this.x_offset*-1)+"px").css("top","0px");},this));} this.startDayNightTimer=function(){setInterval(jQuery.proxy(function(){var time=getCityTime();if(time==this.lastCityTime)return;this.lastCityTime=time;this.setImages();for(var i in this.objects)this.objects[i].timeChanged(time);},this),25000);} this.addHandles=function(){this.leftHandle=new Handle(this.container,$(this.cityImg).height(),jQuery.proxy(this.getCityPosition,this),0,0,"images/city/city-leftarrow.png",40,-20,jQuery.proxy(this.startAnimation,this),jQuery.proxy(this.stopAnimation,this));this.rightHandle=new Handle(this.container,$(this.cityImg).height(),jQuery.proxy(this.getCityPosition,this),$(this.container).width()-40,($(this.getCityImg()).width()-$(this.container).width()),"images/city/city-rightarrow.png",-40,20,jQuery.proxy(this.startAnimation,this),jQuery.proxy(this.stopAnimation,this));this.rightHandle.setHintArrow();this.leftHandle.setHintArrow();$("body").mousemove(jQuery.proxy(function(e){var pos=e.pageY-$("#top").outerHeight(true)-($(this.container).height()-$(this.cityImg).height());this.rightHandle.sentHintArrowPosition(pos);this.leftHandle.sentHintArrowPosition(pos);},this));} this.startAnimation=function(handle){this.cityMotion(handle.max_scroll,handle);} this.stopAnimation=function(handle){handle.animationEndCallback();this.rightHandle.setHintArrow();this.leftHandle.setHintArrow();} this.getCityPosition=function(){return this.x_offset;} this.getCityImg=function(){return this.cityImg;} this.addObjects=function(){this.objects.push(new CityCitizen(this.container,$(this.cityImg).width(),this.h));for(var i in this.objects) this.objects[i].show();} this.cityMotion=function(position,handle){if(position0){this.page--;}else if(this.page');this.height=height;this.container=container;this.top_offset=($(this.container).height()-this.height);this.apfunction=actual_pos_function;this.left_offset=left_offset;this.arrowImageFilename=arrowImageFilename;this.afrom=arrow_animation_from;this.ato=arrow_animation_to;this.max_scroll=max_scroll;this.scallback=start_callback;this.ecallback=end_callback;this.position=0;this.handleArrowAnimation=function(event){$(this.handle).children().stop().remove();var img=$('');$(this.handle).append(img);this.arrow_height=$(img).height();$(img).css("top",this.position+"px").css("left",this.afrom+"px").animate({"left":this.ato+"px","opacity":"0.05"},500,jQuery.proxy(function(){this.handleArrowAnimation(event);},this));};this.afunction=function(){return(((this.max_scroll>0)&&(this.apfunction()this.max_scroll))||((this.max_scroll==0)&&(this.apfunction()!=0)));};$(this.handle).css("left",this.left_offset+"px").css("top",this.top_offset+"px").css("height",this.height+"px");$(this.container).append(this.handle);$(this.handle).click(jQuery.proxy(function(e){if(this.afunction()){this.handleArrowAnimation(e);if(this.scallback!=null)this.scallback(this);}},this));this.remove=function(){$(this.handle).remove();};this.setHintArrow=function(){if(this.afunction()){$(this.handle).children().stop().remove();this.arrowImage=$('');$(this.handle).append(this.arrowImage);$(this.arrowImage).css("opacity",0.2).css("top","-100px");this.arrow_height=$(this.arrowImage).height();}};this.sentHintArrowPosition=function(position){this.position=position-(this.arrow_height / 2);if(this.position<0)this.position=-100;$(this.arrowImage).css("top",this.position+"px");};this.animationEndCallback=function(){$(this.handle).children().stop().remove();this.setHintArrow();};}