// JavaScript Document

// The following controls the weather data display in the red nav bar
// constants
var weatherArrowNormal = "/images/arrows.gif";
var weatherArrowMouseover = "/images/arrows_ro.gif";
// variable
var weatherPos = 0;
// function to scroll through info
function nextWeatherItem() {
  var currentItem = document.getElementById("weather" + weatherPos);
  currentItem.style.visibility = "hidden";
  weatherPos = weatherPos + 1;
  var nextItem = document.getElementById("weather" + weatherPos);
  if ( nextItem == null ) {
    // start over at the beginning
    nextItem = document.getElementById("weather0");
    weatherPos = 0;
  } 
  nextItem.style.visibility = "visible";
}
// make sure we have weather info
function revealWeather() {
var nextItem = document.getElementById("weather" + weatherPos);
  if ( nextItem != null ) {
  // display next arrow
document.writeln(' <a href="javascript:nextWeatherItem();" onMouseOver="document.weatherArrow.src=weatherArrowMouseover;" onMouseOut="document.weatherArrow.src=weatherArrowNormal;"><img name="weatherArrow" src="/images/arrows.gif" alt="Weather Forecast for Alexandria" title="Weather Forecast for Alexandria" border="0" style="position: relative; top: 3px;"/></a>');
  // make current conditions visible
  nextItem.style.visibility = "visible";
}
}

//The following displays random table background images for the COA page header

var backgroundImages=new Array(6);
backgroundImages[0]="/images/header1_bg.jpg";
backgroundImages[1]="/images/header2_bg.jpg";
backgroundImages[2]="/images/header3_bg.jpg";
backgroundImages[3]="/images/rec-header1_bg.jpg";
backgroundImages[4]="/images/rec-header2_bg.jpg";
backgroundImages[5]="/images/rec-header3_bg.jpg";
onload=function(){
var e=(document.getElementById)?document.getElementById("myTableId"):(document.all)?document.all.myTableId:(document.layers)?document.myTableId:null;
if(!e)return true;
e.style.backgroundImage="url("+backgroundImages[Math.floor(Math.random()*backgroundImages.length)]+")";
}


//The following controls jump menus

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}



//The following passes the value of the search box to SearchPage.aspx
function checkKeycode() { 
var keycode; 
if (window.event) 
{ 
keycode = window.event.keyCode; 
if (keycode==13) 
{ 
if (document.getElementById('txtSearchText')!=null) 
CallSearch(); 
} 
} 
} 

document.onkeydown = checkKeycode; 

function CallSearch() 
{ 
var searchText = document.getElementById('txtSearchText').value;
if ( searchText == null ) { return false; } // nothing to do
  if ( (searchText == "") || (searchText == "Search alexandriava.gov") ) { 
    alert("Please enter a search term"); // give user feedback about why "GO" does nothing
    return false; 
  } 
//alert(searchText); 
document.location.href="/SearchPage.aspx?searchtext=" + escape(searchText) + "&folderid=0&searchfor=html&orderby=rank&orderdirection=ascending";
onload=document.form1.btnSearch.focus(); 
//Load the page with the websearch server control in the bottom frame using Javascript 
//Set websearch properties using querystring parameters 
//Properties set here- search text,Orderby, FolderId, and SearchFor 
//SearchFor can be a value from all/html/documents/images/multimedia/discussionForum 
//Orderby can be one of these - editor,id,rank,title,datecreated,datemodified 
//OrderDirection can be ascending or descending 
} 