var ab_droplist = new Array(
"aboutPASE/index.html|What is PASE?",
"aboutPASE/afterschool.html|What is Afterschool?",
"aboutPASE/board.html|Board of Directors",
"aboutPASE/advisorycouncils.html|Advisory Councils",
"aboutPASE/staff.html|Staff",
"aboutPASE/supporters.html|Supporters",
"aboutPASE/membership.html|Membership",
"aboutPASE/press.html|Press"
);
var tr_droplist = new Array(
"training/calendar.html|PASE Professional Development",
"training/OSTcalendar.html|PASE/DYCD OST Training",
"training/site-based.html|PASE Site-Based Services",
"training/eventspase.html|PASEsetter Awards",
"training/national.html|National Events"
);
var dp_droplist = new Array(
"demonstrationPrograms/index.html|Afterschool Outcomes",
"demonstrationPrograms/health.html|Children's Health",
"demonstrationPrograms/collegeprep.html|College Prep",
"demonstrationPrograms/compassion.html|Communities Empowering Youth",
"demonstrationPrograms/leadership.html|Leadership",
"demonstrationPrograms/socialservices.html|Social Services and Mental Health",
"demonstrationPrograms/summergap.html|Summer Learning",
"demonstrationPrograms/pastprojects.html|Past Projects"
);
var ev_droplist = new Array(
"demonstrationPrograms/index.html|Quality Outcomes Initiative",
"outcomes/outcomes_inventory.html|Youth Outcomes Publication",
"reframe/index.htm|Outcomes Resource Center"
);
var pb_droplist = new Array(
"publicationResources/pandr.html#jobs|Jobs Bulletin",
"publicationResources/bulletin.html|PASE Bulletin",
"publicationResources/pandr.html|PASE Publications <br>&nbsp;and Resources",
"publicationResources/podcasts.html|PASE Podcasts",
"publicationResources/afterschool.html|Afterschool <br>&nbsp;Publications <br>&nbsp;and Resources",
"publicationResources/funding.html|Funding Resources ",
"publicationResources/advocacy.html|Advocacy Resources&nbsp;&nbsp;&nbsp;"
);
function Bdetectorf(){
   var ua = navigator.userAgent;
   this.isOpera = function(){
      return /Opera/.test(ua);
   }
   this.isSafari = function(){
      return /Safari/.test(ua);
   }
   this.isGecko = function(){
      return navigator.product == "Gecko" &&
	     ! ( this.isOpera() || this.isSafari() );
   }
   this.isIEWin = function(){
      return window.external && /Win/.test(ua);
   }
   this.isIEMac = function(){
      return window.external && /Mac/.test(ua);
   }
   this.getVersion = function(){
      if( this.isIEWin() || this.isIEMac() ){
         return Number(ua.match(/MSIE ([0-9.]+)/)[1]);
      }else if( this.isSafari() ){
         return Number(ua.match(/[0-9.]+$/));
      }else if( this.isGecko() ){
         var n = ua.match(/rv:([0-9.]+)/)[1];
         var ar = n.split(".");
         var s = ar[0] + ".";
         for(var i = 1; i < ar.length; ++i){
            s += ("0" + ar[i]).match(/.{2}$/)[0];
         }
         return Number(s);
      }else if( this.isOpera() ){
         return Number(ua.match(/Opera ([0-9.]+)/)[1]);
      }else{
         return null;
      }
   }
}
detect = new Bdetectorf();
var ext;
var currentlayer;
var mastertable;
if(document.all || detect.isSafari()){ 
	var ietop = 28; //ie thinks div starts from top height of your nav image.
}else if(document.getElementById){
	 var ietop = 0; //ns6 thinks div starts from bottom
}

var ieleft = 2;
var timeoutid;
var layerlist = new Array('ab','tr','dp','ev','pb');
var physwidth = new Array('153','154','155','155','154');
var jumpwidth = new Array('1','153','308','463','617');

if((!document.all)&&(!document.getElementById)){ //for netscape 4.x
	var nstop = 11;
	var nsleft = 3;
	nsleft = eval(document.images.placeholderimage.x+nsleft);
	nstop = eval(document.images.placeholderimage.y+nstop);
}
if((document.layers)){
	ext ='ns';
}
if(document.getElementById){
	ext ='ns7';		
}
if(document.all){
	ext ='';		
}


var text ='';
// GIANT FOR LOOP WITH OTHER FOR LOOPS GENERATES ALL DHTML FROM ARRAYS GRABBED FROM DB ---------------------------------------------
for(i=0;i<layerlist.length;i++){
	whichlayername = layerlist[i];
	mastertable = whichlayername;
	if(document.all){
		mastertable='';
	}
	if ((document.all)||(document.getElementById)){
		text += '<div id="' + layerlist[i]+ '" style="position:absolute; overflow:none; left:'+ eval(ieleft+eval(jumpwidth[i])) +'px;top:'+ ietop +'px;z-index:1;visibility:hidden;padding:0px">';
		text +='<table class="dropdownlinks dropdownLinks'+ext+mastertable+'" border="0" cellpadding="0" cellspacing="0" style="">\n'
	}else{
		text += '<layer name="' + layerlist[i]+ '" left="'+ eval(nsleft+eval(jumpwidth[i])) +'" top="'+ nstop +'" z-index="10000" visibility="hide">';

	}
	for(j=0;j<eval(layerlist[i]+'_droplist.length');j++){ 
		var subrow = eval(layerlist[i]+'_droplist['+j+']').split("|");
		if ((document.all)||(document.getElementById)){
			text += '<tr class="dropdownLinksrow'+ext+mastertable;
				if((!document.all)&&(document.getElementById)){
					text += ' dropdownLinks'+ext+' dropdownlinks'+whichlayername+'" onMouseOver="showthislayer(\'' + layerlist[i]+ '\');" onMouseOut="hidethislayer(\'' + layerlist[i]+ '\')';
				}
			text += '"><td>';
		}
		text += '<a href="'+basehreffordrop+subrow[0]+'"';

		if (document.all){
			text += 'onMouseOver="showthislayer(\'' + layerlist[i]+ '\');" onMouseOut="hidethislayer(\'' + layerlist[i]+ '\');" class="dropdownLinks'+ext+' dropdownlinks'+whichlayername+'"';
		}
		text += '">&nbsp;'+subrow[1].replace(/\s/g,"&nbsp;")+'&nbsp;</a>';

		if ((document.all)||(document.getElementById)){
			text += '</td></tr>';
		}
	}
	if ((document.all)||(document.getElementById)){
	text += "</table>"

		text += '</div>';
	}else{
		text += '</layer>';
	}

}
//end loop--------------ok it's not that giant------but it generates a lot of stuff-----------------------------------------------------
if(document.all){
	placeholder.innerHTML= text;
}else if(document.getElementById){
	document.getElementById("placeholder").innerHTML = text;
}else{
	document.write(text);
}	
function getLayer(name) {
  if (document.layers)
    return(document.layers[name]);
  else if (document.all) {
    layer = eval('document.all.' + name + '.style');
    return(layer);
  }else if(document.getElementById){
	   return(document.getElementById(name).style)
  }
  else
    return(null);
}

function showthislayer(whichlayer){
	var layer = getLayer(whichlayer);
	if (currentlayer == whichlayer){
		clearTimeout(timeoutid);
	}else{
		currentlayer = whichlayer
		hidealllayers(whichlayer);
	}	
	if (document.layers){
		layer.visibility = "show";
	}
	if ((document.all)||(document.getElementById)){
		layer.visibility = "visible";
	}
}

function hidethislayer(whichlayer){
	layer = getLayer(whichlayer);
	cludgelayer = whichlayer;
	if (currentlayer == whichlayer){
		timeoutid = setTimeout("cludge(cludgelayer);",0);
	}else{
		currentlayer = whichlayer;
		if (document.layers){
			layer.visibility = 'hide';
		}	
		if ((document.all)||(document.getElementById)){
			layer.visibility = "hidden";
		}	
	}
}

function cludge(whichlayer){
	var layer = getLayer(whichlayer);
	if (document.layers){
		layer.visibility = 'hide';
	}	
	if ((document.all)||(document.getElementById)){
		layer.visibility = "hidden";
	}	
}

function hidealllayers(whichlayer){
	for(i=0;i<layerlist.length;i++){
		if(whichlayer != layerlist[i]){
			hidethislayer(layerlist[i]);
		}
	}
}
