/*
 * Load registered javascript library dependencies
 */
function ftnCaBAdminAddJs(source){
	var head = document.getElementsByTagName('head').item(0);
	var script = document.createElement('script');
	script.setAttribute('type','text/javascript');
	script.setAttribute('src',source);
	head.appendChild(script);
}
if(typeof(ftnGetObjectPosition) == 'undefined') ftnCaBAdminAddJs('/javascript/cab-common-functions.js');

/*
 * Extends the window lights bar to the full window width
 */
function ftnWideWindows(){
	left = document.getElementById('windows-bar-left');
	inner = document.getElementById('windows-bar-inner');
	right = document.getElementById('windows-bar-right');
	
	//If the flash block exists set to a variable
	if(document.getElementById('flash-block')){
		var flash = document.getElementById('flash-block');
	}
	
	// Get dimensions
	pagewidth = document.body.scrollLeft + document.body.clientWidth;
	layoutWidth = (BrowserDetect.browser == 'Explorer' && BrowserDetect.version < 7) ? 1002 : 992; // IE6 does special maths...
	width = Math.floor((pagewidth - layoutWidth)/2);
	
	if(width < 1){
		// Just show centred inner
		
		// Change properties of inner
		inner.style.cssFloat = 'none';
		inner.style.styleFloat = 'none';// IE is not standards compliant
		inner.style.clear = 'both';
		
		// Hide side divs
		left.style.display = 'none';
		right.style.display = 'none';
	}else{
		// Show side divs to extend window lights
		
		// Change properties of inner
		inner.style.cssFloat = 'left';
		inner.style.styleFloat = 'left';// IE is not standards compliant
		inner.style.clear = 'none';
		
		// Set side divs
		left.style.width = width + 'px';
		left.style.display = 'block';
		
		if(flash){
			flash.style.left = width + 'px';
		}
		
		if (width > 5){
			var wrapAdjust = (BrowserDetect.browser == 'Explorer' && BrowserDetect.version < 7) ? 11 : 1;
			right.style.display = 'block';
			right.style.width = width-wrapAdjust + 'px';// Stops wrapping if right scrollbar present
		}else{
			right.style.display = 'none';
		}
	}
}

window.onload = ftnWideWindows;
window.onresize = ftnWideWindows;