function changeMonth(month, year, val, id, user) {
	month = month + val;
	
	if (month == 13) {
		month = 1;
		year++;
	}
	if (month == 0) {
		month = 12;
		year--;
	}
		
	$.ajax({
		type: "GET",
		url: "/ajax/calendar.php",
		data: 'month=' + month + "&year=" + year + "&id="+ id + "&user=" + user,
		success: function(msg){
			if (msg != "") $('div#calendar_section').html(msg);
		}
	});
}



function hideIcons(obj) {
	if (JQ_addnote || JQ_removenote || JQ_editnote || JQ_hovernote) return;
	
	if ((viewX > obj.offsetLeft()) && (viewX < (obj.offsetLeft() + obj.width()))) {
		if ((viewY > obj.offsetTop()) && (viewY < (obj.offsetTop() + obj.height()))) {
			return;
		}
	}
	
	
	obj.find('div#JQnotes_iconmenu').hide();
}

var timer = "";
$(document).ready(function() {
	$('#blog_sidebar').hide();

	$('a#toggle_sidebar').click(function() {
		$('#blog_sidebar').toggle(400);
		$('#blog_sidebar_show').hide();
		return false;
	});
	
	//$('a[rel*=facebox]').facebox();
	
	//$('table div[@class*=more_icons]').click(function() { $(this).next().toggle(400); });
	
	// initing the notes now
	$('table[@class*=imgContainer]').hover(function(){
		$(this).find('div#JQnotes_iconmenu').show();
		JQnotes_addboxes($(this));
	},function(){
		obj = $(this);
		setTimeout('hideIcons(obj)', 200);
		
		if (JQ_addnote || JQ_removenote || JQ_editnote) return;
		remove = $(this).parents("div.JQnotes_container");

		JQ_timer[remove.attr("id")] = timer.setTimeout(function() {
			if ((viewX > remove.offsetLeft()) && (viewX < (remove.offsetLeft() + remove.width()))) {
				if ((viewY > remove.offsetTop()) && (viewY < (remove.offsetTop() + remove.height()))) {
					return;
				}
			}
			
			remove.find("div.JQnotes_notes").remove();
		}, 300);
	});
	
	$('a#submit_theme_icon').click(function() {
		
		if (confirm($('input#entry_theme').val())) {
		
			$.ajax({
				type: "GET",
				url: "/ajax/theme.php",
				data: 'id=' + $('input#JQnotes_entryID').val(),
				dataType : 'xml',
				success: function(xml){
					if ($("success",xml).text() == 1) {
						$('div#icon_notify_theme_bad').hide();
						$('div#icon_notify_theme').show(400);
					}
					else {
						$('div#icon_notify_theme').hide();
						$('div#icon_notify_theme_bad').show(400);
					}
				}
			});
		}
	});
	
	$('a#click_subscribe').click(function() {
		$.ajax({
			type: "POST",
			url: "/ajax/subscribe.php",
			data: 'username=' + photoblog_username,
			dataType : 'xml',
			success: function(xml){
				if ($("success",xml).text() == 1) $('div#log_done').show(400);
				else $('div#log_error').show(400);
			}
		});
	});
});