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 == 'Are') 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="/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="/inc/styles.css" type="text/css">');
	pWin.document.write('</head><body><br /><img src="/images/nyamLogo.gif" width="339" height="89" border="0" alt=""><br /><br /><div id="printout">' + document.getElementById('content').innerHTML + '</div></body></html>');
	pWin.document.close();
}


divArray = [
	['Center for Urban Epidemiologic Studies', '/initiatives/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', '/initiatives/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', '/initiatives/swli.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', '/initiatives/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.'],
	['Office of Trustee and Fellowship Affairs', '/fellows/', 'The Fellows Office supports the activities of NYAM Fellows and Members including the Annual Meeting every fall and regular NYAM Section events.  The Office also handles recruitment, dues collection, and Trustee and Committee meeting logistics.']
];

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 = '' + 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;
}

var hcTimeout = null;

window.onload = function() {

	if(document.getElementById('hcMenuAction')) {
		document.getElementById('hcMenuAction').onclick = function() {
			hcShowMenu();
		};
	}
	
	if(document.getElementById('hcMenu')) {
		document.getElementById('hcMenu').onmouseout = function() {
			hcTimeout = setTimeout('hcHideMenu()', 300);
		};
		document.getElementById('hcMenu').onmouseover = function() {
			if(hcTimeout) clearTimeout(hcTimeout);
		};
	}
	
};

function hcShowMenu() {
	var dd = document.getElementsByTagName('dd');
	for(var i = 0; i < dd.length; i ++) {
		if(dd[i].parentNode == document.getElementById('hcMenu'))
			dd[i].style.display = 'block';
	}
}

function hcHideMenu() {
	var dd = document.getElementsByTagName('dd');
	for(var i = 0; i < dd.length; i ++) {
		if(dd[i].parentNode == document.getElementById('hcMenu'))
			dd[i].style.display = 'none';
	}
}