function resizeImg(){
	jQuery("[name=img]").each(function (){
		if (jQuery(this).width() > 135) {
			jQuery(this).attr("width", "135");
		}
		
		if (jQuery(this).height() > 180) {
			jQuery(this).attr("height", "180");
		}
	});
	jQuery('#colCentre').pager('ul'); 
}
    
function myChangeMonth(url) 
{
	var args = ['day', 'iddoc'];
	var newUrl = workingUrl = url;

	var startIdx = workingUrl.indexOf('page=homepage.jsp');
	if(startIdx > 0)
	{		
		for(i = 0; i < args.length; i++)
		{
			startIdx = workingUrl.indexOf(args[i]);
		
			if(startIdx > 0)
			{
				if(workingUrl[startIdx - 1] == '&')
					startIdx--;
				
				var endIdx = workingUrl.indexOf('&', startIdx + 1);
				newUrl = workingUrl.substring(0, startIdx);

				if(endIdx > 0)
					newUrl = newUrl + workingUrl.substring(endIdx, workingUrl.length);
			}			
			workingUrl = newUrl;
		}
	}
	// Fix pour IE(6) qui ne prend pas le window.location...
	setTimeout(function(){window.location.href = newUrl;}, 0);
}

function changeMonthAjax(urlAjax){
	showOverlayLoading('calendarContainer');
	
	var currentUrl = window.location.href;
	var currentIddoc = '';
	var startIdx = currentUrl.indexOf('iddoc=');
	if(startIdx > 0){
		var endIdx = currentUrl.indexOf('&', startIdx);
		if(endIdx < 0){
			endIdx = currentUrl.length;
		}
		currentIddoc = currentUrl.substring(startIdx + 6, endIdx);
	}
	
	jQuery.ajax({ 
		url: urlAjax + '&iddoc=' + currentIddoc,
		success: function(calendarHtml){
        	jQuery('#calendarContainer').html(calendarHtml);
        	hideOverlayLoading();
    	}
	});
}

function showOverlayLoading(divId) {
	var div = jQuery('#' + divId);
	
	var overlayDiv = jQuery("<div>").attr('id','overlay-loading');
	overlayDiv.css({
		'width': '100%',
		'height': '100%',
		'position': 'absolute',
		//'backgroundColor': '#000000',
		'top': 0,
		'left': 0
		//'opacity': 0.75
    });

	var overlayHtml = '<div class="loading"/>';
	overlayDiv.html(overlayHtml);

	div.append(overlayDiv);
}

function hideOverlayLoading() {
	jQuery('#overlay-loading').remove();
}
