jQuery.noConflict();
jQuery(document).ready(function (){
	jQuery(".archive li").bind("click",function(){
		if ( jQuery(this).find("div").is(":visible") ){
			jQuery(this).find("div").hide(300);
		}
		else {
			jQuery(".archive li").find("div:visible").hide();
			jQuery(this).find("div").show(200);
		}
	});
	jQuery(".archive li div span").bind("click",function(){eventLoader(this);});
	jQuery("#prwmth,#nxtmth").bind("click",function(){loadMonth(this);});
	var reg=new RegExp('month=([0-9]{4}-[0-9]{1,2})');
	var month,elem;
	if((month=document.cookie.match(reg))!=null)
		{
		elem=document.getElementById(month[1]);
		eventLoader(elem);
		}
});
function eventLoader(elem){
	jQuery('.archive span').removeClass('specclass');
	jQuery(elem).addClass('specclass');
	var q1=elem.parentNode.parentNode.getElementsByTagName('span')[0];
	jQuery(q1).addClass('specclass');
	document.cookie='month='+elem.id;
	jQuery.post('/ajax/',{'mode':'loadevents','value':elem.id},function(data){
		document.getElementById('events').innerHTML=data;
	});
}
function loadMonth(elem)
	{
	var curdate=jQuery("#crd").html();
	jQuery.post("/ajax/",{"mode":"changemonth","var":elem.id,"curdate":curdate},function(text,status)
		{
		var txt=text.split("*******");
		jQuery("#wrapmth").html(txt[0]);
		jQuery("#wrapcalend").html(txt[1]);
		jQuery("#prwmth,#nxtmth").bind("click",function(){loadMonth(this);});
		});
	}
