//<SCRIPT language="javascript" id="BAYES_ssChanger">
function changeStylesheet(xslFile){
	hideMenu();
	try{
		var x = document.XMLDocument;
		var s = new ActiveXObject("Microsoft.XMLDOM");
		s.async = false;
		s.load(xslFile);
		var newDoc = document.open("text/html", "replace");
		newDoc.write(x.transformNode(s));
		newDoc.XMLDocument = x;
		newDoc.XSLDocument = s;
		newDoc.close();
	}catch(exception){
		formatError(exception);
	}
}
function ssClass(href, title, media){
	this.source = href;
	this.title = title;
	this.media = media;
}
function getPIstylesheet(x){
	var idx = 0;
	var hrefs = new Array();
	if (typeof(x) != "undefined"){
		var y = new ActiveXObject("Microsoft.XMLDOM");
		for (var i = 0; i < x.childNodes.length; i++){
			var n = x.childNodes(i);
			if (n.nodeName == "xml-stylesheet"){
				var h="", t="", m="";
				y.loadXML("<?xml version=\"1.0\"?><xs " + n.nodeValue + "/>");
				try{h=y.selectSingleNode("/xs/@href").value}catch(e){}
				try{t=y.selectSingleNode("/xs/@title").value}catch(e){}
				try{m=y.selectSingleNode("/xs/@media").value}catch(e){}
				hrefs[idx++] = new ssClass(h, t, m);
			}
		}
	}
	return hrefs;
}
function setupChangeStylesheet(obj){
	hideMenu();
	try{
		x = document.XMLDocument;
		var a = getPIstylesheet(x);
		hideMenu();
		var baseref = document.location.protocol + "//" + document.location.host;
		var gif = "<img src=\"" + baseref + "/xml/images/xslt.gif\" title=\"\" style=\"position:relative;top:2px;\" />&#160;&#160;";
		var newTags = "<div id=\"BAYES_ssChangerMenu\" style=\"position:absolute;color:black;background-color:#66ffff;background-repeat:repeat-y;background-image:url('" + baseref + "images/mnubg.gif');border:solid 1px black;padding:4px;cursor:hand;font-size:10pt;z-index:100;\">"
		for (i=0; i < a.length; i++){
			newTags += "<div onclick=\"changeStylesheet('" + a[i].source + "')\" nowrap onmouseover=\"this.style.border='solid 1px blue';this.style.padding='0px'\" onmouseout=\"this.style.border='none';this.style.padding='1px'\" style=\"padding:1px;\">" + gif + a[i].title + "</div>";//"&#160;(" + a[i].media + ")" +
		}
		newTags += "<div onclick=\"hideMenu()\" onmouseover=\"this.style.border='solid 1px blue';this.style.padding='0px'\" onmouseout=\"this.style.border='none';this.style.padding='1px'\" style=\"padding:1px;\">" + "<img src=\"" + baseref + "/xml/images/cancel.gif\" title=\"\" style=\"position:relative;top:2px;\" />&#160;&#160;Cancel</div>";
		newTags += "</div>";
		if (typeof(document.all['BAYES_ssChangerMenu']) != "object"){
			document.body.insertAdjacentHTML("afterBegin", newTags);
			var odiv = document.all['BAYES_ssChangerMenu'];
			var x = event.clientX;
			var y = event.clientY;
			if (odiv.offsetHeight + y > document.body.offsetHeight){
				odiv.style.top = y - odiv.offsetHeight;
			}else{
				odiv.style.top = y;
			}
			if (odiv.offsetWidth + x > document.body.offsetWidth){
				odiv.style.left = x - odiv.offsetWidth;
			}else{
				odiv.style.left = x;
			}
		}
	}catch(exception){
		formatError(exception);	
	}
}
function hideMenu(){
	if (typeof(document.all['BAYES_ssChangerMenu']) == "object" && document.all['BAYES_ssChangerMenu'] != null){
		document.all['BAYES_ssChangerMenu'].outerHTML = "";
		document.all['BAYES_ssChangerMenu'] = null;
	}
}
function formatError(pe){
	var o = "";
	var e = "";
	if (typeof(pe.reason) == "string"){
		for (i=0; i < pe.linepos-1; i++){
			if (pe.srcText.substr(i,1) == "\t"){
				o += "\t";
			}else{
				o += "-";
			}
		}
		o += "^";
		e = pe.reason + ": " + pe.errorCode + "\n" + pe.srcText + "\n" + o + "\n" + pe.url + " line " + pe.line;
	}else if (typeof(pe.description) == "string"){
		e = pe.description;
	}
	alert(e);
}
//</SCRIPT>
