function calc()
{
	sub_total = parseFloat(calc_standard() + calc_demo() + calc_pro() + calc_standard_upgrade() + calc_pro_upgrade());
	document.customer.sales_tax.value   = dollarize(calc_tax(sub_total));
	
	total_cost = parseFloat(sub_total + calc_tax(sub_total));
	document.customer.order_total.value = dollarize(total_cost);
}


function calc_tax(total_cost)
{

	//IF STATE IS MI - THEN CALC SALES TAX
	if (document.customer.billstate.options[document.customer.billstate.selectedIndex].value == 'MI') {
		tax_amount = parseFloat(format((.06 * total_cost),2));					
	//STATE IS NOT MI -- SET TO 0.00
	} else {
		tax_amount = 0.00;		
	}
	return tax_amount;
}

function calc_standard()
{
standard_price = 189;

	//STANDARD QTY IS 0
	if (document.customer.bask_standard_qty.value == 0) {
		standard_cost = 0.00;
	//STANDARD QTY > 0 --- CALC COST
	} else {
	 	standard_cost = parseFloat( format((standard_price * document.customer.bask_standard_qty.value),2));		
	}
	return standard_cost;
}

function calc_standard_upgrade()
{
standard_upgrade_price = 59;

	//STANDARD QTY IS 0
	if (document.customer.bask_standard_upg_qty.value == 0) {
		standard_upgrade_cost = 0.00;
	//STANDARD QTY > 0 --- CALC COST
	} else {
	 	standard_upgrade_cost = parseFloat( format((standard_upgrade_price * document.customer.bask_standard_upg_qty.value),2));		
	}
	return standard_upgrade_cost;
}

function calc_pro()
{
pro_price = 299;
	//PRO QTY IS 0
	if (document.customer.bask_professional_qty.value == 0) {
		pro_cost = 0.00;
	//PRO QTY > 0 --- CALC COST
	} else {
	 	pro_cost = parseFloat( format((pro_price * document.customer.bask_professional_qty.value),2));		
	}
	return pro_cost;
}

function calc_pro_upgrade()
{
pro_upgrade_price = 99;


	//PRO QTY IS 0
	if (document.customer.bask_professional_upg_qty.value == 0) {
		pro_upgrade_cost = 0.00;
	//PRO QTY > 0 --- CALC COST
	} else {
	 	pro_upgrade_cost = parseFloat( format((pro_upgrade_price * document.customer.bask_professional_upg_qty.value),2));		
	}
	
	return pro_upgrade_cost;
}


function calc_demo()
{
demo_price = 8.95;

	//DEMO QTY IS 0
	if (document.customer.bask_demo_qty.value == 0) {
		demo_cost = 0.00;
	//DEMO QTY > 0 --- CALC COST
	} else {
	 	demo_cost = parseFloat( format((demo_price * document.customer.bask_demo_qty.value),2));		
	}
	return demo_cost;
}



//Used to format numbers decimal places
function format (expr,decplaces)
{
	var str = "" + Math.round (eval(expr) * Math.pow(10,decplaces))
	while (str.length <= decplaces) {
		str = "0" + str
	}

	var decpoint = str.length - decplaces
	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
}

function dollarize(expr)
{
	return "$" + format(expr,2)
}


function datechange()
{
	document.customer.PASSDelivery_Date.value = document.customer.month.options[document.customer.month.selectedIndex].value + "-" + document.customer.day.options[document.customer.day.selectedIndex].value + "-" + document.customer.year.options[document.customer.year.selectedIndex].value;
}

function dates()
{
	months = new Array(13);
	months[0] = 'January';
	months[1] = 'February';
	months[2] = 'March';
	months[3] = 'April';
	months[4] = 'May';
	months[5] = 'June';
	months[6] = 'July';
	months[7] = 'August';
	months[8] = 'September';
	months[9] = 'October';
	months[10] = 'November';
	months[11] = 'December';
	
	days = new Array(7);
	days[0] = 'Sunday';
	days[1] = 'Monday';
	days[2] = 'Tuesday';
	days[3] = 'Wednesday';
	days[4] = 'Thursday';
	days[5] = 'Friday';
	days[6] = 'Saturday';
			
	today = new Date();
	tmonth = months[today.getMonth()];
	tdate = today.getDate();
	tyear = today.getFullYear();
	tday  = days[today.getDay()];
	document.write("<font size=1 face=arial><b>" + tday + " " + " - " + "  " + tmonth +" "+ tdate +", "+tyear+"</b></font>");
}

//BASKWARE ONLY
// walk through the images on a page and update each one based on its associated form item
function initImgForm(form,formname) {
	var i;
	var this_ctrl_name;
	var this_ctrl;
	var today          = new Date();
	var future         = new Date();
	
	var oneminute  = 60 * 1000
	var onehour    = oneminute * 60
	var oneday     = onehour * 24
	var oneweek    = oneday * 7  

	//Bump the day forward one day for padding orders				
	today.setTime((today.getTime()) + oneday)
		
	var tmonth    = today.getMonth() + 2;
	var tdate     = today.getDate();
	var tyear     = today.getFullYear();
	var tday      = today.getDay()
	var dateinMs  = today.getTime()
	
	//Set the future date depending on the current day
	//Sunday
	if (tday == 0) {
		future.setTime(dateinMs + (oneday * 4))
	}	

	//Monday
	if (tday == 1) {
		future.setTime(dateinMs + (oneday * 4))
	}	

	//Tuesday
	if (tday == 2) {
		future.setTime(dateinMs + (oneday * 6))
	}	
	
	//Wednesday
	if (tday == 3) {
		future.setTime(dateinMs + (oneday * 6))
	}	

	//Thursday
	if (tday == 4) {
		future.setTime(dateinMs + (oneday * 6))
	}	
		
	//Friday
	if (tday == 5) {
		future.setTime(dateinMs + (oneday * 6))
	}	
		
	//Saturday
	if (tday == 6) {
		future.setTime(dateinMs + (oneday * 5))
	}	
	
	//Set The Month
	//document.customer.month.options[future.getMonth()].selected = true;	
		
	//Set the day
	//document.customer.day.options[future.getDate() - 1].selected = true;

	//Set the year		
	//form.year.value  = future.getFullYear();
	
	//Loop thru and set the images
	for (i = 0; i < document.images.length; i++) {
		var cur_image = document.images[i].name;
		var cur_image_prefix = cur_image.substring(0, image_prefix.length);
		if ((cur_image_prefix) && (cur_image_prefix == image_prefix)) {
			this_ctrl_name = cur_image.substring(image_prefix.length);
			this_ctrl = eval(formname + "." + this_ctrl_name);
	 		this_ctrl = eval("document.forms." + formname + "." + this_ctrl_name);
		
			fieldImg(this_ctrl);
		}
	}
	
	//INITIALIZE THE BLANK IMAGES	
	document.customer.img_shipfirstname.src = emptyImg.src;
	document.customer.img_shiplastname.src  = emptyImg.src;
	document.customer.img_shipstreet1.src   = emptyImg.src;
	document.customer.img_shipstreet2.src   = emptyImg.src;
	document.customer.img_shipcity.src      = emptyImg.src;
	document.customer.img_shipzip.src       = emptyImg.src;
	
	//INITIALIZE THE REQUIRED IMAGES
	document.customer.img_contactname.src = reqImg.src;

}

//Billing State OR providence change
function billstatechange() {
	
	calc();

	if (document.customer.billstate.value == 'ZZ') {
		//Add required icon
		document.customer.state_img.src = reqImg.src;
		document.customer.prov_img.src = reqImg.src;
	} else {
		//Remove required icon		
		document.customer.state_img.src = emptyImg.src;
		document.customer.prov_img.src = emptyImg.src;
		return;
	}

	//Check the providence
	if (document.customer.billprovidence.value == "") {
		document.customer.prov_img.src = reqImg.src;
		document.customer.state_img.src = reqImg.src;
	} else {
		document.customer.prov_img.src = emptyImg.src;
		document.customer.state_img.src = emptyImg.src;
	}
}

//Shipping State OR providence change
function shipstatechange() {
	if (document.customer.shipstate.value == 'ZZ') {
		//Add required icon
		document.customer.ship_state_img.src = reqImg.src;
		document.customer.ship_prov_img.src = reqImg.src;
	} else {
		//Remove required icon		
		document.customer.ship_state_img.src = emptyImg.src;
		document.customer.ship_prov_img.src = emptyImg.src;
		return;
	}

	//Check the providence
	if (document.customer.shipprovidence.value == "") {
		document.customer.ship_prov_img.src = reqImg.src;
		document.customer.ship_state_img.src = reqImg.src;
	} else {
		document.customer.ship_prov_img.src = emptyImg.src;
		document.customer.ship_state_img.src = emptyImg.src;
	}
}


// set the image associated with a form item
function fieldImg(ctrl, thisname) {
	var img = image_prefix + ctrl.name;
		
	if (ctrl.value != "") {
		if (showWarn(ctrl)) {
			// the field value is questionable, show warning
			document.images[img].src = warnImg.src;
		} else {
			// the field value is reasonably valid, so hide the image
			document.images[img].src = emptyImg.src;
		}
	} else {
		// the field is empty so display the required image
		document.images[img].src = reqImg.src;
	}
}

// Change the alternate shipping options
function altership(ctrl) {
	if (ctrl.checked) {
		//CHECKED
		document.img_shipfirstname.src = emptyImg.src;
		document.img_shiplastname.src = emptyImg.src;
		document.img_shipstreet1.src = emptyImg.src;
		document.img_shipcity.src = emptyImg.src;
		document.img_shipzip.src = emptyImg.src;
		document.ship_state_img.src = emptyImg.src;
		document.ship_prov_img.src = emptyImg.src;
	} else {
		//NOT CHECKED
		document.img_shipfirstname.src = reqImg.src;
		document.img_shiplastname.src = reqImg.src;
		document.img_shipstreet1.src = reqImg.src;	
		document.img_shipcity.src = reqImg.src;	
		document.img_shipzip.src = reqImg.src;
		document.ship_state_img.src = reqImg.src;
		document.ship_prov_img.src = reqImg.src;
	}
	//CLEAR CONTENTS
	document.customer.shipfirstname.value = "";
	document.customer.shiplastname.value = "";
	document.customer.shipstreet1.value = "";
	document.customer.shipstreet2.value = "";
	document.customer.shipcity.value = "";
	document.customer.shipstate.value = "";
	document.customer.shipprovidence.value = "";
	document.customer.shipzip.value = "";
}

// check a control to see if it's value is questionable
function showWarn(ctrl) {
	var warnStatus = false;

	if (ctrl.name == "pass") {
		warnStatus = (ctrl.value.length < 4);
	}
	if (ctrl.name == "id") {
		warnStatus = (!(checkNum(ctrl.value)));
	}

	return warnStatus;
}


// check a string to make sure it's only numbers
// this is a validation function demo
function checkNum(checkText) {
	var checkStatus = true;
	var i = 0;
	var len = checkText.length;
	var ch;

	// walk through a string and fail if
	// we find anything not between "0" and "9" 
	while (i < len) {
		ch = checkText.substring(i, i+1);
		if ((ch < "0") || (ch > "9")) {
			checkStatus = false;
			break;
		}
		i++;
	}
	return checkStatus;
}

function checkEmail(emailAddr) {
	// this function checks for a well-formed e-mail address
	// in the format:
	// user@domain.com
	
	var i;
	
	// check for @
	i = emailAddr.indexOf("@");
	if (i == -1) {
		return false;
	}
	
	// separate the user name and domain
	var username = emailAddr.substring(0, i);
	var domain = emailAddr.substring(i + 1, emailAddr.length)

	// look for spaces at the beginning of the username
	i = 0;
	while ((username.substring(i, i + 1) == " ") && (i < username.length)) {
		i++;
	}
	// remove any found
	if (i > 0) {
		username = username.substring(i, username.length);
	}

	// look for spaces at the end of the domain
	i = domain.length - 1;
	while ((domain.substring(i, i + 1) == " ") && (i >= 0)) {
		i--;
	}
	// remove any found
	if (i < (domain.length - 1)) {
		domain = domain.substring(0, i + 1);
	}

	// make sure neither the username nor domain is blank
	if ((username == "") || (domain == "")) {
		return false;
	}
	
	// check for bad characters in the username
	var ch;
	for (i = 0; i < username.length; i++) {
		ch = (username.substring(i, i + 1)).toLowerCase();
		if (!(((ch >= "a") && (ch <= "z")) || 
			((ch >= "0") && (ch <= "9")) ||
			(ch == "_") || (ch == "-") || (ch == "."))) {
				return false;
		}
	}
	
	// check for bad characters in the domain
	for (i = 0; i < domain.length; i++) {
		ch = (domain.substring(i, i + 1)).toLowerCase();
		if (!(((ch >= "a") && (ch <= "z")) || 
			((ch >= "0") && (ch <= "9")) ||
			(ch == "_") || (ch == "-") || (ch == "."))) {
				return false;
		}
	}

	return true;

	//var aSuffix = new Array("com","edu","org","gov","mil","ca","net");
	//var bFoundSuffix = false;
	//i = 0;
	//while (i < aSuffix.length) {
	//	if (("." + aSuffix[i]) == domain.substring(domain.length - aSuffix[i].length - 1, domain.length)) {
	//		return true;
	//	}
	//	i++;
	//}
	// we would have exited if we'd found a good suffix, so return false
	//return false;
}

function emailOK(emailAddr) {
	document.customer.contactemail.value = document.customer.contactemail.value.toLowerCase();

	if (!(checkEmail(document.customer.contactemail.value))) {
		alert("Please check the e-mail address you entered, it is not in the right format.");
		document.img_contactemail.src = reqImg.src;
		customer.contactemail.focus();
		return false;
	}
	return true;
}

 function ltrim(aStr){
   result=""
   if (aStr.length<=0) {return ""}
   if (aStr.length==1){
   	if (aStr==" ") {return ""}
	else {return aStr}
   }
   else{
     if (aStr.charAt(0)!=" "){
	return aStr;
     }
     else{
	return rtrim(aStr.substring(1,aStr.length))
     }
   }
 }

function isDate(field){
var indate=field.value;
 if (indate.indexOf("-")!=-1){
  var sdate0 = indate.substring(0,indate.indexOf("-"))
  var sdate = indate.substring(indate.indexOf("-")+1,indate.length)
  var sdate1 = sdate.substring(0,indate.indexOf("-"))
  sdate2 = sdate.substring(sdate.indexOf("-")+1,sdate.length)
  if (!isNumericString(sdate0)){sdate2=0}
  if (!isNumericString(sdate1)){sdate2=0}
  if (!isNumericString(sdate2)){sdate2=0}
 }
 else{
  var sdate0 = indate.substring(0,indate.indexOf("/"))
  var sdate = indate.substring(indate.indexOf("/")+1,indate.length)
  var sdate1 = sdate.substring(0,sdate.indexOf("/"))
  sdate2 = sdate.substring(sdate.indexOf("/")+1,sdate.length)
  if (!isNumericString(sdate0)){sdate2=0}
  if (!isNumericString(sdate1)){sdate2=0}
  if (!isNumericString(sdate2)){sdate2=0}
 }
 var chkDate=new Date(Date.parse(indate))
 var cmpDate=(chkDate.getMonth()+1)+"/"+(chkDate.getDate())+"/"+(chkDate.getFullYear())
 var indate2=(Math.abs(sdate0))+"/"+(Math.abs(sdate1))+"/"+(Math.abs(sdate2))
 if (indate2!=cmpDate){
   return false;
 }
 else{
  if (cmpDate=="NaN/NaN/NaN"){
   return false;
  }
  else{
   return true;
  }
 }
}

 function rtrim(aStr){
   if (aStr.length<=0) {return "";}
   if (aStr.length==1){
   	if (aStr==" ") {return "";}
	else {return aStr;}
   }
   if (aStr.charAt(aStr.length - 1)!=' '){
	return aStr;
   }
   return rtrim(aStr.substring(0,aStr.length - 1));
 }


 function trim(aStr){
   return ltrim(rtrim(aStr));
 }
	
 function isNumeric(field){
  var nr1
  var flg
  var cmp
  var tst
  nr1=trim(field.value);
  if (nr1==""){
	nr1=0;
	field.value=0;
  }
  flg=0;
  for (var i=0;i<nr1.length;i++){
   cmp="0123456789"
   tst=nr1.substring(i,i+1)
   if (cmp.indexOf(tst)<0){
    flg++;
    break;
   }
  }
  if (flg!=0){return false;}
  return true;
 }

 function isNumericString(aString){
  var nr1
  var flg
  var cmp
  var tst
  nr1=trim(aString);
  flg=0;
  for (var i=0;i<nr1.length;i++){
   cmp="0123456789"
   tst=nr1.substring(i,i+1)
   if (cmp.indexOf(tst)<0){
    flg++;
    break;
   }
  }

  if (flg!=0){return false;}
  return true;
 }

 function isCurrency(astr, forceInput){
  var nr1
  nr1=trim(astr);
  flg=0;
  if ((nr1.indexOf(".") > 0) && ((nr1.indexOf(".") < (nr1.length-4)))){
    return false;
  }
  if ((nr1.indexOf(".") >0) && (!isNumericString(nr1.substring(nr1.indexOf(".")+1,nr1.length)))){
   return false
  }
  if (nr1.length==0){
   if (forceInput){
    return false;
   }
   else{
    return true;
   }
  }
  if (nr1.indexOf(",") < 0){
  if (nr1.indexOf(".") >0){
    return isNumericString(nr1.substring(0,nr1.indexOf(".")));
   }
   else{
    if (isNumericString(nr1)) {
      return true;
    }
    else{
      return false;
    }
   }
  }
  else{
   if (nr1.indexOf(",") >= (nr1.length - 3)){
    return false;
   }
   if (nr1.indexOf(".") <0){
    return isCurrency(nr1.substring(0,nr1.indexOf(","))) && isCurrency(nr1.substring(nr1.indexOf(",")+1,nr1.length));
   }
   else{
    return isCurrency(nr1.substring(0,nr1.indexOf(","))) && isCurrency(nr1.substring(nr1.indexOf(",")+1,nr1.indexOf(".")));
   }
  }
 }

 function isPositive(field){
  return (isNumeric(field) && (field.value>0));
 }

 function isBlank(field){
  var mt
  mt=trim(field.value);
  if (mt.length<1){
	return true;
  }
  return false;
 }

 function isPhone(field){
  var aphone
  aphone=trim(field.value)
str="";
  tst="";
  flg=0;
  cmp="0123456789";
  cmp2="0123456789()/- ";
  for (var i=0;i<aphone.length;i++){
   tst=aphone.substring(i,i+1);
   if (cmp2.indexOf(tst)<0){
    flg++;
   }
   else{
    if (cmp.indexOf(tst)>=0){
     str+=tst;
    }	
   }
  }
  if (flg!=0) {return false;}
  if (str.length==7){
   field.value=str.substring(0,3)+"-"+str.substring(3,7);
  }
  if (str.length!=10){
   return false;
  }
  field.value="(" + str.substring(0,3) +") "+str.substring(3,6)+"-"+str.substring(6,10);
  return true
 }

 
function msgFail(field,Msg){
  alert(Msg);
  field.focus();
  return;
}


function capsLc(txt){
 if (navigator.appVersion.substring(0,1)=="2"){
  return navOld(txt);
 }
 else return navNew(txt);
 }

function navOld(txt){
 txt+=" ";
 txt=txt.toLowerCase();
 txtl="";
 while ((txt.length>0)&&(txt.indexOf(" ")>-1)){
  pos=txt.indexOf(" ");
  wrd=txt.substring(0,pos);
  cmp=" "+wrd+" ";
  if (txt.indexOf(cmp)<0){
   ltr=wrd.substring(0,1);
   ltr=ltr.toUpperCase();
   wrd=ltr+wrd.substring(1,wrd.length);
  }
  txtl+=wrd+" "; 
  txt=txt.substring((pos+1),txt.length);
 }
 ltr=txtl.substring(0,1);
 ltr=ltr.toUpperCase();
 txtl=ltr+txtl.substring(1,txtl.length-1);
 return txtl;
}

function navNew(txt){
 txt=txt+" ";
 txt=txt.toLowerCase();
 txtl="";
 punc=",.?!:;)'";
 punc+='"';
 while ((txt.length>0)&&(txt.indexOf(" ")>-1)){
  pos=txt.indexOf(" ");
  wrd=txt.substring(0,pos);
  wrdpre="";
  if (punc.indexOf(wrd.substring(0,1))>-1){
   wrdpre=wrd.substring(0,1);
   wrd=wrd.substring(1,wrd.length);
  }
  cmp=" "+wrd+" ";
  for (var i=0;i<9;i++){
   p=wrd.indexOf(punc.substring(i,i+1));
   if (p==wrd.length-1){
    cmp=" "+wrd.substring(0,wrd.length-1)+" ";
    i=9;
   }
  }
  if (cmp.indexOf(cmp)<0){
   ltr=wrd.substring(0,1);
   ltr=ltr.toUpperCase();
   wrd=ltr+wrd.substring(1,wrd.length);
  }
  txtl+=wrdpre+wrd+" "; 
  txt=txt.substring((pos+1),txt.length);
 }
 ltr=txtl.substring(0,1);
 ltr=ltr.toUpperCase();
 txtl=ltr+txtl.substring(1,txtl.length-1);
 return txtl;
}

//BASKWARE ONLY
//This function checks all feilds for valid entries
function checkall(form){

	//Set the delivery date
	//datechange()
	
	if (isBlank(form.order_total)) {
		msgFail(form.bask_standard_qty,"Please enter quantity of products or services you wish to order.");
		return false;
	}

	if (parseFloat(calc_standard() + calc_demo() + calc_pro() + calc_standard_upgrade() + calc_pro_upgrade()) == 0) {
		msgFail(form.bask_standard_qty,"Please enter quantity of products or services you wish to order.");
		return false;
	}	

	if (isBlank(form.cardnumber)) {
		msgFail(form.cardnumber,"Please enter a Credit Card Number.");
		return false;
	}

	//Contact Name
  	if (isBlank(form.contactname)){
  		msgFail(form.contactname,"Please enter a Contact Name");
  		return false;
  	}
  	//Email Address
 	if (isBlank(form.contactemail)){
		msgFail(form.contactemail,"Please enter an E-Mail Address");
		return false;
	}

	//Email Address Confirmation
 	if (isBlank(form.contactemail_2)){
		msgFail(form.contactemail_2,"Please enter the confirmation E-Mail Address");
		return false;
	}
	
	//Check e-mail format	
	if (!(emailOK(form.contactemail.value))){
		return false;
	}
	
	//Check email's match
	if (form.contactemail.value != form.contactemail_2.value) {
		alert("Email addresses do not match.  This is a validation of the email address to catch typos.  Please check the email addresses and try again.")
		return false;
	}
	
	//Phone Number
 	if (isBlank(form.PASSPhone)){
		msgFail(form.PASSPhone,"Please enter a Phone Number");
		return false;
	}
	
	//First name
  	if (isBlank(form.billfirstname)){
  		msgFail(form.billfirstname,"Please enter a First Name");
  		return false;
  	}
  	//Last Name
 	if (isBlank(form.billlastname)){
		msgFail(form.billlastname,"Please enter a Last Name");
		return false;
	}
	
	//Street 1
	if (isBlank(form.billstreet1)){
		msgFail(form.billstreet1,"Please enter a Street Address 1");
		return false;
	}

	//City
	if (isBlank(form.billcity)){
		msgFail(form.billcity,"Please enter a City");
		return false;
	}

	//State
	if (form.billstate.value == "ZZ") {
		if(isBlank(form.billprovidence)) {
			msgFail(form.billstate,"Please enter a State OR Providence");
			return false;
		}
	} else {
		//CHECK TO SEE IF BOTH STATE AND PROV EXIST	
		if (isBlank(form.billprovidence) == false) {
			msgFail(form.billprovidence,"Please enter ONLY State OR Providence not both.");
			return false;
		}
	}	
	
	//Zip
	if (isBlank(form.billzip)){
		msgFail(form.billzip,"Please enter a Zip Code");
		return false;
	}
	
	//Validate the checkout box
	if (form.shiptobilladdr.checked) {
		//Skip - dont need to validate alternate shipping
	} else {
		//Validate alternate shipping
	 	//Shipping First Name
	 	if (isBlank(form.shipfirstname)){
			msgFail(form.shipfirstname,"Please enter a Shipping First Name");
			return false;
		}
		
		//Shipping Last Name
	 	if (isBlank(form.shiplastname)){
			msgFail(form.shiplastname,"Please enter a Shipping Last Name");
			return false;
		}

		//Shipping Street 1
		if (isBlank(form.shipstreet1)){
			msgFail(form.shipstreet1,"Please enter a Shipping Street Address 1");
			return false;
		}

		//Shipping City
		if (isBlank(form.shipcity)){
			msgFail(form.shipcity,"Please enter a Shipping City");
			return false;
		}

		//Shipping State
		if (form.shipstate.value == "ZZ") {
			if(isBlank(form.shipprovidence)) {
				msgFail(form.shipstate,"Please enter a Shipping State OR Providence");
				return false;
			}
		} else {
			//CHECK TO SEE IF BOTH STATE AND PROV EXIST	
			if (isBlank(form.shipprovidence) == false) {
				msgFail(form.shipprovidence,"Please enter ONLY Shipping State OR Providence not both.");
				return false;
			}
		}	
	
		//Shipping Zip
		if (isBlank(form.shipzip)){
			msgFail(form.shipzip,"Please enter a Shipping Zip Code");
			return false;
		}
	}

	//ALL PASSED VALIDATION --- Submit the form
	return true;
}

function validate_delivery(form) {

	var today          = new Date();
	var future         = new Date();
	var selected_date  = new Date();
	
	var oneminute = 60 * 1000
	var onehour   = oneminute * 60
	var oneday     = onehour * 24
	var oneweek   = oneday * 7  

	//Bump the day forward one day for padding orders				
	today.setTime((today.getTime()) + oneday)
		
	var tmonth    = today.getMonth() + 2;
	var tdate     = today.getDate();
	var tyear     = today.getFullYear();
	var tday      = today.getDay()
	var dateinMs  = today.getTime()
	
	//Set a date object for the date the customer has selected
	selected_date.setMonth(form.month.options[form.month.selectedIndex].value - 1)
	selected_date.setDate(form.day.options[form.day.selectedIndex].value)
	selected_date.setFullYear(form.year.options[form.year.selectedIndex].value);
	
	//VALIDATE THE SELECTED DATE vs. TODAYS DATE
	if (selected_date < today) {
		alert("Invalid Delivery Date.  Delivery date can not be less than the current date.");
		form.month.focus();
		return "failed";
	}
	
	//Validate Shipping Method
	
	//GROUND
	if (document.customer.shipmethod.options[form.shipmethod.selectedIndex].value == "GNDCOM") {
		//Set the future date depending on the current day
		//Sunday
		if (tday == 0) {
			future.setTime(dateinMs + (oneday * 4))
		}	

		//Monday
		if (tday == 1) {
			future.setTime(dateinMs + (oneday * 4))
		}	

		//Tuesday
		if (tday == 2) {
			future.setTime(dateinMs + (oneday * 6))
		}	
	
		//Wednesday
		if (tday == 3) {
			future.setTime(dateinMs + (oneday * 6))
		}	

		//Thursday
		if (tday == 4) {
			future.setTime(dateinMs + (oneday * 6))
		}	
		
		//Friday
		if (tday == 5) {
			future.setTime(dateinMs + (oneday * 6))
		}	
		
		//Saturday
		if (tday == 6) {
			future.setTime(dateinMs + (oneday * 5))
		}	

		//Validate the Deilvery date and display the next available date				
		if (selected_date < future) {
			alert("Please allow a minimum of 4 BUSINESS DAYS for Ground Shipping.  No Saturday or Sunday deliveries available.  Next available delivery date would be " + (future.getMonth() + 1) + "-" + future.getDate() + "-" + future.getFullYear());
			form.day.focus();
			
			//Set The Month
			document.customer.month.options[future.getMonth()].selected = true;	
			
			//Set the day
			document.customer.day.options[future.getDate() - 1].selected = true;

			//Set the year		
			//form.year.value  = future.getFullYear();
			
			return "failed";		
		}
	}
	
	//2 DAY AIR
	if (form.shipmethod.options[form.shipmethod.selectedIndex].value == "1DA") {
		//Set the future date depending on the current day
		//Sunday
		if (tday == 0) {
			future.setTime(dateinMs + (oneday * 3))
		}	

		//Monday
		if (tday == 1) {
			future.setTime(dateinMs + (oneday * 2))
		}	

		//Tuesday
		if (tday == 2) {
			future.setTime(dateinMs + (oneday * 2))
		}	
	
		//Wednesday
		if (tday == 3) {
			future.setTime(dateinMs + (oneday * 2))
		}	

		//Thursday
		if (tday == 4) {
			future.setTime(dateinMs + (oneday * 4))
		}	
		
		//Friday
		if (tday == 5) {
			future.setTime(dateinMs + (oneday * 4))
		}	
		
		//Saturday
		if (tday == 6) {
			future.setTime(dateinMs + (oneday * 4))
		}	

		//Validate the Deilvery date and display the next available date				
		if (selected_date < future) {
			alert("Please allow a minimum of 2 BUSINESS DAYS for Second Day Air Shipping.  No Saturday or Sunday deliveries available.  Next available delivery date would be " + (future.getMonth() + 1) + "-" + future.getDate() + "-" + future.getFullYear());
			form.day.focus();
						
			//Set The Month
			document.customer.month.options[future.getMonth()].selected = true;	
		
			//Set the day
			document.customer.day.options[future.getDate() - 1].selected = true;

			//Set the year		
			//form.year.value  = future.getFullYear();
			
			return "failed";			
		}
	}

	//NEXT DAY AIR
	if (form.shipmethod.options[form.shipmethod.selectedIndex].value == "2DA") {
		//Set the future date depending on the current day
		//Sunday
		if (tday == 0) {
			future.setTime(dateinMs + (oneday * 2))
		}	

		//Monday
		if (tday == 1) {
			future.setTime(dateinMs + (oneday * 1))
		}	

		//Tuesday
		if (tday == 2) {
			future.setTime(dateinMs + (oneday * 1))
		}	
	
		//Wednesday
		if (tday == 3) {
			future.setTime(dateinMs + (oneday * 1))
		}	

		//Thursday
		if (tday == 4) {
			future.setTime(dateinMs + (oneday * 1))
		}	
		
		//Friday
		if (tday == 5) {
			future.setTime(dateinMs + (oneday * 3))
		}	
		
		//Saturday
		if (tday == 6) {
			future.setTime(dateinMs + (oneday * 3))
		}	

		//Validate the Deilvery date and display the next available date				
		if (selected_date < future) {
			alert("Please allow a minimum of 1 BUSINESS DAY for Next Day Air Shipping.  No Saturday or Sunday deliveries available.  Next available delivery date would be " + (future.getMonth() + 1) + "-" + future.getDate() + "-" + future.getFullYear());
			form.day.focus();
			
			//Set The Month
			document.customer.month.options[future.getMonth()].selected = true;	
		
			//Set the day
			document.customer.day.options[future.getDate() - 1].selected = true;

			//Set the year		
			//form.year.value  = future.getFullYear();
			
			return "failed";		
		}	
	}
}

function shipping_warning(crtl) {
	if (document.customer.shiptobilladdr.checked) {
		if (isBlank(crtl)) {
			document.img_shipfirstname.src = emptyImg.src;
			document.img_shiplastname.src = emptyImg.src;
			document.img_shipstreet1.src = emptyImg.src;
			document.img_shipcity.src = emptyImg.src;
			document.img_shipzip.src = emptyImg.src;
			document.ship_state_img.src = emptyImg.src;
			document.ship_prov_img.src = emptyImg.src;
		}
		else{
			alert("Your current shipping option is to ship to the billing address listed above.  If you want the billing and shipping addresses to be different, please uncheck the option and fill out the required shipping information.");
			crtl.value = '';
			document.customer.shiptobilladdr.focus();
		}
	}
}


function new_page(form)
{
	if (form.category.options[form.category.selectedIndex].value != "blank") {	
	  if (form.category.options[form.category.selectedIndex].value != "baskware_order") {
	     page = "http://www.baskware.com/" + form.category.options[form.category.selectedIndex].value + ".htm";
	     parent.location = page;
    	  } else {
	    order();		
          }     
	}
}

function order()
{
	page = "http://www.baskware.com/order_redirect.asp";
	parent.location = page;
}

function download_trial(form)
{
	//Contact Name
  	if (form.name.value == ""){
  		alert("Please enter your Name.");
  		return;
  	}


	//Company Name
  	if (form.company.value == ""){
  		alert("Please enter your Company Name.");
  		return;
  	}
	
	//Email Address
 	if (form.email_address.value == ""){
		alert("Please enter an E-Mail Address");
		return;
	}
	
	//Agreement
  	if (form.agreement.checked == false){
  		alert("Please check the agreement.");
  		return;
  	}
	
window.open("ftp://download:download@ftp.baskware.com/pub/baskware_trial_30.exe","discWin","width=550,height=500,location=0,menubar=0,directories=no,toolbar=no,scrollbars=yes,resizable=no,status=no");

	
form.submit();

}


function download_pro_upgrade(form)
{
	//Contact Name
  	if (form.name.value == ""){
  		alert("Please enter your Name.");
  		return;
  	}

	//Company Name
  	if (form.company.value == ""){
  		alert("Please enter your Company Name.");
  		return;
  	}

	//Email Address
 	if (form.email_address.value == ""){
		alert("Please enter an E-Mail Address");
		return;
	}
	
	//Reg Number blank
  	if (form.reg_number.value == ""){
  		alert("Please enter your registration number.  The Registration Number can be found on your invoice or in BaskWare under the Menu Option: HELP -> About BaskWare");
  		return;
  	}
	
	//Reg Number check for valid length
	if (form.reg_number.value.length != 25){		
		alert("This is an invalid Registration Number.  Please check it and try again.  The Registration Number can be found on your invoice or in BaskWare under the Menu Option: HELP -> About BaskWare");		
		return;
	}
	
	//Reg Number check for valid code
	if ((Number(form.reg_number.value.substr(0,1))) + (Number(form.reg_number.value.substr(24,1))) != 10){		
		alert("This is an invalid Registration Number.  Please check it and try again.  The Registration Number can be found on your invoice or in BaskWare under the Menu Option: HELP -> About BaskWare");		
		return;
	}

	if (form.version[0].checked == true){
		
		window.open("ftp://download:download@ftp.baskware.com/pub/baskware_ps_upgrade_28.exe","discWin","width=550,height=500,location=0,menubar=0,directories=no,toolbar=no,scrollbars=yes,resizable=no,status=no");

		form.submit();
		
	}

	if (form.version[1].checked == true){

		window.open("ftp://download:download@ftp.baskware.com/pub/baskware_pc_upgrade_28.exe","discWin","width=550,height=500,location=0,menubar=0,directories=no,toolbar=no,scrollbars=yes,resizable=no,status=no");
		
		form.submit();
	}

}

function download_standard_upgrade(form)
{
	//Contact Name
  	if (form.name.value == ""){
  		alert("Please enter your Name.");
  		return;
  	}


	//Company Name
  	if (form.company.value == ""){
  		alert("Please enter your Company Name.");
  		return;
  	}
	
	//Email Address
 	if (form.email_address.value == ""){
		alert("Please enter an E-Mail Address");
		return;
	}
	
	//Reg Number blank
  	if (form.reg_number.value == ""){
  		alert("Please enter your registration number.  The Registration Number can be found on your invoice or in BaskWare under the Menu Option: HELP -> About BaskWare");
  		return;
  	}
	
	
	//if (form.version[0].checked == true){
	//	//Reg Number check for valid 1.x ID
	//	if (form.reg_number.value.length != 15){		
	//		alert("This is an invalid Registration Number.  Please check it and try again.  The Registration Number can be found on your invoice or in BaskWare under the Menu Option: HELP -> About BaskWare");		
	//		return;
	//	}
	//	
	//	window.open("ftp://download:download@ftp.baskware.com/pub/baskware_s_upgrade_28.exe","discWin","width=550,height=500,location=0,menubar=0,directories=no,toolbar=no,scrollbars=yes,resizable=no,status=no");
	//
	//	form.submit();
		
	//}

	if (form.version.checked == true){
	
		//Reg Number check for valid 2.x ID
		if (form.reg_number.value.length != 20){		
			alert("This is an invalid Registration Number.  Please check it and try again.  The Registration Number can be found on your invoice or in BaskWare under the Menu Option: HELP -> About BaskWare");		
			return;
		}

		//Reg Number check for valid code
			if ((Number(form.reg_number.value.substr(0,1))) + (Number(form.reg_number.value.substr(19,1))) != 10){		
			alert("This is an invalid Registration Number.  Please check it and try again.  The Registration Number can be found on your invoice or in BaskWare under the Menu Option: HELP -> About BaskWare");		
			return;
		}

		window.open("ftp://download:download@ftp.baskware.com/pub/baskware_s_upgrade_28.exe","discWin","width=550,height=500,location=0,menubar=0,directories=no,toolbar=no,scrollbars=yes,resizable=no,status=no");
		
		form.submit();
	}
}


function openthis(file)
{
	window.open(file,"discWin","width=700,height=520,location=0,menubar=0,directories=no,toolbar=no,scrollbars=yes,resizable=no,status=no");
}

function check_browser()
{
	// test the browser to make sure it's ok
	var browserName = navigator.appName;
	var browserVer = parseInt(navigator.appVersion);
	var browserOK = (((browserName == "Netscape") && (browserVer >= 3)) || 
		((browserName == "Microsoft Internet Explorer") && (browserVer >= 4)));

	if (browserName == "Netscape") {
		 
	}
}

function dates()
{
	months = new Array(13);
	months[0] = 'January';
	months[1] = 'February';
	months[2] = 'March';
	months[3] = 'April';
	months[4] = 'May';
	months[5] = 'June';
	months[6] = 'July';
	months[7] = 'August';
	months[8] = 'September';
	months[9] = 'October';
	months[10] = 'November';
	months[11] = 'December';
	
	days = new Array(7);
	days[0] = 'Sunday';
	days[1] = 'Monday';
	days[2] = 'Tuesday';
	days[3] = 'Wednesday';
	days[4] = 'Thursday';
	days[5] = 'Friday';
	days[6] = 'Saturday';
			
	today = new Date();
	tmonth = months[today.getMonth()];
	tdate = today.getDate();
	tyear = today.getFullYear();
	tday  = days[today.getDay()];

	document.write("<font size=1 face=Arial Black><b>" + tday + " " + " - " + "  " + tmonth +" "+ tdate +", "+tyear+"</b></font>");
}


function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}


function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}


function preloadImages() {
	if (document.images) {
		home_10_home_03_over = newImage("images/home_10-home_03_over.gif");
		home_10_home_04_over = newImage("images/home_10-home_04_over.gif");
		home_10_home_05_over = newImage("images/home_10-home_05_over.gif");
		home_10_home_06_over = newImage("images/home_10-home_06_over.gif");
		home_10_home_07_over = newImage("images/home_10-home_07_over.gif");
		home_10_home_08_over = newImage("images/home_10-home_08_over.gif");
		preloadFlag = true;
	}
}