function popupimage(filename) {
	doPopUpWindow = window.open("/popup_larger.php?file="+filename,"popupImage","scrollbars=yes,resizable=yes,left=50,top=50,screenX=50,screenY=50,width=600,height=600");
}

/*
from http://www.alistapart.com/articles/popuplinks/
*/

//var _POPUP_FEATURES = 'location=0, statusbar=0, menubar=0, width=400, height=300';
var _POPUP_FEATURES = '';

function raw_popup(url, target, features) {
	if (isUndefined(features)) {
		features = _POPUP_FEATURES;
	}
	if (isUndefined(target)) {
		target = '_blank';
	}
	var theWindow = window.open(url, target, features);
	theWindow.focus();
	return theWindow;
}

function link_popup(src, features) {
	return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);
}

function isUndefined(v) {
	var undef;
	return v===undef;
}

/* OTHER FUNCTIONS */
function validateQuickOrder(theForm) {
	if(!IsNumeric(theForm.Product_Code.value.substr(0,3))) {
		alert("RDN product codes begin with 3 digits and then a dash, followed by letters and numbers. Please review your product code and try again.");
		theForm.Product_Code.focus();
		return false;
	}
	if(theForm.Product_Code.value.substr(3,1) != '-') {
		alert("KaTom product codes begin with 3 digits and then a dash, followed by letters and numbers. Please review your product code and try again.");
		theForm.Product_Code.focus();
		return false;
	}
	if(theForm.Product_Code.value.length < 5) {
		alert("KaTom product codes begin with 3 digits and then a dash, followed by letters and numbers. Please review your product code and try again.");
		theForm.Product_Code.focus();
		return false;
	}
	if(!IsAlphaNumeric(theForm.Product_Code.value.substr(4))) {
		alert("KaTom product codes begin with 3 digits and then a dash, followed by letters and numbers. Please review your product code and try again.");
		theForm.Product_Code.focus();
		return false;
	}
}

function IsNumeric(sText) {
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;

	for (i = 0; i < sText.length && IsNumber == true; i++) {
		Char = sText.charAt(i);
		if (ValidChars.indexOf(Char) == -1) {
			IsNumber = false;
		}
	}
	return IsNumber;
}

function IsAlphaNumeric(sText) {
	var ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.";
	var IsAlphaNum=true;
	var Char;

	for (i = 0; i < sText.length && IsAlphaNum == true; i++) {
		Char = sText.charAt(i);
		if (ValidChars.indexOf(Char) == -1) {
			IsAlphaNum = false;
		}
	}
	return IsAlphaNum;
}
