function showMenu(layer)
{
	var myLayer = document.getElementById(layer);
	if(myLayer.style.display=="none" || myLayer.style.display=="")
	{
		myLayer.style.display="block";
	} else {
		myLayer.style.display="none";
	}
}

function showHelp()
{
	var hLayer = document.getElementById('helpLayer');
	if(hLayer.style.display=="none" || hLayer.style.display=="")
	{
		hLayer.style.display="block";
	} else {
		hLayer.style.display="none";
	}
}

function postTo(where)
{
	thisLink = document.location;
	switch(where)
	{
		case "buzz":
			theURL = "http://buzz.yahoo.com/submit?submitUrl="+escape(thisLink)+"&submitHeadline="+escape(linkTitle);
			window.open(theURL,"postPage");
			break;
		case "mixx":
			theURL = "http://www.mixx.com/submit?page_url="+escape(thisLink);
			window.open(theURL,"postPage");
			break;
		case "delicious":
			theURL = "http://delicious.com/save?url="+escape(thisLink);
			window.open(theURL,"postPage");
			break;
		case "facebook":
			theURL = "http://www.facebook.com/share.php?u="+escape(thisLink);
			window.open(theURL,"postPage");
			break;
		case "citeulike":
			theURL = "http://www.citeulike.org/post";
			window.open(theURL,"postPage");
			break;
		case "connotea":
			var u=location.href;
			var a=false;
			var x=window;
			var e=x.encodeURIComponent;
			var d=document;
			if((s=d.selection)?t=s.createRange().text:t=x.getSelection()+'')(r=/(doi:)?\s?(10\.\d{4}\/\S+)/.exec(t))?u='http://dx.doi.org/'+r[2]:a=true;
			a?alert('Please%20highlight%20a%20full%20DOI,%20or%20deselect%20text%20to%20add%20this%20page.'):w=open('http://www.connotea.org/addpopup?continue=confirm&uri='+e(u)+'&title='+e(d.title),'add','width=720,height=755,scrollbars,resizable');
			void(x.setTimeout('w.focus()',200));
			break;
		case "google":
			var a=window;
			var b=document;
			var c=encodeURIComponent;
			var d=a.open("http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk="+c(b.location)+"&title="+c(b.title),"bkmk_popup","left="+((a.screenX||a.screenLeft)+10)+",top="+((a.screenY||a.screenTop)+10)+",height=420px,width=550px,resizable=1,alwaysRaised=1");
			a.setTimeout(function(){d.focus()},300);
			break;
		default:
			theURL = "http://digg.com/submit?url="+escape(thisLink)+"&title="+escape(linkTitle)+"&media=news&topic=health";
			window.open(theURL,"postPage");
			break;
	}
	
}

urlVars = new Array();

function getURLvars()
{ 
	var thisURL = window.location.search.substring(1);
	var theseVars = thisURL.split("&");
	for (var a=0; a< theseVars.length; a++)
	{
		var thisPair = theseVars[a].split("=");
		urlVars[thisPair[0]] = thisPair[1];
	}
}

function lockCheck()
{
	getURLvars();
	if (urlVars["topic"]) setLock(urlVars["topic"]);
	if (urlVars["file"]) setLock("file"+urlVars["file"]);
	if (urlVars["data"]) setLock("data"+urlVars["data"]);
	if ((urlVars["func"] == "pubs") && (urlVars["what"])) setLock("pub"+urlVars["what"]);
}

function setLock(which)
{
	if (document.getElementById(which))
	{
		var thisClass = document.getElementById(which).className;
		document.getElementById(which).className = thisClass+"lock";
	}
}



ssearchHeight = "-61px";

var searchImages = new Array(10);
for (x=0;x<10;x++)
{
	searchImages[x] = new Image();
}
searchImages[0].src = "/images/~1#color#search_tab1a.gif";
searchImages[1].src = "/images/~1#color#search_tab1s.gif";
searchImages[2].src = "/images/~1#color#search_tab2a.gif";
searchImages[3].src = "/images/~1#color#search_tab2s.gif";
searchImages[4].src = "/images/~1#color#search_tab3a.gif";
searchImages[5].src = "/images/~1#color#search_tab3s.gif";
searchImages[6].src = "/images/~1#color#search_advanceda.gif";
searchImages[7].src = "/images/~1#color#search_advanceds.gif";
searchImages[8].src = "/images/~1#color#search_simplea.gif";
searchImages[9].src = "/images/~1#color#search_simples.gif";

if (navigator.appName == "Netscape")
{
	layerTS='document.layers["';
	layerTM='"]';
	styleTag="";
	isIE = false;
} else {
	layerTS='document.all["';
	layerTM='"]';
	styleTag=".style";
	isIE = true;
}

if ((parseInt(navigator.appVersion) >= 5) && !isIE)
{
	layerTS='document.getElementById("';
	layerTM='")';
	styleTag=".style";
}

searchState = 0;

defaultTextToShow = "Center for Studying Health System Change";

swapImageDir = "/images/";


function simpleClick()
{
	if (searchState==0)
	{
		eval(layerTS+"simplesearch"+layerTM+styleTag+'.top="0px"');
		tempstate = 1;
		showSimple();
	}
	if (searchState==1)
	{
		eval(layerTS+"simplesearch"+layerTM+styleTag+'.top="'+ssearchHeight+'"');
		tempstate = 0;
		showSimple();
	}
	if (searchState==2)
	{
		eval(layerTS+"simplesearch"+layerTM+styleTag+'.top="0px"');
		tempstate = 1;
		showSimple();
	}
	searchState = tempstate;
}

function advancedClick()
{
	if (searchState==0)
	{
		eval(layerTS+"advancedsearch"+layerTM+styleTag+'.top="0px"');
		tempstate = 2;
		showAdvanced();
	}
	if (searchState==1)
	{
		eval(layerTS+"advancedsearch"+layerTM+styleTag+'.top="0px"');
		tempstate = 2;
		showAdvanced();
	}
	if (searchState==2)
	{
		eval(layerTS+"simplesearch"+layerTM+styleTag+'.top="'+ssearchHeight+'"');
		tempstate = 0;
		showSimple();
	}
	searchState = tempstate;
}

function showSimple()
{
	eval(layerTS+"simplesearch"+layerTM+styleTag+'.visibility="visible"');
	eval(layerTS+"advancedsearch"+layerTM+styleTag+'.visibility="hidden"');
	eval(layerTS+"advancedsearch"+layerTM+styleTag+'.top="-300px"');
	document.simplesearchform.searchterm.select();
}

function showAdvanced()
{
	eval(layerTS+"simplesearch"+layerTM+styleTag+'.visibility="hidden"');
	eval(layerTS+"advancedsearch"+layerTM+styleTag+'.visibility="visible"');
	document.formelement.searchterm.select();
}


