
/* on EVERY page */

	// unstick the fixed menu if window is short
function checkHeight () {
	if (!menuHite) {menuHite=550 }; // should have been set by php in <head>, but just in case
	// window.alert(menuHite);
	var hite=0;
	if (window.innerHeight) {
		hite = window.innerHeight;
	} else if( document.documentElement.clientHeight ) { // for IE7 or less
		if (ie6) { // IE6 or less excluded (var ie6 must be defined in <head>)
			hite = 0;
		} else {
			hite = document.documentElement.clientHeight;
		}
	}
	// If the visible page is more than enough to show the menu, it can be fixed
	// Short pages, or those who don't do javascript, get default of absolute (in stylesheet)
	if (hite>menuHite) { 
		document.getElementById('menuVW').style.position='fixed';
	}
}


// several little bits for Search Form(s)

	// most search fields trigger this onchange
function resetMost(){
	document.forms.SearchForm.sText.value = '';
	document.forms.searchForm.stk.value = '';
}

	// for Reset button
function resetForm(){
	document.forms.searchForm.authArt.value = '';
	document.forms.searchForm.titl.value = '';
	document.forms.searchForm.desc.value = '';
	document.forms.searchForm.datmin.value = '';
	document.forms.searchForm.datmax.value = '';
	document.forms.searchForm.stk.value = '';
}

	// stk field triggers this onchange
function resetStock(){
	document.forms.searchForm.authArt.value = '';
	document.forms.searchForm.titl.value = '';
	document.forms.searchForm.desc.value = '';
	document.forms.searchForm.datmin.value = '';
	document.forms.searchForm.datmax.value = '';
	document.forms.searchForm.sText.value = '';
}

	// sText field triggers this onchange
function resetKey(){
	if (document.forms.searchForm) { // searchForm doesn't always exist
		document.forms.searchForm.authArt.value = '';
		document.forms.searchForm.titl.value = '';
		document.forms.searchForm.desc.value = '';
		document.forms.searchForm.datmin.value = '';
		document.forms.searchForm.datmax.value = '';
		document.forms.searchForm.stk.value = '';
	};
}

	// disable/enable Sort selector
function toggleSort() {
	var meth = document.forms.searchForm.sMethod.value;
	if (meth==2) {
		document.getElementById('sortNOT').style.display = 'none';
		document.getElementById('sort').style.display = 'inline';
	}
	if (meth<2) {
		document.getElementById('sort').style.display = 'none';
		document.getElementById('sortNOT').style.display = 'inline';
		document.getElementById('sortNOT').disabled = 'disabled';
	}
}

	// dummy text for search fields
function focusSearchField( fieldName, defaultText  ) {
	var fld = document.getElementById(fieldName);
	fld.value = (fld.value==defaultText ? '' : fld.value);
	fld.style.fontStyle = 'normal';
	fld.style.color = '#000';
}
function blurSearchField( fieldName, defaultText  ) {
	var fld = document.getElementById(fieldName);
	fld.value = (fld.value=='' ? defaultText : fld.value);
	fld.style.fontStyle = (fld.value==defaultText ? 'italic' : 'normal');
	fld.style.color = (fld.value==defaultText ? '#9bb' : '#000');
}

	// check Contact form
function CheckData() {
	var valid = true ;
	var message = "Please complete the following details:";
	if (document.contactForm.email.value.length <6) {
		message = message + "\n" + "  your Email Address";
		document.contactForm.email.value = "***";
		document.contactForm.email.focus();
		valid = false;
	} else {
		emailCheck = document.contactForm.email.value
		AtPos = emailCheck.indexOf("@")
		StopPos = emailCheck.lastIndexOf(".")
		if (AtPos == -1 || StopPos == -1) {
			message = message + "\n" + "  your VALID Email Address"
			document.contactForm.email.focus();
			valid = false;
		}
	}
	if (document.contactForm.fullName.value.length <2 || document.contactForm.fullName.value=='***') {
		message = message + "\n" + "  your Name";
		document.contactForm.fullName.value = "***";
		document.contactForm.fullName.focus();
		valid = false;
	}
	if (document.contactForm.some.value !="s") {
		message = message + "\n" + "  the magic letter";
		document.contactForm.some.focus();
		valid = false;
	}

	if (valid == false) {
		window.alert (message);
	}
	return valid;
}
