stat=new Array();

//main nav code
function getLayer(name) {
	if(typeof name != "string") return name;
	return document.getElementById(name).style;
	return null
}

function hide_secnav(){
	var n=hide_secnav.arguments.length;
	for (var i=0; i<n; i++) {
		var lyr = getLayer(hide_secnav.arguments[i])
		if(lyr) {
			lyr.display = "none";
		}
	}
}

function hideAll(){
	hide_secnav("smabout", "smtrain", "smresrch","dummy","smprod","smfacts","smtopics","smpress","smrsrcs");
}

function show_secnav(){
	hideAll();
   var n=show_secnav.arguments.length;
   for (var i=0; i<n; i++) {
	 var lyr = getLayer(show_secnav.arguments[i]);
	 if(lyr) {
			lyr.display="inline";
	 }
   }
}
// end main nav code

// CSS disclosure menu for test page
function openWind(fname)
{
	window.open(fname,'','width=450,height=470,scrollbars=yes,resizable=yes');
}

function setit(id, isOn){
	objParent=document.getElementById(id);
	objDaughter=document.getElementById('l'+id);
	if(isOn){
		objDaughter.style.display='block';
		objParent.className='cl1op';
		stat[id] = 1;
	}
	else{
		objDaughter.style.display='none';
		objParent.className='cl1nd';
		stat[id] = 0;
	}
}

function flipit(id){
	objParent=document.getElementById(id);
	objDaughter=document.getElementById('l'+id);
	if(stat[id] != 1){
		objDaughter.style.display='block';
		objParent.className='cl1op';
		stat[id] = 1;
	}
	else{
		objDaughter.style.display='none';
		objParent.className='cl1nd';
		stat[id] = 0;
	}
}

function dminit(){
	for (i = 1; i < stat.length; i++){
		if(stat[i] != 1){
			setit(i, false);
		}
		else{
			setit(i, true);
		}
	}
}

function expandall(){
	for (i = 1; i < 100 && document.getElementById('l'+i)!= null; i++){
		setit(i, true);
	}
}

function collapseall(){
	for (i = 1; i < 100 && document.getElementById('l'+i)!= null; i++){
		setit(i, false);
	}
		setit(1, true);
}

function closehigher(id){
	for (i = 0; i < stat.length; i++){
		if(i > id){
			setit(i, false);
		}
	}
}

function changeMain(id){
	objParent=document.getElementById(id);
	objDaughter=document.getElementById('l'+id);
	if(id == 1 && stat[id] == 1){
		closehigher(id);
		return;
	}
	flipit(id);
}

function addMenuState(inLink){
	inLink.href= inLink.href + "&dm=" + stat;
}
// END CSS disclosure menu for test page

function extlinkpopup(){
	alert("\r\nYou are now leaving the Department of Veteran Affairs Website.\r\n \r\nVA does not endorse and is not responsible for the content of the linked website");
}

function extgovpopup(){
	alert("You are now leaving the NCPTSD Website");
}

// functions for tab rollovers

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
