<!--
document.onkeypress =
  function (evt) {
    var c = document.layers ? evt.which
            : document.all ? event.keyCode
            : evt.keyCode;

    if (c == 13) {
    	if (document.frmHeader.txt_search.value != '') doSearch();
    }

    return true;
  };

if (document.layers)
  document.captureEvents(Event.KEYPRESS);



/* 
 * name: openWindow(url, width, height)
 * purpose: open a child window with a given url, width, and height.
 * 	    no toolbars, scrollbars, menubar, location bar, etc.
 */

function openWin(url, name, width, height) {
 var features = 'width='+width+',height='+height+','+
                'resizable=no,scrollbars=no,toolbar=no,'+
                'location=no,menubar=no,directories=no';
            
 winChild = window.open(url, name, features);
 return;
}


/* 
 * name: doMakeUpdate()
 * purpose: onClick event for 'update' button - new make popup window
 */
function doMakeUpdate(){

 var f = document.frmMakeUpdate;
 var make = f.txt_make_name.value;
 
 // check for empty expression
 if (make != '') {
   if(confirm('You are adding the make: ' + make))
      f.submit();
   else
    return;
 }
 else
   alert('Please enter a new make or press cancel to quit.');

}

/* 
 * name: selectMakeID(makeID)
 * purpose: loop through a drop down list boxes options searching for a particular value.
 *          if it's found, select that option.
 */
function selectMakeID(makeID)
{
 var dd = document.frmMuseum.dd_make;

 for (i=0; i<dd.length; i++)
 {
   if (dd.options[i].value == makeID)
   {
     dd.options[i].selected=true;
	 return;
   }
 }
}

function doLogin(){
 
 var f = document.frmLogin;
 
 var un = f.un.value;
 
 var pw = f.pw.value;
 
 alert('un: '+un+'\n'+'pw: '+pw); 
 
 return;

}

function doLogout(){
 
 window.top.location="index.html";

 return;

}


/* 
 * name: doSearch()
 * purpose: onClick event for 'search' button. 
 */
function doSearch()
{

 var f = document.frmHeader;
 
 var it = f.txt_search.value;

 if (it==null || it == '') return;
 
 // replace whitespace with plus signs
 
 var url = 'browse.php?mode=search&era=search&pid=1&q='+it;

 window.top.hidden.location = url;

 return;

}

function doDelete()
{

 var f = document.frmMuseum;

 var model = f.txt_model.value;

 var era = f.era.value;
 
 if (confirm('You\'re about to delete the model, '+model+' from the online collection.\n Press OK to proceed.'))

    alert('record will be deleted [under construction].');

 return;

}

function doSave()
{
 
 var f = document.frmMuseum;

 var model = f.model.value;

 //var make = f.txt_make.value;
 
 var ind = f.dd_make.selectedIndex;
 
 var make = f.dd_make.options[ind].value;
 
 f.makeid.value = make;
 
 var make_name  = f.dd_make.options[ind].text;
 
 //var len = f.dd_make.length
 
 //for(i=0; i<len; i++) {
 //  if (f.dd_make.options[i].
 //}

 var file = f.img.value;

 //if (file=='') file = '[use current image]';

 var notes = f.notes.value;
 
 if(confirm('Are you sure about this? \n\nmodel: ' + model + '\nmake: ' + make_name + '\nfile: ' + file + '\nnotes: ' + notes + '\n'))

   f.submit();

 else

   alert('alright then.');

 return;

}

function sendEmail()
{

 var f = document.frmContact;
 
 var name = f.mname.value;
 
 var email = f.memail.value;
 
 var subject = f.msubject.value;
 
 var message = f.mmessage.value;
 
 var strConfirm = "You are about to record the following message:\nname: "+name+"\nemail: "+email+"\nsubject: "+subject+"\nmessage: "+message;

 if (confirm(strConfirm))
    f.submit();

 return;

}

function clearForm()
{

 var img_temp = new Image;

 img_temp.src="images/txt_image_not_available.gif";

 var f = document.frmMuseum;
 
 f.txt_model.value = '';

 //f.txt_make.value = '';

 //f.img_file.value = '';

 f.txt_notes.value = '';

 f.txt_model.focus();
 
 document.images['img_board'].src = img_temp.src;

 return;

}

//-->