/**********************************************************
* SFX (tm) Searchable A-Z common javascript file.
* Copyright Ex Libris, Inc.
* Version: $Id: common.js,v 1.3 2007/11/01 15:44:58 dz_3 Exp $
***********************************************************/

var recordDisplayed = null;

//---------------------------------------------------------
function OpenWindow(url,winname,w,h,needChild) {
//---------------------------------------------------------
// Standard function for opening an sfx menu window
//---------------------------------------------------------
    if (typeof winname == 'undefined' || ! winname.length) winname = 'openwin';
    if (typeof url     == 'undefined' || ! url.length) url = '';
    var child;
    if (!w && !h){
        child = window.open(url,winname,'width=700,height=500,scrollbars=yes,resizable=yes');
    }else{
        child = window.open(url,winname,"width="+w+",height="+h);
    }
    child.focus();
    if (needChild) return child;
}

//---------------------------------------------------------
function gotoPage(pageNumber,perform_tab) {
//---------------------------------------------------------
// Resubmits the query but first specifies the desired page
// number.
//---------------------------------------------------------
	if (perform_tab == 'searchCategories') {
		document.az_result_form.perform.value = 'searchCategories';
	}
	else if (perform_tab == 'locate') {
		document.az_result_form.perform.value = 'locate';
	}
    if (pageNumber) {
        document.az_result_form.jumpToPage.value = pageNumber;
    }
    if (!document.az_result_form.jumpToPage.value) {
        alert('No page number specified.');
    }
    else {
        if (!IsNumeric(document.az_result_form.jumpToPage.value)) {
            alert('Page number is invalid.');
            document.az_result_form.jumpToPage.value = 1;
        }
        if (document.az_result_form.current_view) {
             document.az_result_form.current_view.value =  document.az_user_form.current_view.value;
        }
        //alert ("gotoPage");
        document.az_result_form.submit();
    }
}

//---------------------------------------------------------
function IsNumeric(sText) {
//---------------------------------------------------------
// This function checks whether the entered page number is
// numeric or not.
//---------------------------------------------------------
   var ValidChars = "0123456789";
   var Char;

   for (i = 0; i < sText.length; i++) {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1) {
         return false;
      }
   }
   return true;
}

function unSelectAll(combo) {
	for (var i=0; i < combo.options.length; i++) {
		combo.options[i].selected = false;
	}
}

//---------------------------------------------------------
// This function generates HTML for Go Button
//---------------------------------------------------------
function go_button(caption){
	return '<table border="0" cellspacing="0" cellpadding="0" style="cursor: pointer" onclick="document.forms.az_user_form.submit()">' +
'        <tr>'+
'          <td><img src="/sfx_local/img/azlist_ver3/go.jpg" title="Go" alt="Go" border="0" width="36" height="36"></td>' +
'        </tr>'+
'      </table>';
}
