$(function() {
	$('#ctl00_ContentPlaceHolder1_cbHeader img').each(function() {
		var oImage = this;
		
		var sAlign = $(oImage).css('float');
		if (sAlign != 'left' && sAlign != 'right') {
			sAlign = $(oImage).attr('align');
			if (sAlign != 'left' && sAlign != 'right') {
				return;
			}
		}

		var sUrl = this.src + '.flowtext.xml' + (window.flowtextDebug ? '?' + new Date() : '');

		$.get(sUrl, function (xml, textStatus) {
			if (typeof xml == 'string') {
				if (window.flowtextDebug) alert('XML is returned as string, is the content type for XML files correct on the web server?');
				return;
			}
			var nLeft = $(oImage).offset().left;	
			var nTop = $(oImage).offset().top;	
			$('outlines outline', xml).each(function() {
				$(oImage).before('<div class="flowtext-outline" style="float:' + sAlign + ';clear:' + sAlign + ';width:' + $(this).attr('width') + ';height:' + $(this).attr('height') + ';"></div>');
			});
			$(oImage).css('position', 'absolute');
			$(oImage).css('left', nLeft + 'px');
			$(oImage).css('top', nTop + 'px');
			$(oImage).css('z-index', '-1');
		}, 'xml');
	});
});
