function ChangeImage(strName, strSource) {
	document.images[strName].src = strSource;
}

function PreloadImages() {
	var objArgs = PreloadImages.arguments;
	var objImg = new Image;
	for (var intCount = 0; intCount < objArgs.length; intCount++) {
		objImg.src = objArgs[intCount];
	}
}
function BarcodeToISBN(strBC) {
	if (strBC.length == 13) {
		var strISBN = strBC.substr(3, 9);
		if (!isNaN(strISBN)) {
			var intX = 10;
			var intC = 0;
			var intCheck = 0;
			for (intX = 10; intX >= 2; intX--) {
				intCheck = intCheck + (parseInt(strISBN.substring(intC, intC + 1)) * intX);
				intC++;
			}
			intCheck = 11 - (intCheck % 11);
			alert('11 - (' + intCheck + '% 11) = ' + intCheck)
			if (intCheck == 11) {
				strISBN = strISBN + '0';
			}
			else if (intCheck == 10) {
				strISBN = strISBN + 'X';
			}
			else {
				strISBN = strISBN + intCheck.toString();
			}
			return strISBN;
		}
		else return strBC
	}
	else return strBC
}

function SubmitBarcode(strForm, strField) {
	if (document.forms[strForm]) {
		var objForm = document.forms[strForm];
		if (objForm[strField]) {
			var strBC = objForm[strField].value;
			var strISBN = BarcodeToISBN(strBC);
			objForm[strField].value = strISBN;
		}
	}
}

function Popup(strURL, strName, intWidth, intHeight) {
	if (!strURL) {
		alert('A URL must be specfied when using the Popup function.')
	}
	else {
		if (!strName) { strName = 'popup' }
		if (!intWidth) { intWidth = 600 }
		if (!intHeight) { intHeight = 400 }
		var objWindow = window.open(strURL, strName, 'width=' + intWidth + ',height=' + intHeight + ',scrollbars=yes,resizable=yes,toolbar=no,status=yes');
		objWindow.focus()
	}
}

function Popdown(strURL, blnLeaveOpen) {
	if (!strURL) {
		alert('A link must be specified when using the Popdown function.');
	}
	else {
		if (top.opener) {
			var objParent = top.opener;
			objParent.location.href = strURL;
			if (!blnLeaveOpen) {
				objParent.focus();
				top.close();
			}
		}
		else {
			alert('Unfortunately the link could not be followed.\nThe window that opened this page may have\nbeen closed, or your browser may not\nsupport this function.');
		}
	}
}

