if(!window.WWWROOT) window.WWWROOT = "/mskcc/"
if(!window.RESOURCES) window.RESOURCES = "/mskcc_resources/"
if(!window.baseDomain) window.baseDomain = ''

/*************** OPEN SEARCH ***************/
function openSearch(Type, Criteria, ShowSummaries){
	Criteria = (Criteria)?Criteria:self.Criteria;
	ShowSummaries = (ShowSummaries)?ShowSummaries:self.ShowSummaries;

	if(self.location.href.indexOf("/_temp/") != -1){
		location = "/inettool/site/" + DisplayType + "?ID=5707&PageType=" + PageType;
	} else {
		location = WWWROOT + ((window.TEMPLATE_TYPE =="print")?"print":"html") + "/5707.cfm?" +
			"SearchFormType=" + Type +
			((typeof Criteria == "string")?"&Criteria=" + escape(Criteria):"") + 
			((typeof ShowSummaries != "undefined")?"&ShowSummaries=" + ShowSummaries:"");
	}
}

/*************** OPEN SIDEBAR ***************/
function openSidebar(Type, Criteria, ShowSummaries){
	Criteria = (Criteria)?Criteria:self.Criteria;
	ShowSummaries = (ShowSummaries)?ShowSummaries:self.ShowSummaries;

	if(top.openSidebar != self.openSidebar){
		top.openSidebar(Type, Criteria, ShowSummaries)
	} else {
		top.location = baseDomain + RESOURCES + "sidebar/index.cfm" + 
			"?WWWROOT=/mskcc/" +
			"&MainSrc=" + escape(location.href) + 
			"&SidebarType=" + Type +
			((typeof Criteria == "string")?"&Criteria=" + escape(Criteria):"") + 
			((typeof ShowSummaries != "undefined")?"&ShowSummaries=" + ShowSummaries:"");
	}
}

function changeVersion(element){
	if(window.TEMPLATE_TYPE){
		var changeTo = (TEMPLATE_TYPE =="print" || TEMPLATE_TYPE =="glossary")?"html":"print"
	
		if(self.location.href.indexOf("/_temp/") != -1){
			var href = "/inettool/site/" + DisplayType + "?ID=" + ID + "&PageType=" + changeTo;
		} else if(self.location.href.indexOf("/prg/") != -1){
			var param = "TemplateType=print"
			if(self.location.href.indexOf(param) != -1)
				var href = self.location.pathname + self.location.search.substring(0, self.location.search.indexOf(param)-1 )
			else
				var href = self.location.pathname + self.location.search + ((self.location.search=="")?"?":"&") + param;

		} else {
			var href = WWWROOT + changeTo + "/" + ID + "." + FileType + location.search + location.hash;
		}
		if(element){
			element.href = href
			return true
		} else {
			window.location = href
			return false
		}
	}
	return true
}