// *******************************************************************
function Zoom(p) { 
   var url = "zoom.asp?photo=" + p + "";	
   popup = window.open(url, "zoom", "scrollbars=no top=25 left=30");
   if (window.focus) { popup.focus() }
}
// *******************************************************************
function Coupon(p) { 
   var url = "Coupon.asp?coupon=" + p + "";
   popup = window.open(url, "coupon", "scrollbars=no top=25 left=50");
   if (window.focus) { popup.focus() }
}
// *******************************************************************
function ResizeWindow(obj) {
   var w = obj.clientWidth + 50;
   var h = obj.clientHeight + 120;
   if (w > screen.width) { zoomBody.scroll= "Yes"; w  = screen.width - 60; }
   if (h > screen.height) { zoomBody.scroll= "Yes"; h = screen.height - 100; }
   window.resizeTo(w, h);
}
// *******************************************************************
function SubmitPage(page) {
document.forms[0].action = page;
document.forms[0].submit();
}
//********************************************************************
//** functions:	checkField
//** parms: 	obj 	(control object, Required)
//**			nam		(reference name)
//**			typ		(alpha/numeric/date/radio Required)
//**			req		(yes/no, Required)
//**			bot		(Minimum Value, Optional)
//**			top		(Maximum Value, Optional)
//**			inc		(Increment Value, Optional)
//********************************************************************
var good = false;
var bad = true;
//********************************************************************
function checkField(objId, nam, typ, req, bot, top, inc) {
typ = LCase(typ);
req = LCase(req);
if (typ == "radio") {
   return checkRadio(objId, nam, typ, req, bot, top, inc); }
var obj = document.getElementById(objId);
if (Len(obj.value) == 0) {
if (req == "yes") {
   alert(nam + " is required.");
   obj.focus();
   return bad; }
else {
   return good; } }
if (typ == "alpha") {
   return checkAlpha(obj, nam, typ, req, bot, top, inc); }
if (typ == "numeric")	{
   return checkNumeric(obj, nam, typ, req, bot, top, inc); }
if (typ == "date") {
   return checkDate(obj, nam, typ, req, bot, top, inc); }
if (typ == "phone") {
   return checkPhone(obj, nam, typ, req, bot, top, inc); }
if (typ == "email") {
   return checkEmail(obj, nam, typ, req, bot, top, inc); }
return good;
}
//********************************************************************
function checkAlpha(obj, nam, typ, req, bot, top, inc) {
if (!IsEmpty(bot)) {
if (Len(obj.value) < bot) {
   alert(nam + " must be at least " + bot + " characters long.");
   obj.focus();
   return bad; } }
if (!IsEmpty(top)) {
if (Len(obj.value) > top) {
   alert(nam + " must be less than " + top + " characters.");
   obj.focus();
   return bad; } }
return good;
}
//********************************************************************
function checkNumeric(obj, nam, typ, req, bot, top, inc) {
if (!IsNumeric(obj.value)) {
   alert(nam + " must be numeric.");
   obj.focus();
   return bad;	}
if (!IsEmpty(bot)) {
if (parseFloat(obj.value) < parseFloat(bot)) {
   alert(nam + " must be greater than or equal to " + bot + ".");
   obj.focus();
   return bad; } }
if (!IsEmpty(top)) {
if (parseFloat(obj.value) > parseFloat(top)) {
   alert(nam + " must be less than or equal to " + top + ".");
   obj.focus();
   return bad; } }
if (!IsEmpty(inc)) {
if (parseInt(obj.value)%parseInt(inc) != 0) {
   alert(nam + " must be an increment of " + inc + ".");
   obj.focus();
   return bad; } }
return good;
}
//********************************************************************
function checkDate(obj, nam, typ, req, bot, top, inc) {
if (!IsDate(obj.value)) {
   alert(nam + " must be a valid date (mm/dd/yyyy).");
   obj.focus();
   return bad; }
if (!IsEmpty(bot)) {
if (!IsDate(bot)) { bot = eval("CalcDate(" + bot + ")"); }
if (Date.parse(obj.value) < Date.parse(bot)) {
   alert(nam + " must be greater than or equal to " + bot + ".");
   obj.focus();
   return bad; } }
if (!IsEmpty(top)) {
if (!IsDate(top)) { top = eval("CalcDate(" + top + ")"); }
if (Date.parse(obj.value) > Date.parse(top)) {
   alert(nam + " must be less than or equal to " + top + ".");
   obj.focus();
   return bad; } }
return good;
}
//********************************************************************
function checkPhone(obj, nam, typ, req, bot, top, inc) {
if (!IsPhone(obj.value)) {
   alert(nam + " must be a valid phone number with area code.\n\n999-999-9999 or (999) 999-9999");
   obj.focus();
   return bad; }
return good;
}
//********************************************************************
function checkEmail(obj, nam, typ, req, bot, top, inc) {
if (!IsEmail(obj.value)) {
   alert(nam + " must be a valid Email Address.");
   obj.focus();
   return bad; }
return good;
}
//********************************************************************
function checkRadio(objId, nam, typ, req, bot, top, inc) {
var objects = document.getElementsByName(objId);
for (var i = 0; i < objects.length; i++) {
   if (objects[i].checked) { return good; } }
alert ("You must make a selection for " + nam + ".");
objects[0].focus();
return bad;
}
//********************************************************************
//**  General Functions
//********************************************************************
function LCase(Value) {
return Value.toString().toLowerCase();
}
function UCase(Value) {
return Value.toString().toUpperCase();
}
function Len(Expression) {
return Expression.toString().length;
}
function IsEmpty(Expression) {
return (Expression.toString().length == 0);
}
function IsNumeric(Expression) { 
return !isNaN(parseInt(Expression)); 
}
function IsDate(Expression) {
var objRegExp = /^\d{1,2}\/\d{1,2}\/\d{4}$/;
if(!objRegExp.test(Expression)) { return false; }
var mmddyyyy = new Date(Date.parse(Expression));
if (isNaN(mmddyyyy.getYear())) { return false; }
var dateArray = Expression.split("/");
if (dateArray.length != 3) { return false; }
if (dateArray[0] != mmddyyyy.getMonth() + 1) { return false; }
if (dateArray[1] != mmddyyyy.getDate()) { return false; }
if (dateArray[2] != mmddyyyy.getFullYear()) { return false; }
return true;
}
function CalcDate(m,d,y) {
var result = "";
var myDate = new Date();
y += myDate.getFullYear();
myDate.setFullYear(y);
m += myDate.getMonth();
myDate.setMonth(m);
d += myDate.getDate();
myDate.setDate(d);
result += (myDate.getMonth() + 1);
result += "/" + myDate.getDate();
result += "/" + myDate.getFullYear();
return result;
}
function IsEmail(Expression) {
var emailFilter = /(\w[-._\w]*\w@\w[-._\w]*\w\.\w{2,3})/;
var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
if (!(emailFilter.test(Expression))) { return false; }
if ((illegalChars.test(Expression))) { return false; }
return true;
}
function IsPhone(Expression) {
var phoneFilter = /^1?\s*-?\s*(\d{3}|\(\s*\d{3}\s*\))\s*-?\s*\d{3}\s*-?\s*\d{4}$/;
if (!(phoneFilter.test(Expression))) { return false; }
return true;
}
//********************************************************************
