

var path = "/header/";
var picArray = new Array(path+"home.jpg", path+"news.jpg", path+"menu.jpg", path+"guest_book.jpg", path+"merchandise.jpg", path+"gallery.jpg", path+"statistics.jpg",
							           path+"home_over.jpg", path+"news_over.jpg", path+"menu_over.jpg", path+"guest_book_over.jpg", path+"merchandise_over.jpg", path+"gallery_over.jpg", path+"statistics_over.jpg");


// Want to preload every image right after the .html page loads.
// The purpose is to have every image downloaded to the hard drive cache ahead of time,
// before any mouseover stuff goes on.  If the images are preloaded, then the mouseover
// stuff will look instantaneous and will already have the new image ahead of time.
var images = new Array();
function doPreLoad() {

		for(var loop = 0; loop < picArray.length; loop++)
		{
 			images[loop] = new Image();
			images[loop].src = picArray[loop];
    }

}


function change_header_image(id, pic_index, mouse_over) {
  if(mouse_over) {
  	document.getElementById(id).src = picArray[pic_index + 7];
  } else {
  	document.getElementById(id).src = picArray[pic_index];
  }
}


function is_numeric(val)
{
  digits="0123456789";

  for(i=0; i<val.length; i++) {
    if (digits.indexOf(val.charAt(i)) < 0) {
      alert("Value must be numeric. Use digits 0-9.")
      return false;
    }
  }

  if(val == '') {
    alert("Cannot leave this field blank.")
    return false;
  }

  return true;
}


function is_blank(str) {

	str = str.replace(/^\s+|\s+$/g,"");

  if(str == '') {
    alert('Cannot leave any fields blank.');
    return true;
  }
  else {
    return false;
  }
}


function is_valid_price(str)
{

  var objRegExp = new RegExp(/^((\d*)|(\d*\.\d{2})|(\d*)|(\d*\.\d{2}))$/);

  //check if string matches pattern
  
  if(objRegExp.test(str)) {
   return true;
  }
  else {
    alert('The dollar amount is not in the correct format.');
    return false;
  }
}
