function mouseOver(imgSelect) {
	var imgSrc = document.images[imgSelect].src
	document.images[imgSelect].src = imgSrc.replace(/-off/, "-over")
	return true
}
function mouseOut(imgSelect) {
	var imgSrc = document.images[imgSelect].src
	document.images[imgSelect].src = imgSrc.replace(/-over/, "-off")
	return true
}
function MouseOver2(image) {
  if(document.images && image.src.indexOf("-over.gif")==-1) {
    image.src = image.src.substring(0,(image.src.indexOf(".gif"))) + "-over.gif";
    }
}
function MouseOut2(image) {
  if(document.images && image.src.indexOf("-over.gif")!=-1) {
    image.src = image.src.substring(0,(image.src.indexOf("-over.gif"))) + ".gif";
    }
}
function openWindow(strPathToFile, strTitle, intWidth, intHeight, strScrollbars) {
	if (strScrollbars = '1') {
		theWindow = window.open(strPathToFile,strTitle,"width="+intWidth+",height="+intHeight+",scrollbars="+strScrollbars);
	} else {
		theWindow = window.open(strPathToFile,strTitle,"width="+intWidth+",height="+intHeight);
	}
	theWindow.focus();
}
function openSwfWindow(strPathToSWF,strWidth,strHeight) {
	movieWindow = window.open(strPathToSWF,"movie","width="+strWidth+",height="+strHeight);
	movieWindow.focus();
}
function centerWin(iCurrWidth,iCurrHeight){
	iMaxHeight = screen.availHeight;
	iMaxWidth = screen.availWidth;
	iXPos = ((iMaxWidth - iCurrWidth)/2);
	iYPos = ((iMaxHeight - iCurrHeight)/2) ;
	window.moveTo(iXPos,iYPos);
	window.focus();
}
function openWin(URL,winName,iWidth,iHeight) { 
	iMaxHeight = screen.availHeight;
	iMaxWidth = screen.availWidth;
	if (isNaN(iMaxHeight)) {
		iXPos = 150;
		iYPos = 150;
	} else {
		iXPos = ((iMaxWidth - iWidth)/2);
		iYPos = ((iMaxHeight - iHeight)/2) + 41;
	}
	
	strfeatures = 'width=' + iWidth + ',height=' + iHeight;
	myWin = window.open(URL,winName,strfeatures);
	myWin.moveTo(iXPos,iYPos);
	myWin.focus();
}
function alertBox(strMessage) {
	var iHeight = 25;
	for (var x = 0; x < strMessage.split('\n').length; x++) {
		iHeight += 30
	}
	openWin('/jmlcat.nsf/alertbox?OpenForm&error=' + escape(strMessage.split('\n').join('<BR>')), 'alert', 335, iHeight);
}
function addToBag() {
	var formRef = document.cart;
	var iErrors = 0;
	var strErrMsg = '';
	var ErrMsg = '';
	var count = 0;
	var tst1=0
	var tst2=0;
	if (isNaN(parseInt(formRef.qty.length))) {
		if (formRef.qty.value != '') {
			if (parseInt(formRef.qty.value) > 0){
			//	tst1 = 1+ parseInt(formRef.qty.value);
			//	tst2 = 1+ parseInt(formRef.stk.value);
			//	if (tst1 > tst2){
			//		iErrors++;
			//		ErrMsg=formRef.bdesc.value+' - '+formRef.qty.value+' ordered, '+
			//				formRef.stk.value+' available\n';
			//	}
				count += parseInt(formRef.qty.value)
			}
		}
	} else {
		for (var x = 0; x < formRef.qty.length; x++) {
			if (formRef.qty[x].value != '') {
				if (parseInt(formRef.qty[x].value) > 0){
				//	tst1 = 1 + parseInt(formRef.qty[x].value);
				//	tst2 = 1 + parseInt(formRef.stk[x].value);
				//	if (tst1 > tst2){
				//		iErrors++;
				//		ErrMsg+=formRef.bdesc[x].value+' - '+formRef.qty[x].value+' ordered, '+
				//			formRef.stk[x].value+' available\n';
				//	}
					count += parseInt(formRef.qty[x].value)
				}
			}
		}
	
	}	
	if ((count <= 0) || (isNaN(count))) {
		iErrors++;
		strErrMsg = strErrMsg + 'Please enter a quantity in order to add a product to your Shopping Bag.\n';
	}else{
		strErrMsg="We cannot fulfil this order:\n" + ErrMsg;
	}
	if (iErrors > 0) {
		alertBox(strErrMsg);
		return false;
	} else {
		formRef.submit();
		return true;
	}
}
function gotoCheckout() {
location.href="/jmlcat.nsf/shop/payment/shopbag?readform&cartid="+document.cart.cartid.value;
}
function printPage() {
	window.print();
}
var blnFollowLinks = true;
function followLink(strUrl) {
	if (blnFollowLinks) {
		location.href = strUrl;
		return true
	} else {
		openWin('/jmlcat.nsf/confirmbox?OpenForm&url=' + escape(strUrl), 'confirm', 335, 135);
		return false;
	}
}
var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1); 
function PrintTheseDetails(frame, arg) {
	if (frame == window) {
		printThis();
	} else {
		link = arg; // a global variable 
		printFrame(frame);
	}
	return false;
}
function printThis() {
	if (pr) { // NS4, IE5
		window.print();
	} else if (da && !mac) { // IE4 (Windows)
		vbPrintPage();
	} else { // other browsers
		alert("Sorry, your browser doesn't support this feature.\n\n Please try using the Print button on the browser toolbar.");
	}
}
function printFrame(frame) {
	if (pr && da) { // IE5
		frame.focus();
		window.print();
		link.focus();
	} else if (pr) { // NS4
		frame.print();
	} else if (da && !mac) { // IE4 (Windows)
		frame.focus();
		setTimeout("vbPrintPage(); link.focus();", 100);
	} else { // other browsers
		alert("Sorry, your browser doesn't support this feature.\n\n Please try using the Print button on the browser toolbar.");
	}
}
if (da && !pr && !mac) with (document) {
	writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
	writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
	writeln('Sub window_onunload');
	writeln('  On Error Resume Next');
	writeln('  Set WB = nothing');
	writeln('End Sub');
	writeln('Sub vbPrintPage');
	writeln('  OLECMDID_PRINT = 6');
	writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
	writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
	writeln('  On Error Resume Next');
	writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
	writeln('End Sub');
	writeln('<' + '/SCRIPT>');
}
function alertBox2(strMessage,heightOffset) {
	var iHeight = heightOffset;
	if (strMessage.split('\n').length > 3) {
		iHeight += 115;
	}
	
	openWin('/jmlcat.nsf/alertbox?OpenForm&error=' + escape(strMessage.split('\n').join('<BR>')), 'alert', 335, iHeight);
}
// Return a reference to a given element within the document
function getDocElement(oObjectID)
{
	var oObject	= null;
	
	// Need specific code for 5+ browsers
	if(document.getElementById)
	{
		oObject	= document.getElementById(oObjectID).style;
	}
	else
	{
		oObject	= eval("document."+ coll + oObjectID + styleobj);
	}
	
	return oObject;
}
function getDHTMLObj(oObjectID)
{
	var oObject	= null;
	
	// Need specific code for 5+ browsers
	if(parseInt(navigator.appVersion,10) >= 5)
	//if(document.getElementById())
	{
		oObject	= document.getElementById(oObjectID);
	}
	else
	{
		oObject	= eval("document."+ coll + oObjectID);
	}
	
	return oObject;
}
//Utility function sets the visibility of an object to visible
function show(obj)
{
	obj.visibility	= "visible";
}
//Utility function sets the visibility of an object to hidden
function hide(obj)
{
	obj.visibility	= "hidden";
}
//Utility function to provide left position on page
function getPageLeft(obj)
{
	return obj.offsetLeft;
}
//Utility function to provide top position on page
function getPageTop(obj)
{
	return obj.offsetTop;
}
