cf = 0;
om = 0;
hl = 0;

function hilite(m)
{
 hl = m;
 document.getElementById(hl).style.background = "#80041E";
 document.getElementById(hl).style.color = "#FFF";
}

function openSubmenu(n)
{
	if(cf) clearTimeout(timer);
	document.getElementById(n).style.display = 'block';
 if(om && om != n) {
  document.getElementById(om).style.display = 'none';
  if(hl)
  {
   document.getElementById(hl).style.background = "#FFF";
   document.getElementById(hl).style.color = "#80041E";  
   hl = 0;
  } 
 }
 om = n;
	cf = 0;
}

function closeSubmenu(n)
{
	if(cf)
	{
		document.getElementById(n).style.display = 'none';
		cf = 0;
  if(hl)
  {
   document.getElementById(hl).style.background = "#FFF";
   document.getElementById(hl).style.color = "#80041E";  
   hl = 0;
  }
	}
	else
	{
		timer = setTimeout("closeSubmenu('"+n+"')", 150);
		cf = 1;
	}
}


function makeCrumbs()
{
	if(document.getElementById('sectionHeader'))
	{
		section = document.getElementById('sectionHeader').innerHTML;
		sec = section.substring(0,3);
		if(document.getElementById('title'))
		{
			page = document.getElementById('title').innerHTML;
			if(page.length > 75) page = page.substring(0,74) + '...';
			if(document.getElementById('bc'))
			{
				if(sec == 'Abo') link = '/about/';
				else if(sec == 'Div') link = '/initiatives/';
				else if(sec == 'New') link = '/news/';
				else if(sec == 'Lib') link = '/library/';
				else if(sec == 'Eve') link = '/events/';
				else if(sec == 'Con') link = '/contribute/';
				else if(sec == 'Fel') link = '/fellows/';
				else if(sec == 'Gra') link = '/grants/';
				else if(sec == 'Res') link = '/resources/';
    else if(sec == 'The') link = '/initiatives/jf/';
				else link = '/';
				document.getElementById('bc').innerHTML += '<a href="' + link + '">' + section + '</a>  <img src="http://www.nyam.org/images/arrow.gif" width="3" height="5" border="0" alt=""> <a href="#">' + page + '</a>';
			}
			else alert('span not found');
			error = '';
		}
		else error = 'title not found';
	}
	else error = 'section not found';
	if(error) document.getElementById('bc').innerHTML += '<a href="">' + error + '</a>';
}

function printer()
{
	pWin = window.open('','printer','width=650,height=580,resizeable=1,scrollbars=1,menubar=1,toolbar=0,directories=0,statusbar=0');
	pWin.document.open();
	pWin.document.write('<html><head><title>' + document.title + '</title>');
	pWin.document.write('<link rel="stylesheet" href="http://www.nyam.org/inc/styles.css" type="text/css">');
	pWin.document.write('</head><body><img src="http://www.nyam.org/images/printerLogo.gif" width="184" height="66" border="0" alt=""><div id="printout">' + document.getElementById('content').innerHTML + '</div></body></html>');
	pWin.document.close();
}


divArray = [
	['Center for Urban Epidemiologic Studies', 'cues.shtml', 'The Center for Urban Epidemiologic Studies conducts wide-ranging research geared to understanding and preventing infectious disease, and educating residents about health risks they face and how to avoid them.'],
	['Division of Health Policy', 'sp.shtml', 'The Division of Health Policy is focused on improving the health of society’s most vulnerable populations, including immigrants, people of color, children, the elderly, people living in poverty, people with HIV/AIDS, and drug users.'],
	['Social Work Leadership Institute', 'gswppp.shtml', 'The Social Work Leadership Institute is building a committed and qualified workforce that can provide comprehensive care and superior social work services to the nation\'s older adults, and working to improve national policies that will improve seniors\' health.'],
	['Office of School Health Programs', 'shp.shtml', 'The Office of School Health Programs works to enhance the health of New York City children by addressing health education needs in schools and communities and helping students to develop the skills, attitudes, and knowledge needed to lead and maintain healthy lives.'],
	['Division of Public Health', 'ph.shtml', 'The Division of Public Health conducts research and policy analyses that help partnerships, funders, and policy makers to solve complex problems related to health and other areas through more effective collaboration with many different kinds of people and organizations.']
];

alt = 0;
alph = 100;
rot = 5;
strt = 0;
lnk = 0;
doRotate = 0;
initRot = 0;
	
function rotateDivisions()
{
	if(alt)
	{
		alph = alph - 2;
		if(alph > -1) doRotate = setTimeout("rotateDivisions()", 5);
		else setDivisions();
	}
	else
	{
		alph = alph + 2;
		if(alph < 101) doRotate = setTimeout("rotateDivisions()", 5);
		else setDivisions();
	}
	if(document.all) fgslot.style.filter = 'alpha(opacity=' + alph + ')';
	else
	{
		fgslot.style.opacity = (alph / 100);
		fgslot.opacity = (alph / 100); 
		fgslot.MozOpacity = (alph / 100); 
	}
	if(alph == 50) changeText();
}

function setDivisions()
{
	alt = alt ? 0 : 1;
	bgslot = document.getElementById('divisionDiv');
	fgslot = document.getElementById('divisionImg');
	dtitle = document.getElementById('divisionTitle');
	dtext  = document.getElementById('divisionText');
	rot ++;
	if(rot > 5) rot = 1;
	next = (rot == 5) ? 1 : rot + 1;	
	if(alt)
	{
		fgslot.src = '/images/homeDivisions' + rot + '.jpg';
		bgslot.style.background = 'url(/images/homeDivisions' + next + '.jpg)';
	}
	else
	{
		fgslot.src = '/images/homeDivisions' + next + '.jpg';
		bgslot.style.background = 'url(/images/homeDivisions' + rot + '.jpg)';		
	}
	initRot = setTimeout("rotateDivisions()", 5000);
	if(!strt)
	{ 
		dtitle.innerHTML = divArray[rot-1][0];
		dtext.innerHTML  = divArray[rot-1][2];		
	}
	strt ++;
}

function changeText()
{
	dtitle.innerHTML = divArray[next-1][0];
	dtext.innerHTML  = divArray[next-1][2];
	lnk = next-1;
	for(c=1; c<6; c++)
	{
		document.getElementById('div' + c).className = 'off';
	}
	document.getElementById('div' + next).className = 'on';
}

function divisionsLink()
{
	document.location = '/initiatives/' + divArray[lnk][1];
}

function divisionsJump(d)
{
	if(initRot) clearTimeout(initRot);
	if(doRotate) clearTimeout(doRotate);
	if(document.all) fgslot.style.filter = 'alpha(opacity=100)';
	else
	{
		fgslot.style.opacity = 1;
		fgslot.opacity = 1; 
		fgslot.MozOpacity = 1; 
	}
	fgslot.src = '/images/homeDivisions' + d + '.jpg'; 
	next = d;
	if(strt<5) showWait();
	changeText();
}

function showWait()
{
	document.getElementById('divisionWait').style.display = 'block';
	hwait = setTimeout("hideWait()", 500);
}

function hideWait()
{
	document.getElementById('divisionWait').style.display = 'none';
}

var submitted = 0;
function clickLimit (form,element) {
	if ( ! submitted ) { 
		form.elements[element].disabled=true;
        form.elements[element].value="Processing...";
        submitted = 1;
        form.submit();
    }
    else { alert("We're processing your contribution. Please be patient."); }
}

function gotosite(s)
{
	document.location = s;
}

function editWin(type, id) {
	var winwidth = 600;
	var winheight = 400;
	var url = '';
	
	
	switch(type) {
		case 'post':
			url = '/initiatives/jf/actions/disc_editpost.php?id=' + id;	
		break;
		
		case 'topic':
		default:
			url = '/initiatives/jf/actions/disc_edittopic.php?id=' + id;	
		break;
		
	}
	
	window.open(url,'name','height=' + winheight + ',width=' + winwidth + ', scrollbars=1');
}

function runUpdate() {
	var op_url = window.opener.document.location;
	
	window.opener.document.location = op_url;
	
	window.close();
	
	return;
}