
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//Initializes FAQ page

function initFAQ() {

a1.answer = a1.innerHTML;
a1.question = q1.innerHTML;
a1.innerHTML = "";

a2.answer = a2.innerHTML;
a2.question = q2.innerHTML;
a2.innerHTML = "";

//a3.answer = a3.innerHTML;
//a3.question = q3.innerHTML;
//a3.innerHTML = "";

a4.answer = a4.innerHTML;
a4.question = q4.innerHTML;
a4.innerHTML = "";

a5.answer = a5.innerHTML;
a5.question = q5.innerHTML;
a5.innerHTML = "";

a6.answer = a6.innerHTML;
a6.question = q6.innerHTML;
a6.innerHTML = "";

a7.answer = a7.innerHTML;
a7.question = q7.innerHTML;
a7.innerHTML = "";

a8.answer = a8.innerHTML;
a8.question = q8.innerHTML;
a8.innerHTML = "";

a9.answer = a9.innerHTML;
a9.question = q9.innerHTML;
a9.innerHTML = "";

a10.answer = a10.innerHTML;
a10.question = q10.innerHTML;
a10.innerHTML = "";

a11.answer = a11.innerHTML;
a11.question = q11.innerHTML;
a11.innerHTML = "";

a12.answer = a12.innerHTML;
a12.question = q12.innerHTML;
a12.innerHTML = "";

a13.answer = a13.innerHTML;
a13.question = q13.innerHTML;
a13.innerHTML = "";

a14.answer = a14.innerHTML;
a14.question = q14.innerHTML;
a14.innerHTML = "";

a15.answer = a15.innerHTML;
a15.question = q15.innerHTML;
a15.innerHTML = "";

a16.answer = a16.innerHTML;
a16.question = q16.innerHTML;
a16.innerHTML = "";

a17.answer = a17.innerHTML;
a17.question = q17.innerHTML;
a17.innerHTML = "";
}

//Opens FAQ answers

function openAnswer(idstring) {
  answerArea.innerHTML = "<p class='subHeading'>" + idstring.question + "</p><blockquote>" + idstring.answer + "</blockquote><p class='littlesmaller'>Please click another question to view its answer.</p>";
}

//Popup window

function popitup(url,windowWidthx,windowHeighty,scrollbar) {
 var windowWidth = windowWidthx, windowHeight=windowHeighty;
 if (scrollbar) {
  var scrollbars = scrollbar;
 } else {
  var scrollbars = "yes";
 }
 if (document.all) {
 var xMax = screen.width, yMax = screen.height;
 } else {
 if (document.layers) {
 var xMax = window.outerWidth, yMax = window.outerHeight;
 } else {
 var xMax = 640, yMax=480;
   }
 }
 var xOffset = (xMax - windowWidth)/2, yOffset = (yMax - windowHeight)/2;
 newwindow=window.open(url,'nameofwinder','height='+windowHeight+',width='+windowWidth+',scrollbars='+scrollbars+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset);
 if (window.focus) {
  newwindow.focus();
  }
 return false;
}


//Product pages Select box

var productDropDown = "<form name='productForm' method='post' action=''><div align='left'><b>Go to product:</b><br>&nbsp;</div><select name='productSelect' id='productSelect' onChange='gotoProduct(productForm.productSelect.selectedIndex);' style='width: 300px;'><option value='NULL'>(Select a Style)</option><option value='223.html'>223 - Hanes Adult Knit Shirt</option><option value='223.html'>223Y - Hanes Youth Knit Shirt</option><option value='224.html'>224 - Hanes Adult Sweatshirt</option><option value='224.html'>224Y - Hanes Youth Sweatshirt</option><option value='320.html'>320 - Adult Unlined Nylon Coaches Jacket</option><option value='321.html'>321 - Adult Light Lined Nylon Coaches Jacket</option><option value='321Y.html'>321Y - Youth Light Lined Nylon Coaches Jacket</option><option value='326.html'>326 - Adult Light Lined Satin Baseball Jacket Stripe Trim</option><option value='326Y.html'>326Y - Youth Light Lined Satin Baseball Jacket Stripe Trim</option><option value='326.html'>327 - Adult Light Lined Satin Baseball Jacket Solid Trim</option><option value='326Y.html'>327Y - Youth Light Lined Satin Baseball Jacket Solid Trim</option><option value='332.html'>332 - Adult Quilt Lined Satin Baseball Jacket Stripe Trim</option><option value='332Y.html'>332Y - Youth Quilt Lined Satin Baseball Jacket Stripe Trim</option><option value='332.html'>333 - Adult Quilt Lined Satin Baseball Jacket Solid Trim</option><option value='332Y.html'>333Y - Youth Quilt Lined Satin Baseball Jacket Solid Trim</option><option value='450.html'>450 - Adult Light Lined Nylon Baseball Jacket Stripe Trim</option><option value='450.html'>450Y - Youth Light Lined Nylon Baseball Jacket Stripe Trim</option><option value='450.html'>451 - Adult Light Lined Nylon Baseball Jacket Solid Trim</option><option value='450.html'>451Y - Youth Light Lined Nylon Baseball Jacket Solid Trim</option><option value='460.html'>460 - Adult Unlined Nylon Hooded Pullover</option><option value='460.html'>460Y - Youth Unlined Nylon Hooded Pullover</option><option value='480.html'>480 - Adult Micro-Twill Wind Shirt</option></select></form>";


function gotoProduct (product) {

if ((productForm.productSelect.options[productForm.productSelect.selectedIndex].value) != "NULL") {
	location.href = productForm.productSelect.options[product].value;
	}
}

//Change style preview color

function changeProductColor(style, color1, color2) {
	if (style != "") {
		if (color2) {
			colorOverlay.innerHTML = '<img src="images/products/'+style+"_"+color1+"_"+color2+'.jpg">';
		} else {
			colorOverlay.innerHTML = '<img src="images/products/'+style+"_"+color1+'.jpg">';
		}
	} else {
		colorOverlay.innerHTML = '&nbsp;';
	}
}

//For determining which colors/sizes are available for each style

function orderStyleSelectBox () {
	if (orderForm.styleSelect.selectedIndex == 0) {
		colorSelect.innerHTML = styleOne.innerHTML;
	}
	if (orderForm.styleSelect.selectedIndex == 1) {
		colorSelect.innerHTML = styleTwo.innerHTML;
	}
	if (orderForm.styleSelect.selectedIndex == 2) {
		colorSelect.innerHTML = styleThree.innerHTML;
	}
	if (orderForm.styleSelect.selectedIndex == 3) {
		colorSelect.innerHTML = styleFour.innerHTML;
	}
}

// FORMBREEZE-BEGIN   - Do not modify these lines directly.  To change your form validation, visit http://www.formbreeze.com. 

var b = 0 ;
var i = 0 ;
var errmsg = "" ;
var punct = "" ;
var min = 0 ;
var max = 0 ;

function formbreeze_email(field) {

	if (b && (field.value.length == 0)) return true ;


	if (! emailCheck(field.value))
	  {
		  field.focus();
		  if (field.type == "text") field.select();
		  return false ;
	  }

   return true ;
}

function formbreeze_filledin(field) {

if (b && (field.value.length == 0)) return true;

if (field.value.length < min) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false ;
   }

if ((max > 0) && (field.value.length > max)) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false ;
   }

return true ;
}

function formbreeze_number(field) {

if (b && (field.value.length == 0)) return true ; ;

if (i)
 var valid = "0123456789"
else
 var valid = ".,0123456789"

var pass = 1;
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") pass = 0;

}

if (!pass) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false;
 }

if (field.value < min) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false;
   }


if ((max > 0) && (field.value > max)) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false;
   }

return true ;
}


function formbreeze_numseq(field) {


if (b && (field.value.length == 0)) return true ;

var valid = punct + "0123456789"

var pass = 1;
var digits = 0
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") pass = 0;
if (valid.indexOf(temp) > (punct.length-1) ) digits++ ;

}

if (!pass) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false ; ;
   }

if (digits < min) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false;
   }

if ((max > 0) && (digits > max)) {
alert(errmsg);
field.focus();
if (field.type == "text") field.select();
return false;
   }

return true ;
}

function emailCheck (emailStr) {

var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|ws)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);

if (matchArray==null) {
alert(errmsg);
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert(errmsg);
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert(errmsg);
return false;
   }
}

if (user.match(userPat)==null) {
alert(errmsg);
return false;
}

var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert(errmsg);
return false;
   }
}

if (checkTLD && domArr[domArr.length-1].length!=2 &&
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert(errmsg);
return false;
}

if (len<2) {
alert(errmsg);
return false;
}

return true;
}

function formbreeze_sub()
{

b=0;
errmsg="Your Name must be filled in.";
min=1;
max=0;
if (! formbreeze_filledin(document.form1.txtName) ) return false ;
b=0;
errmsg="Company Name must be filled in.";
min=1;
max=0;
if (! formbreeze_filledin(document.form1.txtCompany) ) return false ;
b=0;
errmsg="Address must be filled in.";
min=1;
max=0;
if (! formbreeze_filledin(document.form1.txtAddress1) ) return false ;
b=0;
errmsg="City must be filled in.";
min=1;
max=0;
if (! formbreeze_filledin(document.form1.txtCity) ) return false ;
b=0;
errmsg="State must be filled in.";
min=1;
max=0;
if (! formbreeze_filledin(document.form1.txtState) ) return false ;
b=0;
errmsg="Please enter a valid zip code.";
punct="-";
min=5;
max=9;
if (! formbreeze_numseq(document.form1.txtZip) ) return false ;
b=0;
errmsg="Please enter a complete phone number with area code.";
punct=" ()-+";
min=10;
max=10;
if (! formbreeze_numseq(document.form1.txtPhone) ) return false ;
b=0;
errmsg="Please enter a valid email address.";
if (! formbreeze_email(document.form1.txtEmail) ) return false ;
b=1;
errmsg="";
min=1;
max=0;
if (! formbreeze_filledin(document.form1.txtAddress2) ) return false ;
b=1;
errmsg="";
min=1;
max=0;
if (! formbreeze_filledin(document.form1.txtCountry) ) return false ;
b=1;
errmsg="";
punct=" ()-+";
min=10;
max=10;
if (! formbreeze_numseq(document.form1.txtFax) ) return false ;

}

//Disallows right-clicking:

function right(e) {
if (navigator.appName == 'Netscape' &&
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' &&
(event.button == 2 || event.button == 3)) {
alert("Sorry, you do not have permission to right click.");
return false;
}
return true;
}

document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;


//Literature Request Form Validation

function checkform (form) {
	if ((form.Name.value == "") || (form.Email.value == "") || (form.Address1.value == "") || (form.City.value == "") || (form.State.value == "") || (form.Zip.value == "")|| (form.PhoneNumber.value == "")) {
    	alert("Please complete required fields.");
    	form.Name.focus();
    	return false ;
 	} else {
 	 	apos=form.Email.value.indexOf("@");
		dotpos=form.Email.value.lastIndexOf(".");
		lastpos=form.Email.value.length-1;
		if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) {
			alert("Please enter a valid email address.");
			form.Email.focus();
			return false;
		} else {
			return true;
		}
	}
}

//New store functions:

function switchOutSizeMenu() {
	if (document.getElementById("style").value) {
		newMenu1=document.getElementById("style").value;
	} else {
		newMenu1=document.getElementById("style").options[document.getElementById("style").selectedIndex].value;
	}
	newMenu2=document.getElementById("color").options[document.getElementById("color").selectedIndex].value;
	newMenu=newMenu1+newMenu2+"sizes";
	sizeMenu.innerHTML = document.getElementById(newMenu).innerHTML;
}

function switchOutColorMenu() {
	if (document.getElementById("style")) {
		if (document.getElementById("style").value) {
			newMenu=document.getElementById("style").value;
		} else {
			newMenu=document.getElementById("style").options[document.getElementById("style").selectedIndex].value;
		}
		newMenu=newMenu+"colors";
		colorMenu.innerHTML = document.getElementById(newMenu).innerHTML;
		switchOutSizeMenu();
	}
}

function selectAllDefaults() {
	if (document.getElementById("style")) {
		document.getElementById("style").selectedIndex=0;
	}
	switchOutColorMenu();
}

var productDropDownASP = "<form name='productForm' method='post' action=''><div align='left'><b>Go to product:</b><br>&nbsp;</div><select name='productSelect' id='productSelect' onChange='gotoProduct(productForm.productSelect.selectedIndex);' style='width: 300px;'><option value='NULL'>(Select a Style)</option><option value='223.asp'>223 - Hanes Adult Knit Shirt</option><option value='223.asp'>223Y - Hanes Youth Knit Shirt</option><option value='224.asp'>224 - Hanes Adult Sweatshirt</option><option value='224.asp'>224Y - Hanes Youth Sweatshirt</option><option value='320.asp'>320 - Adult Unlined Nylon Coaches Jacket</option><option value='321.asp'>321 - Adult Light Lined Nylon Coaches Jacket</option><option value='321Y.asp'>321Y - Youth Light Lined Nylon Coaches Jacket</option><option value='326.asp'>326 - Adult Light Lined Satin Baseball Jacket Stripe Trim</option><option value='326Y.asp'>326Y - Youth Light Lined Satin Baseball Jacket Stripe Trim</option><option value='326.asp'>327 - Adult Light Lined Satin Baseball Jacket Solid Trim</option><option value='326Y.asp'>327Y - Youth Light Lined Satin Baseball Jacket Solid Trim</option><option value='332.asp'>332 - Adult Quilt Lined Satin Baseball Jacket Stripe Trim</option><option value='332Y.asp'>332Y - Youth Quilt Lined Satin Baseball Jacket Stripe Trim</option><option value='332.asp'>333 - Adult Quilt Lined Satin Baseball Jacket Solid Trim</option><option value='332Y.asp'>333Y - Youth Quilt Lined Satin Baseball Jacket Solid Trim</option><option value='450.asp'>450 - Adult Light Lined Nylon Baseball Jacket Stripe Trim</option><option value='450.asp'>450Y - Youth Light Lined Nylon Baseball Jacket Stripe Trim</option><option value='450.asp'>451 - Adult Light Lined Nylon Baseball Jacket Solid Trim</option><option value='450.asp'>451Y - Youth Light Lined Nylon Baseball Jacket Solid Trim</option><option value='460.asp'>460 - Adult Unlined Nylon Hooded Pullover</option><option value='460.asp'>460Y - Youth Unlined Nylon Hooded Pullover</option><option value='480.asp'>480 - Adult Micro-Twill Wind Shirt</option></select></form>";



//Change style preview color on new ASP pages

function changeProductColorASP(style, color1, color2) {
	if (style != "") {
		if (color2) {
			colorOverlay.innerHTML = '<img src="../../images/products/'+style+"_"+color1+"_"+color2+'.jpg">';
		} else {
			colorOverlay.innerHTML = '<img src="../../images/products/'+style+"_"+color1+'.jpg">';
		}
	} else {
		colorOverlay.innerHTML = '&nbsp;';
	}
}

function hideCCMsg(){
	document.getElementById("ccMessage").oldHTML = document.getElementById("ccMessage").innerHTML;
	document.getElementById("ccMessage").innerHTML = "";
};

function doChangePayment() {
	if (document.getElementById('idPaymentArray').options[document.getElementById('idPaymentArray').selectedIndex].value=='1'){
		document.getElementById("ccMessage").innerHTML = document.getElementById("ccMessage").oldHTML;
	}				
				
	if (document.getElementById('idPaymentArray').options[document.getElementById('idPaymentArray').selectedIndex].value=='2'){
		alert('The Terms option is only available to established customers who have agreements with us. If you do not meet this criteria, your order will be cancelled.');
	}
}