
window.onload = function() {
	if (document.all.inherit) {
		document.all.inherit.style.display = "none";
	}
	if (document.all.collab) {
		document.all.collab.style.display = "none";
	}
}

function inherit() {
	if (document.all.inherit) {
		if (document.all.inherit.style.display == "none") {
			document.all.inherit.style.display = "";
		} else {
			document.all.inherit.style.display = "none";
		}
	}
}
function collab() {
	if (document.all.collab) {
		if (document.all.collab.style.display == "none") {
			document.all.collab.style.display = "";
		} else {
			document.all.collab.style.display = "none";
		}
	}
}

function brew_api(link,link2) {
	var f = location.href;
	var path = '';
	
	// from local HTML
	if (f.substring(0,5) == 'file:') {
		r = new RegExp('^file:///?(([^/]+/)+).*$', 'i');
		if (f.match(r)) {
			path = RegExp.$1;
			path = path.split('/').join('\\') + "..\\";
		}
	}
	// from CHM
	else if (f.substring(0,3) == 'mk:') {
		r = new RegExp('^mk:@MSITStore:(([^\\\\]+\\\\)+)[^:]+::.*$', 'i');
		if (f.match(r)) {
			path = RegExp.$1;
		}
	}

	if (path == '') {
		alert('This link to BREW API Reference is not available.');
		return;
	}
	
	
	var base = "ms-its:" + path + "BREWAPIReference.chm::/";
	//alert(base);

	try {
		new Ajax.Request(base + link2, { 
			onComplete: function(responseHttpObj)
			{
				if(responseHttpObj.responseText == ''){
					window.open(base + link);
				} else {
					window.open(base + link2);
				}
			}
		});
	} catch(e) {
		window.open(base + link);
	}

	//window.open(url, 'BREW_API');
}



