<!--

function checknum() {
var x = document.order.weight.value;
var filter = /^([0-9])+$/;
if (!(filter.test(x))) {
alert("Please enter numbers only for Weight");
document.order.weight.value="";
document.order.weight.focus();
}
return;
}

function checkship() {
var x = document.order.state.value;
if (x=="AK" || x=="HI") {
alert("Were sorry.  We do not currently take online orders to be shipped to Alaska or Hawaii.  Please contact us by email or phone to make special arrangements.");
}
return;
}


function boys(){

var b=document.order.sleevesize.value;
var c=document.order.necksize.value;

if(document.order.necksize.value=="Boys 10 - 10 1/2"){
alert("NOTE: Boys shirt sleeve lengths are determined by the neck size."+"\n"+"\n"+"The size 10 - 10 1/2 inch neck size you selected comes with a 19 inch sleeve."+"\n"+"\n"+"If you need a longer sleeve length than this, you must choose the next neck size."+"\n"+"\n"+"IMPORTANT:"+"\n"+"To properly fit the coat, select the actual measured sleeve length from the list box.");
}else if(document.order.necksize.value=="Boys 11 - 11 1/2"){
alert("NOTE: Boys shirt sleeve lengths are determined by the neck size."+"\n"+"\n"+"The size 11 - 11 1/2 inch neck size you selected comes with a 23 inch sleeve."+"\n"+"\n"+"If you need a longer sleeve length than this, you must choose the next neck size."+"\n"+"\n"+"IMPORTANT:"+"\n"+"To properly fit the coat, select the actual measured sleeve length from the list box.");
}else if(document.order.necksize.value=="Boys 12 - 12 1/2"){
alert("NOTE: Boys shirt sleeve lengths are determined by the neck size."+"\n"+"\n"+"The size 12 - 12 1/2 inch neck size you selected comes with a 27 inch sleeve."+"\n"+"\n"+"If you need a longer sleeve length than this, you must choose the next neck size."+"\n"+"\n"+"IMPORTANT:"+"\n"+"To properly fit the coat, select the actual measured sleeve length from the list box.");
}else if(document.order.necksize.value=="Boys 13 - 13 1/2"){
alert("NOTE: Boys shirt sleeve lengths are determined by the neck size."+"\n"+"\n"+"The size 13 - 13 1/2 inch neck size you selected comes with a 31 inch sleeve."+"\n"+"\n"+"If you need a longer sleeve length than this, you must choose the next neck size."+"\n"+"\n"+"IMPORTANT:"+"\n"+"To properly fit the coat, select the actual measured sleeve length from the list box.");
}

// 'boys' shirt neck sizes start with b and their lengths are 2 digits
if ( ((c.charAt(0)!= "B") && (c!="") && (b!="") && (b<=30))  ){
alert("You have selected a man's neck size with boy's sleeve lengths.\nPlease check your measurements before proceeding.");
}
}

function validate(){

if (document.order.required.value == ""){
alert ("Please enter the required date.");
document.order.required.focus();
return;
}

if (document.order.state.value == ""){
alert ("Please enter the shipping state.");
document.order.state.focus();
return;
}

if (document.order.occasion.value == ""){
alert ("Please enter the occasion.");
document.order.occasion.focus();
return;
}

if ((document.order.occasion.value == "Wedding") && (document.order.position.value == "")){
alert ("Please enter Wearer's position in Wedding.");
document.order.position.focus();
return;
}

if ((document.order.occasion.value == "Wedding") && (document.order.position.value == "GROOM") && (document.order.persons.value == "")){
alert ("Please enter the number in your Wedding.");
document.order.persons.focus();
return;
}

if ((document.order.occasion.value == "Group") && (document.order.persons.value == "")){
alert ("Please enter the number in your Group.");
document.order.persons.focus();
return;
}

if ( ((document.order.occasion.value == "Wedding") || (document.order.occasion.value == "Group")) && (document.order.groupname.value == "") ){
alert ("Please enter the name of your Wedding or Group.");
document.order.groupname.focus();
return;
}

if ((document.order.occasion.value == "Wedding") && (document.order.position.value == "GROOM") && (document.order.glist.value == "")){
alert ("Please list all Gentlemen in your Wedding.");
document.order.glist.focus();
return;
}

if ((document.order.occasion.value == "Group") && (document.order.glist.value == "")){
alert ("Please list all Gentlemen in your Group.");
document.order.glist.focus();
return;
}

if (document.order.wearer.value == ""){
alert ("Please enter the wearer's name.");
document.order.wearer.focus();
return;
}

if (document.order.height.value == ""){
alert ("Please enter the height measurement.");
document.order.height.focus();
return;
}

if (document.order.weight.value == ""){
alert ("Please enter weight measurement.");
document.order.weight.focus();
return;
}

if (document.order.chest.value == ""){
alert ("Please enter chest measurement.");
document.order.chest.focus();
return;
}

if (document.order.overarm.value == ""){
alert ("Please enter overarm measurement.");
document.order.overarm.focus();
return;
}

if (document.order.coatsize.value == ""){
alert ("Please enter coat size measurement.");
document.order.coatsize.focus();
return;
}

if (document.order.necksize.value == ""){
alert ("Please enter neck size measurement.");
document.order.necksize.focus();
return;
}

if (document.order.sleevesize.value == ""){
alert ("Please enter sleeve size measurement.");
document.order.sleevesize.focus();
return;
}

if (document.order.waistsize.value == ""){
alert ("Please enter waist size measurement.");
document.order.waistsize.focus();
return;
}

if (document.order.outseam.value == ""){
alert ("Please enter outseam measurement.");
document.order.outseam.focus();
return;
}

if (document.order.shoesize.value == ""){
alert ("Please enter shoe size measurement.");
document.order.shoesize.focus();
return;
}

if (document.order.terms.value == ""){
alert ("You must agree to the terms and\nconditions of the rental policy");
document.order.terms.focus();
return;
}

if ( (document.order.state.value == "AK") || (document.order.state.value == "HI") ){
alert("Were sorry.  We do not currently take online orders to be shipped to Alaska or Hawaii.  Please contact us by email or phone to make special arrangements.");
return;
}

// Finally check the selected date

// date1 is the calculated date in mm/dd/yyyy format
// date2 is the user selected date in mm/dd/yyyy format

var dateflag=0;

var date1=document.order.date1.value;
var date2=document.order.required.value;


datesplit1=date1.split("/");

date1year=eval(datesplit1[2]);
date1month=eval(datesplit1[0]);
date1day=eval(datesplit1[1]);

datesplit2=date2.split("/");

date2year=eval(datesplit2[2]);
date2month=eval(datesplit2[0]);
date2day=eval(datesplit2[1]);


if (date2year < date1year){
dateflag=1;
}else if ((date2year==date1year) && (date2month<date1month)){
dateflag=1;
}else if ((date2year==date1year) && (date2month==date1month) && (date2day < date1day)){
dateflag=1;
}

if (dateflag==1){
alert("The current earliest delivery date is " + date1);
document.order.required.focus();
return;
}

// Check the 180 day rule

var objDate1=new Date(date1);
var objDate2=new Date(date2);
var advance=(objDate2.getTime()-objDate1.getTime())/1000;

if (advance > 15552000){
alert ("To assure availability, rentals may not be\nordered more than 180 days in advance.\nWe apologize for any inconvenience\n");
document.order.required.focus();
return;
}


document.order.submit();

}


function checkgroup(){
var a=document.order.occasion.value;

if (a == "Wedding" || a=="Group"){
document.order.groupname.text = "Enter Group Name";
document.order.groupname.value = "";
document.order.groupname.disabled=false;
}else{
document.order.groupname.text = "Not Applicable";
document.order.groupname.value = "Not Applicable";
document.order.groupname.disabled=true;
}

if (a == "Wedding"){
document.order.position.selectedIndex = 0;
document.order.position.options[0].text = "Choose One";
document.order.position.options[0].value = "";
document.order.position.disabled=false;
}else{
document.order.position.selectedIndex = 0;
document.order.position.options[0].text = "Not Applicable";
document.order.position.options[0].value = "Not Applicable";
document.order.position.disabled=true;
}

if (a == "Group"){

document.order.group.selectedIndex = 0;
document.order.group.options[0].text = "Select One For Weddings Or Group Occasions";
document.order.group.options[0].value = "";
document.order.group.disabled=false;

document.order.persons.text = "";
document.order.persons.value = "";
document.order.persons.disabled=false;

document.order.glist.text = "";
document.order.glist.value = "";
document.order.glist.disabled=false;

}else{

document.order.group.selectedIndex = 0;
document.order.group.options[0].text = "This Selection Does Not Apply To This Order";
document.order.group.options[0].value = "Not Applicable";
document.order.group.disabled=true;

document.order.persons.text = "N/A";
document.order.persons.value = "N/A";
document.order.persons.disabled=true;

document.order.glist.text = "Not Applicable";
document.order.glist.value = "Not Applicable";
document.order.glist.disabled=true;

}
return;
}



function checkposition(){
var a=document.order.position.value;
if (a == "GROOM"){

document.order.group.selectedIndex = 0;
document.order.group.options[0].text = "Select One For Weddings Or Group Occasions";
document.order.group.options[0].value = "";
document.order.group.disabled=false;

document.order.persons.text = "";
document.order.persons.value = "";
document.order.persons.disabled=false;

document.order.glist.text = "";
document.order.glist.value = "";
document.order.glist.disabled=false;

}else{

document.order.group.selectedIndex = 0;
document.order.group.options[0].text = "This Selection Does Not Apply To This Order";
document.order.group.options[0].value = "Not Applicable";
document.order.group.disabled=true;

document.order.persons.text = "N/A";
document.order.persons.value = "N/A";
document.order.persons.disabled=true;

document.order.glist.text = "Not Applicable";
document.order.glist.value = "Not Applicable";
document.order.glist.disabled=true;
}
return;
}

// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
var i;
for (i = 0; i < s.length; i++){   
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;

// All characters are numbers.
return true;
}
}

function stripCharsInBag(s, bag){
var i;
var returnString = "";
// Search through string's characters one by one.
// If character is not in bag, append to returnString.
for (i = 0; i < s.length; i++){   
var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}

function daysInFebruary (year){
// February has 29 days in any year evenly divisible by four,
// EXCEPT for centurial years which are not also divisible by 400.
return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
for (var i = 1; i <= n; i++) {
this[i] = 31
if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
if (i==2) {this[i] = 29}
} 
return this
}

function isDate(){
var dtStr=document.order.required.value;
var daysInMonth = DaysArray(12)
var pos1=dtStr.indexOf(dtCh)
var pos2=dtStr.indexOf(dtCh,pos1+1)
var strMonth=dtStr.substring(0,pos1)
var strDay=dtStr.substring(pos1+1,pos2)
var strYear=dtStr.substring(pos2+1)
strYr=strYear
if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
for (var i = 1; i <= 3; i++) {
if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
}
month=parseInt(strMonth)
day=parseInt(strDay)
year=parseInt(strYr)
if (pos1==-1 || pos2==-1){
alert("The date format should be : mm/dd/yyyy")
return false
}
if (strMonth.length<1 || month<1 || month>12){
alert("Please enter a valid month")
return false
}
if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
alert("Please enter a valid day")
return false
}
if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
return false
}
if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
alert("Please enter a valid date")
return false
}
return true
}

function checkheight(){
var a=document.order.height.value;
var b=document.order.sleevesize.value;
var c=document.order.necksize.value;

if (  (((a=="5-0") || (a=="5-1") || (a=="5-2") || (a=="5-3") || (a=="5-4") || (a=="5-5") ) && ((b!="") && (b!="30-31") && (b!="31-32")))  ){
alert("Height and Sleeve Length are not a typical combination.\nPlease check your measurements before proceeding.");
}
if (  (((a=="5-6") || (a=="5-7") || (a=="5-8")) && ((b!="") && (b!="31-32") && (b!="32-33") && (b!="33-34")))  ){
alert("Height and Sleeve Length are not a typical combination.\nPlease check your measurements before proceeding.");
}
if (  (((a=="5-9") || (a=="5-10") || (a=="5-11") || (a=="6-0")) && ((b!="") && (b!="33-34") && (b!="34-35") && (b!="35-36")))  ){
alert("Height and Sleeve Length are not a typical combination.\nPlease check your measurements before proceeding.");
}
if (  (((a=="6-1") || (a=="6-2") || (a=="6-3")) && ((b!="") && (b!="34-35") && (b!="35-36") && (b!="36-37") && (b!="37-38")))  ){
alert("Height and Sleeve Length are not a typical combination.\nPlease check your measurements before proceeding.");
}
if (  (((a=="6-4") || (a=="6-5") || (a=="6-6") || (a=="6-7") || (a=="6-8")  || (a=="6-9") || (a=="6-10") || (a=="6-11") || (a.charAt(0)== "7")) && ((b!="") && (b!="37-38") && (b!="38-39") && (b!="39-40")))  ){
alert("Height and Sleeve Length are not a typical combination.\nPlease check your measurements before proceeding.");
}

// 'boys' shirt neck sizes start with b and their lengths are 2 digits
if ( ((c.charAt(0)!= "B") && (c!="") && (b<=30))  ){
alert("You have selected a man's neck size with boy's sleeve lengths.\nPlease check your measurements before proceeding.");
}

}

function checklength(){
var a=document.order.height.value;
var b=document.order.outseam.value;

if (  (((a=="5-0") || (a=="5-1") || (a=="5-2") || (a=="5-3") || (a=="5-4") || (a=="5-5")) && ((b!="") && (b!="33") && (b!="34") && (b!="35") && (b!="36") && (b!="37")))  ){
alert("Height and Outseam are not a typical combination.\nPlease check your measurements before proceeding.");
}
if (  (((a=="5-6") || (a=="5-7") || (a=="5-8")) && ((b!="") && (b!="37") && (b!="38") && (b!="39") && (b!="40")))  ){
alert("Height and Outseam Length are not a typical combination.\nPlease check your measurements before proceeding.");
}
if (  (((a=="5-9") || (a=="5-10") || (a=="5-11") || (a=="6-0")) && ((b!="") && (b!="40") && (b!="41") && (b!="42") && (b!="43")))  ){
alert("Height and Outseam Length are not a typical combination.\nPlease check your measurements before proceeding.");
}
if (  (((a=="6-1") || (a=="6-2") || (a=="6-3")) && ((b!="") && (b!="43") && (b!="44") && (b!="45") && (b!="46")))  ){
alert("Height and Outseam Length are not a typical combination.\nPlease check your measurements before proceeding.");
}
if (  (((a=="6-4") || (a=="6-5") || (a=="6-6") || (a=="6-7") || (a=="6-8")  || (a=="6-9") || (a=="6-10") || (a=="6-11") || (a.charAt(0)== "7")) && ((b!="") && (b!="46") && (b!="47") && (b!="48") && (b!="49")))  ){
alert("Height and Outseam Length are not a typical combination.\nPlease check your measurements before proceeding.");
}

}

function checkcoat(){
var a=document.order.height.value;
var b=document.order.coatsize.value;

if ((((a=="5-5") || (a=="5-6")) && ((b!="") && (b.charAt(2)!= "S")))  ){
alert("A men's size 'Short' coat is typical for your height measurement.\nPlease check your measurements before proceeding.");
}
if ((((a=="5-7")) && ((b!="") && (b.charAt(2)!= "S") && (b.charAt(2)!= "R")))  ){
alert("A men's size 'Short' or 'Regular' coat is typical for your height measurement.\nPlease check your measurements before proceeding.");
}
if (  (((a=="5-8") || (a=="5-9") || (a=="5-10") || (a=="5-11")) && ((b!="") && (b.charAt(2)!= "R")))  ){
alert("A men's size 'Regular' coat is typical for your height measurement.\nPlease check your measurements before proceeding.");
}
if (  (((a=="6-0") || (a=="6-1") || (a=="6-2")) && ((b!="") && (b.charAt(2)!= "L")))  ){
alert("A men's size 'Long' coat is typical for your height measurement.\nPlease check your measurements before proceeding.");
}
if ((((a=="6-3")) && ((b!="") && (b.charAt(2)!= "L") && (b.charAt(2)!= "X")))  ){
alert("A men's size 'Long' or 'X-Long' coat is typical for your height measurement.\nPlease check your measurements before proceeding.");
}
if (  (((a=="6-4") || (a=="6-5") || (a=="6-6") || (a=="6-7") || (a=="6-8")  || (a=="6-9") || (a=="6-10") || (a=="6-11") || (a.charAt(0)== "7")) && ((b!="") && (b.charAt(2)!= "X")))  ){
alert("A men's size 'X-Long' coat is typical for your height measurement.\nPlease check your measurements before proceeding.");
}

}

//-->


