function syncMain() {
	function sync1() {
		// autosection appears only in the properties
		p = document.getElementById('autoSection');
		p2 = document.getElementById('autoSectionMeasure');
		if (p) {
			perfectHeight = (4 + (10*Math.ceil((p2.offsetHeight -4 )/ 10)));
			if ((perfectHeight - 14) % 40 == 0) { // same color dot
				perfectHeight += 10;
			}
			if (p.offsetHeight != perfectHeight) {
				p.style.height = perfectHeight +'px';
			}
		}
		sync2();
	}
	
	function sync2() {
		var main = document.getElementById('main');
		var menu = document.getElementById('menu');
		var content = document.getElementById('content');
		perfectHeight = 10*Math.ceil(Math.max(menu.offsetHeight, content.offsetHeight+21) / 10);
		if (perfectHeight % 40 == 0) { // same color dot
			perfectHeight += 10;
		}
		if (perfectHeight != document.getElementById('main').offsetHeight) {
			main.style.height = perfectHeight +'px';
		}
	}
	
	sync1();
}

var preloads = [];
var allNav = [];
var rolledOver = false;
function preloadImages() {
	var nav = document.getElementById('nav').getElementsByTagName('a');
	for (var i=0; i<nav.length; i++) {
		var a = nav[i];
		var img = a.firstChild;
		if (img) {
			var base = img.src.substr(0,img.src.lastIndexOf('/')+1);
			a.img_default = base+img.id+'.gif';
			a.img_rollover = base+img.id+'-over.gif';
			a.img_start = img.src;
			preloads.push(new Image());
			preloads[preloads.length-1].src = a.img_default;
			a.onmouseover = function () {
				var img = this.firstChild;
				for (var i=0; i<allNav.length; i++) {
					if (allNav[i][0]!=this && allNav[i][1].src != allNav[i][0].img_rollover) {
						allNav[i][1].src = allNav[i][0].img_rollover;
					}
				}
				rolledOver = true;
				if (img.src != this.img_default) img.src = this.img_default;
			}
			a.onmouseout = function () {
				rolledOver = false;
				setTimeout(function () { 
					if (!rolledOver) {
						for (var i=0; i<allNav.length; i++) {
							if (allNav[i][1].src != allNav[i][0].img_start) allNav[i][1].src = allNav[i][0].img_start;
						}
					}
				}, 50);
			}	
			a.onclick = function() {this.blur()} // hide marquee in IE		
			allNav.push([a,img]);
		}
	}
}
function loadFlash() {
	var h1 = document.getElementsByTagName('h1');
	if (h1.length) {
		h1 = h1[0];
		var parent = h1.parentNode;
		// quick hack to add dots for resources under the heading...
		// new: now for all pages
		if (1) {//document.location.href.indexOf('resources.php')>=0) {
			var el = document.createElement('div');
			el.innerHTML = '<div style="margin-bottom:10px;position:relative; left:-15px; padding-left:15px; background:url(/-/media/base/horiz-dots.gif) repeat-x -4px bottom; height:34px; width:550px; margin-right:-20px;" id="h1"></div>';
		} else {
			var el = document.createElement('div');
			el.id = 'h1';
		}
		if (FlashManager.availFlash(8,0,0,0)) {		
			var h1inner = h1.innerHTML;
			// IE bastardizes the html, needs to be fixed
			h1inner=h1inner.split('=accent').join('="accent"').split('SPAN').join('span');
			
			// fix rare html entities into more casual characters
			h1inner=h1inner.split('’').join('\'');
			
			var fm = new FlashManager({movie:'/-/media/h1.swf',height:30, flashVars:'headingText='+escape(h1inner)});
			
			parent.insertBefore(el, h1);
			parent.removeChild(h1);
			fm.replaceCodeIn('h1', 'cancel');
		}
	}
}