function set_default_button()
{
	var floop,eloop,found;
	
	found = false;
	for(floop = 0;(!found) && (floop < document.forms.length);floop++)
	{
		for(eloop = 0;(!found) && (eloop < document.forms[floop].elements.length);eloop++)
		{
			if(document.forms[floop].elements[eloop].type == 'submit')
			{
				document.forms[floop].elements[eloop].focus();
				found = true;
			}
		}
	}
	for(floop = 0;(!found) && (floop < document.forms.length);floop++)
	{
		for(eloop = 0;(!found) && (eloop < document.forms[floop].elements.length);eloop++)
		{
			if(document.forms[floop].elements[eloop].type == 'button')
			{
				document.forms[floop].elements[eloop].focus();
				found = true;
			}
		}
	}
}
function openWin(url,name,restrict,height,width,top,left)
{
	var params = restrict?'resizable=yes,menubar=no,scrollbars=yes,toolbar=no,location=no,status=yes,directories=no':'';
	if(height > 0)	{	params += ',height='+height;	}
	if(width > 0)	{	params += ',width='+width;	}
	if(top > 0)	{	params += ',top='+top;	}
	if(left > 0)	{	params += ',left='+left;	}
	remote=window.open(url,name,params);
	if (remote.opener == null)	{	remote.opener = self;	}
	return false;
}
function openHelp()	{	openWin('/help/index.cfm?helpareaid='+selected,'helpWindow',true,490,600,50,50);	}
function openCopyright()	{	openWin('/copyright.cfm','copyrightWindow',true,490,600,50,50);	}
function openebooks()	{	openWin('http://dawson.etailer.dpsl.net/','ebooksWindow',false,0,0,0,0);	}
function logout()
{
	if(orderexists && confirm("You currently have unconfirmed orders.\nPlease click 'OK' to view these orders or 'Cancel' to log off"))
		{	self.location.replace("/batch/body.cfm") ;	}
	else	
		{	self.location.replace("/logout.cfm") ;	}
	return false;
}
function Validate_ISBN(field) {
	var err = '',base = '';
	var checktotal = 0;
	var checklength = 0
	var checkdigit = '';
	var checkmod = 0;
	var weights,modval,digits;
	field.value = field.value.replace(/[ \-]/g,"");
	var isbn = field.value;
	if (isbn.length == 0) {	return true;	}
	if (isbn.length != 10 && isbn.length != 13) {
		err = '\nISBN must be 10 or 13 characters.';
	} else {
		if (isbn.length == 10) {
			weights = new Array(10,9,8,7,6,5,4,3,2);
			modval = 11;
			digits = new Array(0,'X',9,8,7,6,5,4,3,2,1);
		} else {
			weights = new Array(1,3,1,3,1,3,1,3,1,3,1,3);
			modval = 10;
			digits = new Array(0,9,8,7,6,5,4,3,2,1);
		}
		base = isbn.substr(0,(isbn.length - 1));
		if(base.search('/[^0-9]/') >= 0) {
			err = '\nThe first ' + base + ' characters of an ISBN must be numerical.';
		} else {
			checklength = base.length
			for(i=0;i < checklength;i++) {
				checktotal += parseInt(isbn.substr(i,1)) * weights[i];
			}
			checkmod = checktotal % modval;
			checkdigit = digits[checkmod];
			if(checkdigit != isbn.substr((isbn.length - 1),1).toUpperCase()) {
				err = 'The ISBN check Code digit for this entry is wrong!\n';
			}
		}
	}
//	alert('['+isbn+']['+base+']['+checklength+']['+checktotal+']['+checkmod+']['+checkdigit+']['+isbn.substr((isbn.length - 1),1)+']');
	if(err.length) {
		alert(err);
		field.select();
		field.focus();
		return false;
	}
	return true;
}