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];}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
		
function replaceChars(entry) {
out = "-"; // replace this
add = ""; // with this
temp = "" + entry; // temporary holder
while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add + 
temp.substring((pos + out.length), temp.length));
}
return temp;
}
function replaceCharsB(entry) {
out = "."; // replace this
add = ""; // with this
temp = "" + entry; // temporary holder
while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add + 
temp.substring((pos + out.length), temp.length));
}
return temp;
}
function replaceCharsC(entry) {
out = " "; // replace this
add = ""; // with this
temp = "" + entry; // temporary holder
while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add + 
temp.substring((pos + out.length), temp.length));
}
return temp;
}

function letternumber(e)
{
var key;
var keychar;
if (window.event)
 key = window.event.keyCode;
else if (e)
 key = e.which;
else
 return true;
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();
// control keys
if ((key==null) || (key==0) || (key==8) || 
 (key==9) || (key==13) || (key==27) )
 return true;
// alphas and numbers
else if ((("-0123456789").indexOf(keychar) > -1))
 return true;
else
 return false;
}

function formatTel(t) {
	if (t.length == 10){
		if (t == ''){
			NEWt = ''
			return NEWt
		} 
		else {
			if (t.match(/[(|)|-]/g)) return t
			 t = t.substr(0,3)+"-"+t.substr(3,3)+"-"+t.substr(6,4)
			  return t
			}
	}
	else {return t}
}

function validateFocus (form,field,value,msg){
    alert(msg)
	field.focus()
 }
 
function tafWin(URL){
		tafwin = window.open(URL,'TAFWin','width=500,height=500,toolbar=0,directories=0,menubar=0,status=0,resizable=0,location=0,scrollbars=0,copyhistory=0');
}

function favWin(URL){
		favwin = window.open(URL,'FAVWin','width=550,height=450,toolbar=0,directories=0,menubar=0,status=0,resizable=1,location=0,scrollbars=1,copyhistory=0');
}

function repWin(URL){
		repwin = window.open(URL,'REPWin','width=400,height=400,toolbar=0,directories=0,menubar=0,status=0,resizable=0,location=0,scrollbars=0,copyhistory=0');
}

function invoiceWin(URL){
		invwin = window.open(URL,'INVWin','width=640,height=400,toolbar=1,directories=0,menubar=1,status=0,resizable=1,location=0,scrollbars=1,copyhistory=0');
}

function shipWin(URL){
		shipwin = window.open(URL,'SHIPWin','width=550,height=400,toolbar=0,directories=0,menubar=0,status=0,resizable=1,location=0,scrollbars=1,copyhistory=0');
}

function checkSpecialOrder(){
	
	if  (document.spoForm.itemName.value=="")
		{
			alert('Please enter the item')
			document.spoForm.itemName.focus();
			return false;
		}

	if  (document.spoForm.itemQty.value=="")
		{
			alert('Please enter the item quantity')
			document.spoForm.itemQty.focus();
			return false;
		}

	if  (document.spoForm.itemPrice.value=="")
		{
			alert('Please enter the item price you were quoted (per item)')
			document.spoForm.itemPrice.focus();
			return false;
		}
	
	if (document.spoForm.termsAgree.checked==false) {
           alert('You must check the box to confirm you agree to the terms noted in order to continue.')
			document.spoForm.termsAgree.focus();
		   return false;
        }

}

function checkPaymentForm(){
	if(document.myForm.paymentMethod){
		if(document.myForm.paymentMethod[1].checked==true){
			/// cc info filled in?
			if(document.myForm.NameOnCard.value==""){
				alert('Please enter the name on your credit card.')
				document.myForm.NameOnCard.focus();
				return false;
			}
			else if(document.myForm.CreditCardNumber.value==""){
				alert('Please enter your credit card number number.')
				document.myForm.CreditCardNumber.focus();
				return false;
			}
			else if(document.myForm.ccv.value==""){
				alert('Please enter your credit card ID.')
				document.myForm.ccv.focus();
				return false;
			}
		}
	}
}

function checkTestimonial(){


	if (document.testimonialForm.Testimonial){
		if (document.testimonialForm.Testimonial.value == ''){
			 alert('Please add your testimonial.')
			 document.testimonialForm.Testimonial.focus();
			 return false;
			}
	}

}

var testresults
function checkTAF(){
var str=document.myForm.EmailFrom.value
var strB=document.myForm.EmailTo.value
var filter=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
if (filter.test(str))
	testresults=true
	else{
		alert("Please enter your e-mail address (for replies).")
		testresults=false
		}
if (filter.test(strB))
	testresults=true
	else{
		alert("Please enter a valid e-mail address for the person you want to send this item to.")
		testresults=false
		}
	return (testresults)
}
function checkAddy(){
if (document.layers||document.getElementById||document.all)
return checkemail()
else
return true
}

function checkAccountNEW(){
	var minLength=4;
	
	if (document.myForm.Username){
			if (document.myForm.Username.value.length < minLength) {
			alert("Please enter at least a 4 character Username.");
			document.myForm.Username.focus();
			document.myForm.Username.select();
			return false;
	  		}
		}
	if (document.myForm.Password){
		if (document.myForm.Password.value.length < minLength) {
			alert("Please enter at least a 4 character Password.");
			document.myForm.Password.focus();	
			document.myForm.Password.select();	
			return false;
		   }
		}
	if (document.myForm.Password){
		if (document.myForm.VerifyPassword.value == ''){
			 alert('Please re-enter your password for verification purposes.')
			 document.myForm.VerifyPassword.focus();
			 return false;
			}
		
		if (document.myForm.Password.value != document.myForm.VerifyPassword.value){
			 alert('Your entries in the Password and Verify Password fields did not match.\n\nPlease re-enter this information.')
			 document.myForm.Password.value=''
			 document.myForm.VerifyPassword.value=''
			 document.myForm.Password.focus();
			 return false;
			}
		}
	if (document.myForm.First_Name){
			if (document.myForm.First_Name.value == ""){
			 alert("Please enter your first name.")
			 document.myForm.First_Name.focus();
			 return false;
			}
			
		}
	if (document.myForm.Last_Name){
			if (document.myForm.Last_Name.value == ""){
			 alert("Please enter your last name.")
			 document.myForm.Last_Name.focus();
			 return false;
			 
			}
		}
	if (document.myForm.Address){
			if (document.myForm.Address.value == ""){
			 alert("Please enter your address.")
			 document.myForm.Address.focus();
			 return false;
			 
			}
		}
	if (document.myForm.City){
			if (document.myForm.City.value == ""){
			 alert("Please enter your city.")
			 document.myForm.City.focus();
			 return false;
			 
			}
		}
	if (document.myForm.state){
			if (document.myForm.state.options[document.myForm.state.selectedIndex].value == "NAP"){
			 alert("Please choose a State from the pulldown menu.")
			 document.myForm.state.focus();
			 return false;
			 
			}
		}
	//if (document.myForm.Country){
			//if (document.myForm.Country.options[document.myForm.Country.selectedIndex].value == "nap"){
			// alert("Please choose a Country from the pulldown menu.")
			// document.myForm.Country.focus();
			// return false;
			// 
			//}
		//}
	if (document.myForm.ZIP){
			if (document.myForm.ZIP.value == ""){
			 alert("Please enter your ZIP code.")
			 document.myForm.ZIP.focus();
			 return false;
			 
			}
		}
	if (document.myForm.Email){
				var str=document.myForm.Email.value
				var filter=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
				if (filter.test(str)!=true){
				 alert("Please enter a valid email address.")
				 document.myForm.Email.focus();
				document.myForm.Email.select();	
				 return false;
				
				}
		}
	if (document.myForm.Phone){
		if (document.myForm.Phone.value == ""){
	        alert("Please enter a valid Phone Number in the format ###-###-####.");
	        document.myForm.Phone.focus();
	        return false;
			
		}
		else {
			var pattern1 = /\d{3}\-\d{3}\-\d{4}/; 
		    if(!pattern1.test(document.myForm.Phone.value)) {
		        alert("Please enter a valid Phone Number in the format ###-###-####.");
		        document.myForm.Phone.focus();
				document.myForm.Phone.select();	
		        return false;
				
		      }
			}
	}
	
	if (document.myForm.Fax){
		if (document.myForm.Fax.value != ""){
			var pattern1 = /\d{3}\-\d{3}\-\d{4}/; 
		    if(!pattern1.test(document.myForm.Fax.value)) {
		        alert("Please enter a valid Fax Number in the format ###-###-####");
		        document.myForm.Fax.focus();
				document.myForm.Fax.select();	
		        return false;
				
		       }
			}
		}
		
	if (document.myForm.shippingFirstName){
			if (document.myForm.shippingFirstName.value == ""){
			 alert("Please supply the first name of the person who will be receiving shipments at this address.")
			 document.myForm.shippingFirstName.focus();
			 return false;
			 
			}
			}
		
	if (document.myForm.shippingLastName){
			if (document.myForm.shippingLastName.value == ""){
			 alert("Please supply the last name of the person who will be receiving shipments at this address.")
			 document.myForm.shippingLastName.focus();
			 return false;
			 
			}
			}
		
	if (document.myForm.ShippingAddress){
			if (document.myForm.ShippingAddress.value == ""){
			 alert("Please enter a shipping address.")
			 document.myForm.ShippingAddress.focus();
			 return false;
			 
			}
			}
			
	if (document.myForm.ShippingCity){
			if (document.myForm.ShippingCity.value == ""){
			 alert("Please enter a shipping city.")
			 document.myForm.ShippingCity.focus();
			 return false;
			 
			}
			}
			
	if (document.myForm.shippingState){
		if (document.myForm.shippingState.options[document.myForm.shippingState.selectedIndex].value == "NAP"){
			alert("Please choose a shipping state from the pulldown menu.")
			document.myForm.shippingState.focus();
			return false;
			
			}
		}
		
	if (document.myForm.shippingZIP){
			if (document.myForm.shippingZIP.value == ""){
			 alert("Please enter a shipping ZIP code.")
			 document.myForm.shippingZIP.focus();
			 return false;
			 
			}
			}
	//if (document.myForm.shippingCountry){
			//if (document.myForm.shippingCountry.options[document.myForm.shippingCountry.selectedIndex].value == "nap"){
			// alert("Please choose a Country from the pulldown menu.")
			// document.myForm.shippingCountry.focus();
			// return false;
			// 
			//}
		//}
			
	if (document.myForm.shippingEmail){
					var strS=document.myForm.shippingEmail.value
					var filterS=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
					if (filterS.test(strS)!=true){
					alert("Please enter a valid shipping email address.")
							document.myForm.shippingEmail.focus();
							document.myForm.shippingEmail.select();	
							return false;
							
							}
					}
	
	
	if (document.myForm.shippingPhone){
		if (document.myForm.shippingPhone.value == ""){
	        alert("Please enter a valid Phone Number in the format ###-###-#### for this shipping address.");
	        document.myForm.shippingPhone.focus();
	        return false;
			
		}
		else {
			var pattern1 = /\d{3}\-\d{3}\-\d{4}/
		    if(!pattern1.test(document.myForm.shippingPhone.value)) {
		        alert("Please enter a valid Phone Number in the format ###-###-#### for this shipping address.");
		        document.myForm.shippingPhone.focus();
				document.myForm.shippingPhone.select();	
		        return false;
				
		       }
			 }
		}
	
	if (document.myForm.shippingFax){
		if (document.myForm.shippingFax.value != ""){
			var pattern1 = /\d{3}\-\d{3}\-\d{4}/; 
		    if(!pattern1.test(document.myForm.shippingFax.value)) {
		        alert("Please enter a valid Fax Number in the format ###-###-#### for this shipping address.");
		        document.myForm.shippingFax.focus();
							document.myForm.shippingFax.select();	
		        return false;
				
		       }
		}
	}
}
function checkNL(){
	if (document.myForm.First_Name){
			if (document.myForm.First_Name.value == ""){
			 alert("Please enter your first name.")
			 document.myForm.First_Name.focus();
			 return false;
			}
		}
	if (document.myForm.Last_Name){
			if (document.myForm.Last_Name.value == ""){
			 alert("Please enter your last name.")
			 document.myForm.Last_Name.focus();
			 return false;
			}
		}
	var str=document.myForm.Email.value
	var filter=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/

	if(filter.test(str)!=true){
		alert('Please enter a valid email address.')
		document.myForm.Email.focus();
		return false;
	}
}

function change(id, newClass) {
	identity=document.getElementById(id);
	identity.className=newClass;
}
	function payToggleB(){
		if(this.checked==true){
		
		document.myForm.NameOnCard.disabled=true;
		document.myForm.CreditCardNumber.disabled=true;
		document.myForm.CreditCardType.disabled=true;
		document.myForm.ccv.disabled=true;
		document.myForm.ExpMonth.disabled=true;
		document.myForm.expyear.disabled=true;
		document.ccExample.src='images/content/visa-creditcardGREY.jpg';
		}
		else{
		document.myForm.NameOnCard.disabled=false;
		document.myForm.CreditCardNumber.disabled=false;
		document.myForm.CreditCardType.disabled=false;
		document.myForm.ccv.disabled=false;
		document.myForm.ExpMonth.disabled=false;
		document.myForm.expyear.disabled=false;
		document.ccExample.src='images/content/visa-creditcard.jpg';
		}
	}
	function payToggleA(){
		if(this.checked==true){
		document.myForm.NameOnCard.disabled=false;
		document.myForm.CreditCardNumber.disabled=false;
		document.myForm.CreditCardType.disabled=false;
		document.myForm.ccv.disabled=false;
		document.myForm.ExpMonth.disabled=false;
		document.myForm.expyear.disabled=false;
		document.ccExample.src='images/content/visa-creditcard.jpg';
		}
		else{
		document.myForm.NameOnCard.disabled=true;
		document.myForm.CreditCardNumber.disabled=true;
		document.myForm.CreditCardType.disabled=true;
		document.myForm.ccv.disabled=true;
		document.myForm.ExpMonth.disabled=true;
		document.myForm.expyear.disabled=true;
		document.ccExample.src='images/content/visa-creditcardGREY.jpg';
		}
	}

MM_preloadImages('images/nav/02_on.gif','images/nav/03_on.gif','images/nav/04_on.gif','images/nav/05_on.gif','images/nav/06_on.gif','images/nav/07_on.gif')
