function DateData(){this.photo="";this.fromtime="";this.duration="";this.title="";this.id="";this.description="";this.type_id="";this.lat="";this.lng="";this.zoomlevelmin="";this.zoomlevelmax="";this.parentplace_id="";this.parentname=""}function EventsObject(){this.urlHasHash=false;this.currentMonth=0;this.currentYear=0;this.currentDate=0;this.currentSelectedDate=0;this.currentImageCounter=0;this.visibleImageCounter=0;this.months=[["January","February","March","April","May","June","July","August","September","October","November","December"],["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]];this.days=[["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]];this.FilterState=[0,1,2,3,4,5];this.EventDateData=new Object();this.timeout=0}var eo=new Object();function CreateEventDateDataArray(b){eo.EventDateData=new Array(b);for(var a=0;a<b;a++){eo.EventDateData[a]=new DateData()}}function LoadEventDateData(a){$.each(a,function(b,c){if(findInFilter(c.type_id)){if(c.photo==null){eo.EventDateData[b].photo="/static/images/image_unavailable.gif"}else{eo.EventDateData[b].photo=global.SERVER+"/"+c.photo}eo.EventDateData[b].fromtime=c.fromtime;eo.EventDateData[b].duration=c.duration;eo.EventDateData[b].title=c.title;eo.EventDateData[b].id=c.id;eo.EventDateData[b].description=c.description;eo.EventDateData[b].type_id=c.type_id;eo.EventDateData[b].lat=c.lat;eo.EventDateData[b].lng=c.lng;eo.EventDateData[b].zoomlevelmin=c.zoomlevelmin;eo.EventDateData[b].zoomlevelmax=c.zoomlevelmax;eo.EventDateData[b].parentplace_id=c.parentplace_id;eo.EventDateData[b].parentname=c.parentname}})}function add_favorite_to_favlist(a,f,c){var b=$("#event_title").text();var e=$("#image_wrapper").children("img").attr("src");if(eo.EventDateData[eo.currentImageCounter-1].photo!="/static/images/image_unavailable.gif"){e=ParsePhotoURL(e,"s")}else{e=""}var d=$(a).next("a").attr("href");var f=f;var c=c;data=new Object();data.id=f;data.link=d;data.title=b;data.type=c;data.photo=e;show_favorites(data);UpdateFavoritesNumber();$("#favorites_dd").trigger("click");$("#favorites #myfavs").children("div").removeClass("hoverclass");$("#myfav-"+f).addClass("hoverclass");$("#myfavs").scrollTop(0);return false}function CheckFavorites(a){$favitems=$("#favorites #myfavs").children("div");found=false;$.each($favitems,function(b,c){if($(this).find(".other_info").children("div").text()==a){found=true}});return found}function LastDayOfMonth(a,b){return(new Date((new Date(a,b+1,1))-1)).getDate()}function getactuallength(a){var c=0;for(var b=0;b<a.length;b++){if(a[b].id!=""){c++}}return c}var RenderEvents=function(){if(CheckFavorites(eo.EventDateData[eo.currentImageCounter-1].title)){$("#bottom_links_events").find(".addfavorites").addClass("favorite").unbind("click").bind("click",AddFavoriteAjax)}else{form="<div class='favorite_form' style='display:none;'><form method='post' action='/favorite/add/' id='favoriteform-"+eo.EventDateData[eo.currentImageCounter-1].id+"'><input type='hidden' value='24' name='ctype_id'/><input type='hidden' value='"+eo.EventDateData[eo.currentImageCounter-1].id+"' name='obj_id'/><input type='hidden' value='"+document.URL+"' name='next'/><input type='submit' value='Add To Favorites'/></form></div>";$("#bottom_links_events").find("div.favorite_form").remove();$("#bottom_links_events").prepend(form).find(".addfavorites").removeClass("favorite").unbind("click").bind("click",AddFavoriteAjax)}while(true){if(eo.EventDateData[eo.currentImageCounter-1].id!=""){break}else{eo.currentImageCounter++}}$("#image_wrapper").removeClass().addClass("event-"+eo.currentImageCounter).empty();$("#event_title").empty().append(eo.EventDateData[eo.currentImageCounter-1].title);$("#bottom_links_events").find(".readmore").attr("href","/event/id/"+eo.EventDateData[eo.currentImageCounter-1].id);$("#image_info").empty().append("<label>"+eo.visibleImageCounter+" of "+getactuallength(eo.EventDateData)+"</label>");var a;if(eo.EventDateData[eo.currentImageCounter-1].photo!="/static/images/image_unavailable.gif"){a=ParsePhotoURL(eo.EventDateData[eo.currentImageCounter-1].photo,"m")}else{a="/static/images/events/"+ObjectTypes["event-"+eo.EventDateData[eo.currentImageCounter-1].type_id].replace(/ /g,"_")+"_Large.jpg"}LoadImage(a);$("#event_description").empty().append("<div>"+eo.EventDateData[eo.currentImageCounter-1].description+"</div>");if(eo.visibleImageCounter==1){$("#image_prev_link").addClass("deactivated")}else{$("#image_prev_link").removeClass("deactivated")}if(eo.visibleImageCounter==getactuallength(eo.EventDateData)){$("#image_next_link").addClass("deactivated")}else{$("#image_next_link").removeClass("deactivated")}$("#display_picture_container").show()};function FindEvent(a){for(var b=0;b<eo.EventDateData.length;b++){if(a==eo.EventDateData[b].id){eo.currentImageCounter=(b+1);eo.visibleImageCounter=eo.currentImageCounter}}}function LoadImage(b){var a=new Image();$(a).load(function(){$(this).hide();checkwidth=(a.width>a.height)?false:true;image_big=(a.width>eo.maxWidth||a.height>eo.maxHeight)?true:false;$("#image_wrapper").removeClass("loading1").append(this);if(image_big){if(checkwidth){$("#image_wrapper").children("img").css({width:eo.maxWidth+"px",height:Math.ceil((a.height/a.width)*eo.maxWidth)+"px"});$("#image_wrapper").css({width:eo.maxWidth+"px",height:Math.ceil((a.height/a.width)*eo.maxWidth)+"px"})}else{$("#image_wrapper").children("img").css({height:eo.maxHeight+"px",width:Math.ceil((a.width/a.height)*eo.maxHeight)+"px"});$("#image_wrapper").css({height:eo.maxHeight+"px",width:Math.ceil((a.width/a.height)*eo.maxHeight)+"px"})}}else{if(checkwidth){$("#image_wrapper").children("img").css({width:a.width+"px",height:Math.ceil((a.height/a.width)*a.width)+"px"});$("#image_wrapper").css({width:a.width+"px",height:Math.ceil((a.height/a.width)*a.width)+"px"})}else{$("#image_wrapper").children("img").css({height:a.height+"px",width:Math.ceil((a.width/a.height)*a.height)+"px"});$("#image_wrapper").css({height:a.height+"px",width:Math.ceil((a.width/a.height)*a.height)+"px"})}}$(this).fadeIn()}).error(function(){}).attr({src:b})}var RenderEventImages=function(data){data=eval(data);eo.EventDateData=null;CreateEventDateDataArray(data.length);LoadEventDateData(data);$("#image_next_link").removeClass("deactivated");$("#image_prev_link").addClass("deactivated");if(eo.urlHasHash){var locationhash=location.hash;locationhash=locationhash.split("#");FindEvent(parseInt(splitString(locationhash[2])))}RenderEvents()};var ThumbsOnClickEvent=function(){$("#months").addClass("deactivated");eo.currentSelectedDate=splitString($(this).parent().attr("id"));if(!eo.urlHasHash){eo.currentImageCounter=1;eo.visibleImageCounter=1}$("<label>"+eo.currentSelectedDate+" "+eo.months[0][eo.currentMonth-1]+" "+eo.currentYear+"</label>").appendTo("#picture_date");$.ajax({url:"/ajax/event/date/"+eo.currentYear+"/"+eo.currentMonth+"/"+eo.currentSelectedDate+"/",type:"get",datatype:"json",success:RenderEventImages});return false};function findInFilter(b){var a=false;if(eo.FilterState[0]==0){return true}$.each(eo.FilterState,function(c,d){if(d==b){a=true;return a}});return a}function bindEvents(){eo=new EventsObject();var todaysdate=new Date();eo.currentYear=todaysdate.getFullYear();eo.currentMonth=todaysdate.getMonth()+1;eo.currentDate=1;$("#months").find("a").bind("click",function(){if(!$(this).parent().parent().hasClass("deactivated")){eo=null;eo=new EventsObject();eo.currentYear=parseInt(splitString($(this).parent().attr("class")));eo.currentMonth=parseInt(splitString($(this).attr("class")),10);eo.currentDate=1;$.ajax({url:"/ajax/event/bigcalendar/"+eo.currentYear+"/"+eo.currentMonth+"/",type:"get",datatype:"json",success:function(data){data=eval("["+data+"]")[0];$(".year-"+eo.currentYear).find(".month-"+eo.currentMonth).empty().append(eo.months[1][eo.currentMonth-1]+"("+data.count+")");$("#months").find("a").removeClass("selected_month");$(".year-"+eo.currentYear).find(".month-"+eo.currentMonth).addClass("selected_month");$("#calendar").find(".month_name").empty().append(eo.months[0][eo.currentMonth-1]+" "+eo.currentYear);$("#calendar").find(".calender_dates").empty().append(data.calendar)}});index=$("#months").children().index($(this).parent());animateto=index*59-4*59-81;if(animateto<=0){$("#months").animate({marginLeft:"0px"},"normal")}else{if(animateto>729){animateto=729}$("#months").animate({marginLeft:"-"+animateto+"px"},"normal")}}return false});$(".loaded").find("a").bind("click",ThumbsOnClickEvent);$("#display_picture_container").css({height:$("#roundborder").height()-21,width:$("#roundborder").width()});$("#close_link").bind("click",function(e){eo.urlHasHash=false;$("#display_picture_container").fadeOut();$("#picture_date").empty();$("#months").removeClass("deactivated");$("#bigimage_container > img").remove()});$("#close_link > img").hover(function(){$(this).attr("src","/static/images/close_button_red.gif")},function(){$(this).attr("src","/static/images/close_button.gif")});$("#image_prev_link").click(function(){if(!$(this).hasClass("deactivated")){eo.currentImageCounter--;eo.visibleImageCounter--;$("#image_next_link").removeClass("deactivated");$("#bigimage_container").children("img").hide();RenderEvents();return false}else{return false}});$("#image_next_link").click(function(){if(!$(this).hasClass("deactivated")){eo.currentImageCounter++;eo.visibleImageCounter++;$("#image_prev_link").removeClass("deactivated");$("#bigimage_container").children("img").hide();RenderEvents();return false}else{return false}});if(location.hash){if(location.hash!="#"){var locationhash=location.hash;locationhash=locationhash.split("#");var urldate=locationhash[1];eo.currentMonth=parseInt(urldate.split("-")[0],10);eo.currentDate=parseInt(urldate.split("-")[1],10);eo.currentYear=parseInt(urldate.split("-")[2],10);eo.urlHasHash=true}}$.get(global.SERVER+"/ajax/event/getnexteventcount/"+eo.currentMonth+"/",function(data){data=eval(data);$.each(data,function(index,element){$(".year-"+element.year).find(".month-"+element.month).empty().append(eo.months[1][element.month-1]+"("+element.count+")")})});$("#scroll_left").bind("mousedown",function(){eo.timeout=setInterval("animate_months_left()",100)});$("#scroll_left").bind("mouseup",function(){clearInterval(eo.timeout)});$("#scroll_right").bind("mousedown",function(){eo.timeout=setInterval("animate_months_right()",100)});$("#scroll_right").bind("mouseup",function(){clearInterval(eo.timeout)})}function animate_months_left(){marginleft=parseInt($("#months").css("margin-left"));animateby=marginleft+20;animateby=(animateby>0)?0:animateby;if(marginleft<0){$("#months").animate({marginLeft:animateby},90)}else{clearInterval(eo.timeout)}}function animate_months_right(){marginleft=parseInt($("#months").css("margin-left"));animateby=marginleft-20;animateby=(animateby<-741)?-741:animateby;if(marginleft<0){$("#months").animate({marginLeft:animateby},90)}else{clearInterval(eo.timeout)}}$(document).ready(function(){bindEvents()});