// ----------------------------------------------------------------------------
// Application:		DEKALB
// Author:			CMETIFI
//
// Role				JavaScript functions to round corners of Centered pictures
// Modification
// Author           Date          Comments
// ----------------------------------------------------------------------------
// CMETIFI			04/07/10	Creation
// ----------------------------------------------------------------------------


	// Return the image width
	function getImageWidth(obj){
		if (obj.hasChildNodes()){
			var child = obj.firstChild;
			if(child.nodeName == 'IMG'){
				return child.offsetWidth;
			}							
		}
		return 0;					
	}

	
	// This function allows to center a rounded picture
	// width of the DIV that contains the picture is set to the picture width
	function setImageDivWidth() {
		var picwidth = [];
		var containerDiv = document.getElementById('main_center');

		if(containerDiv != null){
			// get all 'div' element from the main content
			var dvs = containerDiv.getElementsByTagName('div');
			
			for(var c=0; c<dvs.length; c++) {
				// find the right 'wrapper' div which contains the image (parent is 'article center_pict')
				// then find the picture size
				// then set the size to the wrapper parent (wrapper is left floated)
				if (dvs[c].className.indexOf('wrapper') != -1) {
						
					if(dvs[c].parentNode.className.indexOf('center_pict') != -1){
						picwidth[c] = getImageWidth(dvs[c]);							
						dvs[c].parentNode.style.width = picwidth[c]+'px';							
					}
				}
			}
		}
	} 

	window.onload=function() {
		setImageDivWidth();
	} 

