var script_path = '/cgi-perl/browse.fcgi';

var newWindow;
function openWindow(ahtmlpath) {
	newWindow = window.open(ahtmlpath, "myWindow", "resizable=yes,scrollbars=yes,width=400,height=300")
	if (navigator.appName.indexOf("Netscape") != -1) {
		//newWindow.window.focus();
	} else if (navigator.appVersion.indexOf("5") != -1) {
		//newWindow.window.focus();
	}
}

function v_num ( whichbox ) {
	if (isNaN(whichbox.value)) {
		if (!whichbox.priorval) whichbox.priorval = 1;
		whichbox.value = whichbox.priorval;
		whichbox.focus();
	} else {
		whichbox.priorval = whichbox.value;
	}
}

function add2list ( product_id ) {
	var qty = 1;
	if (document.catalog_list) {
		eval ("qty = document.catalog_list.qty_" + product_id + ".value;") 
	}
	top.list.location.href = script_path + '?list=add&item=' + product_id + '&qty=' + qty;
}

function reloadOrderList ( ) {
	top.list.location.href = script_path + '?list=1';
}

function updatePromoCats  (location) {
	document.location = location;
}

function testForEnter( theform ) {
	if (window.event && window.event.keyCode == 13) {
		window.event.cancelBubble = true;
		window.event.returnValue = false;
		updateList( theform );
	}
}

function killEnter( theform ) {
	if (window.event && window.event.keyCode == 13) {
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	}
}

function verifyClear( theform ) {
	var x = confirm("Are you sure you want to clear the list?")
	if (x) {
		theform.list.value = 'Clear List';
		theform.submit();
	}
}

function multipleItemAdd( theform ) {
	theform.multiple_item_search_action.value = 'add';
	theform.submit();
}

function updateList( theform ) {
	theform.list.value = 'Update List';
	theform.submit();
}

function checkEmailListForm(theform) {
	if (navigator.appName == "Netscape" || navigator.appName == "Microsoft Internet Explorer") {
		if (window.event && window.event.keyCode == 13) {
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
	}
	if (theform.from_name.value == '') {
		alert("You must provide a name.");
	} else if (theform.from_email.value == '') {
		alert("You must provide an E-mail address.");
	} else {
		if (window.confirm("Go ahead and mail this list?")) {
			theform.submit();
		}
	}
}
