function setZoomingIndex(iSize) {
	var objImg = document.getElementById('imgTextZooming');

	if(objImg) {
		// If iSize exists we probably clicked de zooming button if not we come from an 'onload' event.
		if(iSize) {
			if(parseInt(iSize)) {
				if (!(iSize >= 1 && iSize <= 3)) {
					setZoomingIndex(1)
				}
			}
			
			objImg.textZoomingIndex = iSize;					
		}
		else {							
			if (Get_Cookie('HopitalLaval_TextZoomingIndex')) {				
				objImg.textZoomingIndex = parseInt(Get_Cookie('HopitalLaval_TextZoomingIndex'));
			}
			else {
				// No iSize, no cookie then set default text zooming index
				objImg.textZoomingIndex = 1;
			}
		}
		
		Set_Cookie('HopitalLaval_TextZoomingIndex', objImg.textZoomingIndex, 365);
		
		doZooming();
	}
}

function imgTextZooming_click(e) {
	if (e.target || e.srcElement) {
		var textZoomingIndex
		
		if (e.target) {
			textZoomingIndex = this.textZoomingIndex
		}
		else {
			textZoomingIndex = e.srcElement.textZoomingIndex
		}
				
		if (textZoomingIndex) {
			switch(parseInt(textZoomingIndex)) {
				case 1:
					setZoomingIndex(2);
					break;
				case 2:
					setZoomingIndex(3);
					break;
				case 3:
					setZoomingIndex(1);
					break;
				default:
					setZoomingIndex(1);				
			}		
		}
		else {
			setZoomingIndex(1);
		}		
	}
}

function doZooming() {
	var objImg = document.getElementById('imgTextZooming');
	var objMainContainer = document.getElementById('contenu_sections');
	
	if(!objMainContainer) {
		objMainContainer =  document.getElementById('texte_accueil');
	}
	
	if(!objMainContainer) {
		objMainContainer =  document.getElementById('contenu_sections_large');
	}
	
	if (objImg && objMainContainer ) {
		switch(parseInt(objImg.textZoomingIndex)) {
			case 1 :
				objImg.src = 'http://www.hopitallaval.qc.ca/images/accueil/bout_typo1.gif';
				objMainContainer.className = 'textZooming1';
				break;
			case 2 :
				objImg.src = 'http://www.hopitallaval.qc.ca/images/accueil/bout_typo2.gif';
				objMainContainer.className = 'textZooming2';
				break;				
			case 3 :
				objImg.src = 'http://www.hopitallaval.qc.ca/images/accueil/bout_typo3.gif';
				objMainContainer.className = 'textZooming3';
				break;
		}
	}
}
