function appendCalendarFunctions(){
    $(".events1").click(function(e){
		    var id="sweeyaCalendarPopup";
            var el=document.getElementById(id)
		    var mouseX=e.pageX;
		    var mouseY=e.pageY;
		    var selfId=this.id + "";
		    var contentId=selfId.replace('day','events')
		    var content=document.getElementById(contentId)
		
		    //display fuckin popup
		    el.style.display="block";
		    el.style.top=(mouseY+10)+"px";
		    el.style.left=(mouseX-375)+"px"
		
		    //fill freakin content
		    //sweeyaCalendarPupupContent
		    document.getElementById("sweeyaCalendarPupupContent").innerHTML=content.innerHTML
		
       
    });
    $("#sweeyaCalendarPopupClose").click(function(){
		    el=document.getElementById("sweeyaCalendarPopup");
		    el.style.display="none";
    });

    $("#next_month_link").click(function(){
            month=$("#next_month").val()
            year=$("#next_year").val()
            $("#next_month_link").html("<img src='/images/loading.gif'>");
            $.post("/frontend/other_calendar",{month: month, year: year},
			       function(data){
	
				    if(2==3){
						    alert(data);
				    }else{
        
					    $("#fronted_calendar").html(data);
                        appendCalendarFunctions();


				    }
		    });

    });



    $("#prev_month_link").click(function(){
            month=$("#prev_month").val()
            year=$("#prev_year").val()
            $("#prev_month_link").html("<img src='/images/loading.gif'>");
            $.post("/frontend/other_calendar",{month: month, year: year},
			       function(data){
	
				    if(2==3){
						    alert(data);
				    }else{
        
					    $("#fronted_calendar").html(data);
                        appendCalendarFunctions();


				    }
		    });

    });    

}
appendCalendarFunctions();
function showPopup(id){
	var popup=$('#'+id);
	popup.show("blind");
	
}
