/*
 * ie6Layout.js
 * Adapts IE to behave according to standards
 *
 * Author: Zach van Schouwen
 * Date: 01-10-2007
 *
 * Argh! IE6 exhibits a miserable sort of behavior when you have a page
 * laid out exclusively with floats.
 *
 * This function pulls all labels with CSS "clear" set, and adds a meaningless
 * in-flow DIV before them to force IE to flow properly, without compromising
 * our standards-compliant code.
 *
 * Currently, IE7 runs Sundial in "old quirks" mode, so it exhibits the same
 * behavior. If we later update our DOCTYPE, this can change.
 */

function fixIE6Layout() {
	if (navigator.userAgent.toLowerCase().indexOf("msie 6") == -1 &&
	    navigator.userAgent.toLowerCase().indexOf("msie 7") == -1) {
		return;
	}
	var labels = document.getElementsByTagName('label');
	for (var i = 0; i < labels.length; i++) {
		/* currentStyle is proprietary, but we're already in IE hell */
		if (labels[i].currentStyle.clear == 'both' ||
		    labels[i].currentStyle.clear == 'left' ||
		    labels[i].currentStyle.clear == 'right') {
			var emptyDiv = document.createElement('div');
			emptyDiv.style.clear = 'left';
			/* we don't want this showing up in the layout */
			emptyDiv.style.height = '0px';
			emptyDiv.style.lineHeight = '0px';
			labels[i].parentNode.insertBefore(emptyDiv, labels[i]);
		}
	}

	var inputs = document.getElementsByTagName('input');
	for (i = 0; i < inputs.length; i++) {
		if (inputs[i].type == 'checkbox' ||
		    inputs[i].type == 'radio')
			inputs[i].style.border = 'none';
	}
}

addOnload(fixIE6Layout);
