// common shared JavaScript functions
// file date 2007.09.26 001

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_transport_to_Jetstream() {
	return confirm('You are now being transported to\nThe NWS JetStream MAX Interactive Cloud Chart.\n\nClick OK if you wish to proceed.');
}
function confirm_download() {
	return confirm('The file that you are about to access is 16MB in size.\n\nDependent upon your connection speed,\nthe download may take several minutes.\n\nClick OK if you wish to proceed.');
}

function Disclaimer() {
	alert("\nYou are now leaving the NASA web domain (.nasa.gov)\n");
}


function CreateSCOOLheader() {
document.write('<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="100%" BGCOLOR="#c7eafb">');
document.write('    <TR>');
document.write('        <TD VALIGN="middle" WIDTH="510"><A HREF="http://www.nasa.gov"><IMG SRC="http://science-edu.larc.nasa.gov/common/new_logo_nasa.gif" WIDTH="288" HEIGHT="51" ALT="NASA - National Aeronautics and Space Administration" BORDER="0"></A><BR /></TD>');
document.write('        <TD VALIGN="middle" HEIGHT="65" WIDTH="186">');
document.write('            <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">');
document.write('                <TR>');
document.write('                    <TD BGCOLOR="#c7eafb" WIDTH="1"><IMG BORDER="0" ALT=" " HEIGHT="45" WIDTH="1" SRC="http://science-edu.larc.nasa.gov/common/spacer.gif"></TD>');
document.write('                    <TD WIDTH="19"><IMG BORDER="0" ALT="" HEIGHT="1" WIDTH="1" SRC="http://science-edu.larc.nasa.gov/common/spacer.gif"></TD>');
document.write('                    <TD BGCOLOR="#c7eafb" VALIGN="middle" ALIGN="right" HEIGHT="65" WIDTH="278">');
document.write('                        <TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">');
document.write('                            <TR>');
document.write('                                <TD ROWSPAN="2" WIDTH="30" ALIGN="right"><IMG BORDER="0" ALT="" HEIGHT="1" WIDTH="10" SRC="http://science-edu.larc.nasa.gov/common/spacer.gif"></TD>');
document.write('                                <TD COLSPAN="3">');
document.write('                                    <LABEL FOR="searchfield"><B><FONT SIZE="2">FIND IT @ S\'COOL</FONT></B>');
document.write('                                </TD>');
document.write('                            </TR>');
document.write('                            <TR>');
document.write('                                <TD VALIGN="top" ALIGN="right">');
document.write('                                    <FONT SIZE="2" FACE="arial">');
document.write('                                        <FORM NAME="search" METHOD="post" ACTION="/cgi-bin/SCOOL_websearch.pl">');
document.write('                                            <INPUT TYPE="hidden" NAME="boolean" VALUE="as a phrase" />');
document.write('                                            <INPUT TYPE=TEXT NAME="terms" SIZE="20" /><FONT SIZE="3">');
document.write('                                            <INPUT TYPE="hidden" NAME="boolean" VALUE="all terms" />');
document.write('                                            <INPUT TYPE="hidden" NAME="case" VALUE="insensitive" />');
document.write('                                            <INPUT TYPE="hidden" NAME="hits" VALUE="25" />');
document.write('                                        </FORM>');
document.write('                                    </FONT>');
document.write('                                <TD WIDTH="8"><IMG BORDER="0" ALT="" HEIGHT="1" WIDTH="5" SRC="http://science-edu.larc.nasa.gov/common/spacer.gif"></TD>');
document.write('                                <TD VALIGN="middle"><A HREF="javascript:document.search.submit();"><IMG name="Go" SRC="http://science-edu.larc.nasa.gov/common/button_go_C7EAFB.gif" WIDTH="38" HEIGHT="20" ALT="Go" BORDER="0"></A></TD>');
document.write('                                <TD WIDTH="8"><IMG BORDER="0" ALT="" HEIGHT="1" WIDTH="5" SRC="http://science-edu.larc.nasa.gov/common/spacer.gif"></TD>');
document.write('                            </TR>');
document.write('                        </TABLE>');
document.write('                    </TD>');
document.write('                </TR>');
document.write('            </TABLE>');
document.write('        </TD>');
document.write('    </TR>');
//document.write('    <TR>');
//document.write('        <TD COLSPAN="2" HEIGHT="2" BGCOLOR="#000000"></TD>');
//document.write('    </TR>');
document.write('</TABLE>');
}


function CreateNASAheaderBLUE() {
document.write('<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="100%" BGCOLOR="#c7eafb">');
document.write('    <TR>');
document.write('        <TD VALIGN="middle" WIDTH="510"><A HREF="http://www.nasa.gov"><IMG SRC="http://science-edu.larc.nasa.gov/common/new_logo_nasa.gif" WIDTH="288" HEIGHT="51" ALT="NASA - National Aeronautics and Space Administration" BORDER="0"></A><BR /></TD>');
document.write('        <TD VALIGN="middle" HEIGHT="65" WIDTH="186">');
document.write('            <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">');
document.write('                <TR>');
document.write('                    <TD BGCOLOR="#c7eafb" WIDTH="1"><IMG BORDER="0" ALT=" " HEIGHT="45" WIDTH="1" SRC="http://science-edu.larc.nasa.gov/common/spacer.gif"></TD>');
document.write('                    <TD WIDTH="19"><IMG BORDER="0" ALT="" HEIGHT="1" WIDTH="1" SRC="http://science-edu.larc.nasa.gov/common/spacer.gif"></TD>');
document.write('                    <TD BGCOLOR="#c7eafb" VALIGN="middle" ALIGN="right" HEIGHT="65" WIDTH="278">');
document.write('                        <TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">');
document.write('                            <TR>');
document.write('                                <TD ROWSPAN="2" WIDTH="30" ALIGN="right"><IMG BORDER="0" ALT="" HEIGHT="1" WIDTH="10" SRC="http://science-edu.larc.nasa.gov/common/spacer.gif"></TD>');
document.write('                                <TD COLSPAN="3">');
document.write('                                    <LABEL FOR="searchfield"><B><FONT SIZE="2">FIND IT @ NASA</FONT></B>');
document.write('                                </TD>');
document.write('                            </TR>');
document.write('                            <TR>');
document.write('                                <TD VALIGN="top" ALIGN="right">');
document.write('                                    <FONT SIZE="2" FACE="arial">');
document.write('                                        <FORM id="search" name="search" action="http://search.nasa.gov/nasasearch/search/search.jsp" method="get" target="search">');
//document.write('                                            <INPUT TYPE="hidden" NAME="boolean" VALUE="as a phrase" />');
document.write('                                            <INPUT id=searchfield title=searchfield name=nasaInclude SIZE="20" /><FONT SIZE="3">');

//document.write('                                        </FORM>');
document.write('                                    </FONT>');
document.write('                                <TD WIDTH="8"><IMG BORDER="0" ALT="" HEIGHT="1" WIDTH="5" SRC="http://science-edu.larc.nasa.gov/common/spacer.gif"></TD>');
//                                              <INPUT title=Go type=image height=20 alt=Go width=38 src="common/button_go.gif" border=0>
document.write('                                <TD VALIGN="middle"><INPUT title="Go" type="image" SRC="http://science-edu.larc.nasa.gov/common/button_go_C7EAFB.gif" WIDTH="38" HEIGHT="20" ALT="Go" BORDER="0"></TD>');
document.write('                                <TD WIDTH="8"><IMG BORDER="0" ALT="" HEIGHT="1" WIDTH="5" SRC="http://science-edu.larc.nasa.gov/common/spacer.gif"></TD>');
document.write('                            </TR>');
document.write('                                        </FORM>');
document.write('                        </TABLE>');
document.write('                    </TD>');
document.write('                </TR>');
document.write('            </TABLE>');
document.write('        </TD>');
document.write('    </TR>');
//document.write('    <TR>');
//document.write('        <TD COLSPAN="2" HEIGHT="2" BGCOLOR="#000000"></TD>');
//document.write('    </TR>');
document.write('</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');


