if (document.images) {
  
  imageadvon = new Image();
  imageadvon.src="/images/header/advanced_on.gif";
  
  image1on = new Image();
  image1on.src="/images/header/nav_trade_on.gif";

  image2on = new Image();
  image2on.src="/images/header/nav_children_on.gif";
  
  image3on = new Image();
  image3on.src="/images/header/nav_future_on.gif";

  image4on = new Image();
  image4on.src="/images/header/nav_authors_on.gif";

  image5on = new Image();
  image5on.src="/images/header/nav_reading_on.gif";  

  image6on = new Image();
  image6on.src="/images/header/nav_catalogs_on.gif"; 
  
  imageadvoff = new Image();
  imageadvoff.src="/images/header/advanced_off.gif";  
  
  image1off = new Image();
  image1off.src="/images/header/nav_trade_off.gif";
  
  image2off = new Image();
  image2off.src="/images/header/nav_children_off.gif";

  image3off = new Image();
  image3off.src="/images/header/nav_future_off.gif";

  image4off = new Image();
  image4off.src="/images/header/nav_authors_off.gif";

  image5off = new Image();
  image5off.src="/images/header/nav_reading_off.gif";

  image6off = new Image();
  image6off.src="/images/header/nav_catalogs_off.gif";
  
  }

function isEmpty(strValue){   
     return ((strValue == null) || (strValue.length == 0))
}

function isAllSpaces(strValue){
    var allspaces = " \t\n\r";
    var i;
    
    if (isEmpty(strValue)) return true;

    for (i = 0; i < strValue.length; i++) {   
        var ch = strValue.charAt(i);
        if (allspaces.indexOf(ch) == -1) return false;
    }
    return true;
}

function stripCharacters(strValue, strRemove) {
	var strReturnValue = '';
	var i;
	for (i = 0; i < strValue.length; i++) {
		var ch = strValue.charAt(i);
		if  (strRemove.indexOf(ch) == -1) strReturnValue += ch;
	}
	return strReturnValue;
}

function isISBN(strValue) {            
  var blnResult = false;
  //var rexISBNpattern = /(^\d{9}\w{1}$)|(^\d{1}\-\d{2}\-\d{6}\-\w{1}$)/;
  var rexISBNpattern = /(^\d{9}[0-9A-Za-z]{1}$)|(^\d{1}\-\d{2}\-\d{6}\-[0-9A-Za-z]{1}$)/;
  if  (strValue.match(rexISBNpattern))
      blnResult = true;

  return blnResult;
}

function SubmitSimpleForm(){
	var strMessage      = 'The search value is empty';
	var strCriteria     = document.forms['frmSimpleSearch'].q.value;
	var intSelected     = document.forms['frmSimpleSearch'].sf.selectedIndex;
	var strSearchField  = document.forms['frmSimpleSearch'].sf.options[intSelected].value;
	var strSort = '';
		
	//document.forms['frmSimpleSearch'].hdnDisplayCriteria.value = strCriteria;
	
	if (isAllSpaces(strCriteria)){
	   alert(strMessage);
	   document.forms['frmSimpleSearch'].q.focus();
	   return false;
	}

	if (strSearchField == 'isbn') {
	     //if (!isISBN(strCriteria)) 
	     //{
	     //   alert('Invalid ISBN value');
	     //   document.forms['frmSimpleSearch'].q.focus();
	     //   return false;
	     //}
	     //else {
	           strCriteria = stripCharacters(strCriteria,'-');
	     //}
	}   
    
    /*
    strSort = '';
        
    var rexSortInAction = /st/ig
          
    if  (! strAction.match(rexSortInAction)) {
		switch(strSearchField){
		  case 'Title': strSort = '&st=Title'; break;
		  case 'Author': strSort = '&st=Author'; break;
		  case 'ISBN': strSort = '&st=ISBN'; break;
		  default: strSort = '&st=Title'; break;
		}
    }
	*/
	
	//document.forms['frmSimpleSearch'].hdnSearchCriteria.value = strCriteria;
//    document.frmSimpleSearch.action = '\\booksearch\\search_results.asp';
    document.frmSimpleSearch.action = '/booksearch/search_results.asp';
	// ADDED BY SPH 6/10/2008 for testing
//    document.frmSimpleSearch.action = '/booksearch/search_results_test.asp';
	document.frmSimpleSearch.submit();
}

function PrintCurrentDate() {
var months=new Array(13);
months[1]="January";
months[2]="February";
months[3]="March";
months[4]="April";
months[5]="May";
months[6]="June";
months[7]="July";
months[8]="August";
months[9]="September";
months[10]="October";
months[11]="November";
months[12]="December";
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getFullYear();
var year1=time.getYear();
if ((navigator.appName == "Microsoft Internet Explorer") && (year < 2000))
year="19" + year;
if (navigator.appName == "Netscape")
year= year;
if(navigator.appName.indexOf("WebTV") != -1)
year=year1;
document.write(lmonth + " ");
document.write(date + ", " + year );
}

function turnOn(imageName) {

  if (document.images) {

    document[imageName].src = eval(imageName + "on.src");

  }

}

function turnOff(imageName) {

  if (document.images) {

    document[imageName].src = eval(imageName + "off.src");

  }

}

function popUp(url) {
	playerWindow=window.open(url,'Player','height=350,width=350');
	if (window.focus) {playerWindow.focus()}
}
