// common shared JavaScript functions for Science Directorate websites version 02
// author: Jay Madigan
// revision date:  2008.04.24 001
// DO NOT EDIT WITHOUT PERMISSION


var monthsLONG = new Array("January","February","March","April","May","June","July","August","September","October","November","December");


function MakeDateString(datecode) {
    //20060908
    //01234567
//    alert(datecode);
    var year = datecode.substr(0,4);
//    var month = parseInt(date.substr(4,2));
    var month = datecode.substr(4,2)-1;
//    var day = parseInt(date.substr(6,2));
    var day = datecode.substr(6,2);
 //   alert(day);
    var DateString =  monthsLONG[month]+" "+day+", "+year;
    return DateString;
}

function confirm_leave() {
	return confirm('Thank you for visiting our NASA web site.\n\nYou are now leaving this site to enter a web site that is NOT maintained by the National Aeronautics and Space Administration (NASA).\n\nClick Cancel if you want to stay.');
}

function Disclaimer() {
	alert("\nYou are now leaving the NASA web domain (.nasa.gov)\n");
}

function CreateFooter(){
    //template change NASA Civil Servant to actual name
    document.write('<TABLE cellSpacing=0 cellPadding=0 width=730 align=center bgColor=#ffffff border=0>'        
                +'<TBODY>\n'
                +'<TR bgColor=#ffffff>\n'
                +'<TD colSpan=2><IMG height=1 src="http://science.larc.nasa.gov/common/spacer.gif" width=175></TD>\n'
                +'<TD vAlign=center align=right width=433><BR><IMG height=1 alt=spacer \n'
                +'src="http://science.larc.nasa.gov/common/spacer.gif" width=433> </TD></TR></TBODY></TABLE><!-- White space ends here --><!-- footer starts here --><!-- Footer starts -->\n'
                +'<TABLE cellSpacing=0 cellPadding=0 width=730 align=center border=0>\n'
                +'<TBODY>\n'
                +'<TR bgColor=#ffffff>\n'
                +'<TD width=10>&nbsp;</TD>\n'
                +'<TD width=330>&nbsp;</TD>\n'
                +'<TD width=52>&nbsp;</TD>\n'
                +'<TD width=10>&nbsp;</TD>\n'
                +'<TD width=189>&nbsp;</TD></TR>\n'
                +'<TR bgColor=#cccccc>\n'
                +'<TD width=10>&nbsp;</TD>\n'
                +'<TD width=330>&nbsp;</TD>\n'
                +'<TD width=52>&nbsp;</TD>\n'
                +'<TD width=10>&nbsp;</TD>\n'
                +'<TD width=189>&nbsp;</TD></TR>\n'
                +'<TR vAlign=top align=left bgColor=#cccccc>\n'
                +'<TD width=10><IMG height=1 \n'
                +'src="http://science.larc.nasa.gov/common/spacer.gif" \n'
                +'width=10> </TD>\n'
                +'<TD vAlign=top width=330 class="footer"><A class=footerLnk\n' 
                +'href="javascript:openNASAWindow(\'http://www.hq.nasa.gov/office/pao/FOIA/agency/\')">&#43;\n' 
                +'Freedom of Information Act</A> <BR><A class=footerLnk\n' 
                +'href="javascript:openNASAWindow(\'http://www.nasa.gov/about/budget/index.html\')">&#43; \n'
                +'Budgets, Strategic Plans and Accountability Reports</A> <BR><A class=footerLnk \n'
                +'href="javascript:openNASAWindow(\'http://www.nasa.gov/about/highlights/HP_Management.html\')">&#43;\n'
                +'The President\'s Management Agenda</A> <BR><A class=footerLnk \n'
                +'href="javascript:openNASAWindow(\'http://www.nasa.gov/about/highlights/HP_Privacy.html\')">&#43;\n' 
                +'Privacy Policy and Important Notices</A> <BR><A class=footerLnk \n'
                +'href="javascript:openNASAWindow(\'http://www.hq.nasa.gov/office/oig/hq/hotline.html\')">&#43;\n' 
                +'Inspector General Hotline</A> <BR><A class=footerLnk \n'
                +'href="javascript:openNASAWindow(\'http://www.hq.nasa.gov/office/codee/nofear.html\')">&#43;\n' 
                +'Equal Employment Opportunity Data Posted<BR><IMG height=1 alt="" \n'
                +'src="http://science.larc.nasa.gov/common/spacer.gif" \n'
                +'width=9 border=0>Pursuant to the No Fear Act</A> <BR><A \n'
                +'class=footerLnk \n'
                +'href="javascript:openNASAWindow(\'http://www.nasa.gov/about/contact/information_inventories_schedules.html\')">&#43;\n' 
                +'Information-Dissemination Priorities and Inventories</A> <BR><A \n'
                +'class=footerLnk href="javascript:openNASAWindow(\'http://www.usa.gov/\')">&#43;\n' 
                +'USA.gov</A> <BR><A class=footerLnk \n'
                +'href="javascript:openNASAWindow(\'http://www.whitehouse.gov/omb/expectmore/\')">&#43;\n' 
                +'ExpectMore.gov</A> <BR></TD>\n'
                +'<TD vAlign=top width=52><A class=footerLnk\n' 
                +'href="javascript:openNASAWindow(\'http://www.nasa.gov/home/index.html\')"><IMG \n'
                +'height=63 alt=NASA src="http://science.larc.nasa.gov/common/nasa_footer_03.gif" \n'
                +'width=52 border=0></A> </TD>\n'
                +'<TD width=10><IMG height=1 \n'
                +'src="http://science.larc.nasa.gov/common/spacer.gif" \n'
                +'width=10> </TD>\n'
                +'<TD class=footerlight width=189>&nbsp; <BR>Curator: <A class=footerLnk\n' 
                +'href="mailto:ANTISPAM.j.j.madigan@larc.nasa.gov">Jay Madigan</A> \n'
                +'<BR>NASA Responsible Official:<BR>&nbsp;&nbsp; NASA Civil Servant<BR>\n'
                +'last update:&nbsp;<SCRIPT> document.write (document.lastModified); </SCRIPT>\n'
		+'</TD></TR>\n'
                +'<TR bgColor=#cccccc>\n'
                +'<TD width=10><IMG height=1\n' 
                +'src="http://science.larc.nasa.gov/common/spacer.gif" \n'
                +'width=10></TD>\n'
                +'<TD width=330><IMG height=1\n' 
                +'src="http://science.larc.nasa.gov/common/spacer.gif" \n'
                +'width=330></TD>\n'
                +'<TD width=52><IMG height=1\n' 
                +'src="http://science.larc.nasa.gov/common/spacer.gif" \n'
                +'width=52></TD>\n'
                +'<TD width=10><IMG height=1\n' 
                +'src="http://science.larc.nasa.gov/common/spacer.gif" \n'
                +'width=10></TD>\n'
                +'<TD width=189><IMG height=1 \n'
                +'src="http://science.larc.nasa.gov/common/spacer.gif" \n'
                +'width=189></TD></TR>\n'
                +'<TR bgColor=#cccccc>\n'
                +'<TD width=10>&nbsp;</TD>\n'
                +'<TD width=330>&nbsp;</TD>\n'
                +'<TD width=52>&nbsp;</TD>\n'
                +'<TD width=10>&nbsp;</TD>\n'
                +'<TD width=189>&nbsp;</TD>\n'
                +'</TR>\n'
                +'</TBODY></TABLE>');
}
function CreateFooterBMB(){
    //template change NASA Civil Servant to actual name
    document.write('<TABLE cellSpacing=0 cellPadding=0 width=730 align=center bgColor=#ffffff border=0>'        
                +'<TBODY>\n'
                +'<TR bgColor=#ffffff>\n'
                +'<TD colSpan=2><IMG height=1 src="http://science.larc.nasa.gov/common/spacer.gif" width=175></TD>\n'
                +'<TD vAlign=center align=right width=433><BR><IMG height=1 alt=spacer \n'
                +'src="http://science.larc.nasa.gov/common/spacer.gif" width=433> </TD></TR></TBODY></TABLE><!-- White space ends here --><!-- footer starts here --><!-- Footer starts -->\n'
                +'<TABLE cellSpacing=0 cellPadding=0 width=730 align=center border=0>\n'
                +'<TBODY>\n'
                +'<TR bgColor=#ffffff>\n'
                +'<TD width=10>&nbsp;</TD>\n'
                +'<TD width=330>&nbsp;</TD>\n'
                +'<TD width=52>&nbsp;</TD>\n'
                +'<TD width=10>&nbsp;</TD>\n'
                +'<TD width=189>&nbsp;</TD></TR>\n'
                +'<TR bgColor=#cccccc>\n'
                +'<TD width=10>&nbsp;</TD>\n'
                +'<TD width=330>&nbsp;</TD>\n'
                +'<TD width=52>&nbsp;</TD>\n'
                +'<TD width=10>&nbsp;</TD>\n'
                +'<TD width=189>&nbsp;</TD></TR>\n'
                +'<TR vAlign=top align=left bgColor=#cccccc>\n'
                +'<TD width=10><IMG height=1 \n'
                +'src="http://science.larc.nasa.gov/common/spacer.gif" \n'
                +'width=10> </TD>\n'
                +'<TD vAlign=top width=330 class="footer"><A class=footerLnk\n' 
                +'href="javascript:openNASAWindow(\'http://www.hq.nasa.gov/office/pao/FOIA/agency/\')">&#43;\n' 
                +'Freedom of Information Act</A> <BR><A class=footerLnk\n' 
                +'href="javascript:openNASAWindow(\'http://www.nasa.gov/about/budget/index.html\')">&#43; \n'
                +'Budgets, Strategic Plans and Accountability Reports</A> <BR><A class=footerLnk \n'
                +'href="javascript:openNASAWindow(\'http://www.nasa.gov/about/highlights/HP_Management.html\')">&#43;\n'
                +'The President\'s Management Agenda</A> <BR><A class=footerLnk \n'
                +'href="javascript:openNASAWindow(\'http://www.nasa.gov/about/highlights/HP_Privacy.html\')">&#43;\n' 
                +'Privacy Policy and Important Notices</A> <BR><A class=footerLnk \n'
                +'href="javascript:openNASAWindow(\'http://www.hq.nasa.gov/office/oig/hq/hotline.html\')">&#43;\n' 
                +'Inspector General Hotline</A> <BR><A class=footerLnk \n'
                +'href="javascript:openNASAWindow(\'http://www.hq.nasa.gov/office/codee/nofear.html\')">&#43;\n' 
                +'Equal Employment Opportunity Data Posted<BR><IMG height=1 alt="" \n'
                +'src="http://science.larc.nasa.gov/common/spacer.gif" \n'
                +'width=9 border=0>Pursuant to the No Fear Act</A> <BR><A \n'
                +'class=footerLnk \n'
                +'href="javascript:openNASAWindow(\'http://www.nasa.gov/about/contact/information_inventories_schedules.html\')">&#43;\n' 
                +'Information-Dissemination Priorities and Inventories</A> <BR><A \n'
                +'class=footerLnk href="javascript:openNASAWindow(\'http://www.usa.gov/\')">&#43;\n' 
                +'USA.gov</A> <BR><A class=footerLnk \n'
                +'href="javascript:openNASAWindow(\'http://www.whitehouse.gov/omb/expectmore/\')">&#43;\n' 
                +'ExpectMore.gov</A> <BR></TD>\n'
                +'<TD vAlign=top width=52><A class=footerLnk\n' 
                +'href="javascript:openNASAWindow(\'http://www.nasa.gov/home/index.html\')"><IMG \n'
                +'height=63 alt=NASA src="http://science.larc.nasa.gov/common/nasa_footer_03.gif" \n'
                +'width=52 border=0></A> </TD>\n'
                +'<TD width=10><IMG height=1 \n'
                +'src="http://science.larc.nasa.gov/common/spacer.gif" \n'
                +'width=10> </TD>\n'
                +'<TD class=footerlight width=189>&nbsp; <BR>Curator: <A class=footerLnk\n' 
                +'href="mailto:ANTISPAM.j.j.madigan@larc.nasa.gov">Jay Madigan</A> \n'
                +'<BR>NASA Responsible Official:<BR>&nbsp;&nbsp; Dr. Joel S. Levine<BR>\n'
                +'last update:&nbsp;<SCRIPT> document.write (document.lastModified); </SCRIPT>\n'
		+'</TD></TR>\n'
                +'<TR bgColor=#cccccc>\n'
                +'<TD width=10><IMG height=1\n' 
                +'src="http://science.larc.nasa.gov/common/spacer.gif" \n'
                +'width=10></TD>\n'
                +'<TD width=330><IMG height=1\n' 
                +'src="http://science.larc.nasa.gov/common/spacer.gif" \n'
                +'width=330></TD>\n'
                +'<TD width=52><IMG height=1\n' 
                +'src="http://science.larc.nasa.gov/common/spacer.gif" \n'
                +'width=52></TD>\n'
                +'<TD width=10><IMG height=1\n' 
                +'src="http://science.larc.nasa.gov/common/spacer.gif" \n'
                +'width=10></TD>\n'
                +'<TD width=189><IMG height=1 \n'
                +'src="http://science.larc.nasa.gov/common/spacer.gif" \n'
                +'width=189></TD></TR>\n'
                +'<TR bgColor=#cccccc>\n'
                +'<TD width=10>&nbsp;</TD>\n'
                +'<TD width=330>&nbsp;</TD>\n'
                +'<TD width=52>&nbsp;</TD>\n'
                +'<TD width=10>&nbsp;</TD>\n'
                +'<TD width=189>&nbsp;</TD>\n'
                +'</TR>\n'
                +'</TBODY></TABLE>');
}


//
// CORE NASA JavaScript FUNCTIONS BELOW: ---------------------------
// formerly content of 45193main_nes-common.js
// things such as common NASA footer and header will not work without these
//
function UA(){
  var v = navigator.appVersion.toLowerCase(), u = navigator.userAgent.toLowerCase(), n = navigator.appName;
  this.mac = (v.indexOf("mac")+1);
  this.win = (v.indexOf("win")+1);
  this.nn = (n == "Netscape");
  this.ie = (n == "Microsoft Internet Explorer");
  this.aol = (u.indexOf("aol")+1);
  this.opera = (u.indexOf("opera")+1);
  this.ver = (this.ie) ? parseFloat(v.split('msie ')[1]) : parseFloat(v);
  this.major = this.ver.toString().split('.')[0];
	this.minor = this.ver.toString().split('.')[1];
	this.v4 = (this.major == 4);
	this.os = (this.mac) ? 'mac' : (this.win) ? 'win' : navigator.platform;
  this.name = (this.nn) ? 'nn' : (this.ie) ? 'ie' : n;
  this.codeName = this.name +'_'+ parseInt(this.ver) + '_'+ this.os;
}
var ua = new UA();

var onloadHandlers = [];
function loadEvents() {
  for(var i=0; i<onloadHandlers.length; i++) {
    eval(onloadHandlers[i]);
  }
}
window.onload = loadEvents;

var onresizeHandlers = [];
function resizeEvents() {
  for(var i=0; i<onresizeHandlers.length;i++) {
    eval(onresizeHandlers[i]);
  }
}
window.onresize = resizeEvents;

function handleResize(init) {
  if(!(document.layers)) return;
  if(init==true) with (navigator) {
    document.pgW=innerWidth;
    document.pgH=innerHeight;
    onresizeHandlers[onresizeHandlers.length] = 'handleResize()';
  }
  else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}
handleResize(true);

function getObjByName(name,doc) {
  var o = 0;
  if(!doc) doc = document;
  if(doc[name]) o=doc[name];
  if(document.all && doc.all[name]) o=doc.all[name];
  if(o) {
    if(!o.getElementsByTagName) o.getElementsByTagName = getElementsArray;
    return o;
  }
  if(document.layers) {
    for(var i=0;i < doc.layers.length;i++){
      var lyrdoc = doc.layers[i].document;
      if(lyrdoc[name]) return lyrdoc[name];
      if(lyrdoc.layers.length > 0) {
        var o = getObjByName(name,lyrdoc);
        if(o) return o;
      }
    }
  }
  return 0;
}
if(!document.getElementById) document.getElementById = getObjByName;

function getElementsArray(el) {
  if(document.layers) {
    var doc = (this == document) ? document : this.document;
    switch(el) {
      case 'img' : return doc.images;
      case 'a' : return doc.links;
      case 'div' : return doc.layers;
      case 'form' : return doc.forms;
      default : return 0;
    }
  }
  if(document.all) return this.all.tags(el);
  return 0;
}
if(!document.getElementsByTagName) document.getElementsByTagName = getElementsArray;
if(document.layers) Layer.prototype.getElementsByTagName = getElementsArray;

function show(div){
  if(document.all) window.document.all[div].style.visibility = 'visible';
  else if(document.layers) getObjByName(div).visibility = 'show';
  else document.getElementById(div).style.visibility = 'visible';
}
function hide(div){
  if(document.all) window.document.all[div].style.visibility = 'hidden';
  else if(document.layers) getObjByName(div).visibility = 'hide';
  else document.getElementById(div).style.visibility = 'hidden';
}

function swapImg() {
  if(!document.images) return;
  var args = swapImg.arguments;
  for(var i=0;i < args.length;i+=2) {
    var imgSrc = (args[i + 1].indexOf('[') != -1) ? eval(args[i + 1] + '.src') : args[i + 1];
    if(getObjByName(args[i])) getObjByName(args[i]).src = imgSrc;
  }
}

function setCookie(name,value,expires) {
  document.cookie = escape(name)+'='+escape(value)+'; expires='+expires.toGMTString();
}

function getCookie(name) {
  var value,nl,cl,i,j,e;
  name+='=';
  value = 0;
  nl = name.length;
  cl = document.cookie.length;
  i = 0;
  while (i < cl) {
    j = i+nl;
    if(document.cookie.substring(i,j) == name) {
      e = document.cookie.indexOf(';',j);
      if(e == -1) e = document.cookie.length;
      value = unescape(document.cookie.substring(j,e));
      break;
    }
    i = document.cookie.indexOf(' ', i) + 1;
    if (i == 0) break;
  }  
  return value;
}

function openNASAWindow(url)
{
  if (url != "#")
  {
    var positionX = screen.width;
    var positionY = ((screen.height)/2);

    var sizeX = 720;
    var sizeY = 640;
    
    var strWindowFeatures = "";
    strWindowFeatures += 'menubar=yes,location=yes,toolbar=yes,directories=yes,scrollbars=yes,status=yes,resizable=yes,outerWidth='+720+',outerHeight='+640+',width='+720+'height='+640+',left='+80+',top='+60+'screenX='+80+',screenY='+60;
    winPopupWindow = window.open(url, "nasawindow", strWindowFeatures);
    winPopupWindow.focus();
  }
}

function preLoad(a) {
  var o = [];
  for(var i=0; i<a.length; i++) {
    o[i] = new Image();
    o[i].src = '/images/'+a[i]+'_1.gif';
  }
}

//preLoad('placeholder/navigation/topnav/nav_top_0','placeholder/navigation/topnav/nav_top_1','placeholder/navigation/topnav/nav_top_2','placeholder/navigation/topnav/nav_top_3','placeholder/navigation/topnav/nav_top_4','placeholder/navigation/topnav/nav_top_5');


