<!--
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;
}

// Check form for required information
function YY_checkform() { //v4.71
  var a=YY_checkform.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
    v=o.value;t=a[i+2];
    if (o.type=='text'||o.type=='password'||o.type=='hidden'||o.type=='input'){
      if (r&&v.length==0){err=true}
      if (v.length>0)
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      }
    } else
    if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo){s+='* '+a[i+3]+'\n'}
      }
    } else if (o.type=='checkbox'){
      if((t==1&&o.checked==false)||(t==2&&o.checked&&o1&&o1.value.length/1==0)){err=true}
    } else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
    }else if (o.type=='textarea'){
      if(v.length<a[i+1]){err=true}
    }
    if (err){s+='* '+a[i+3]+'\n'; err=false}
  }

  if (s!=''){alert('The following is either incomplete or contains errors ...\t\n\n'+s)}
  document.MM_returnValue = (s=='');
}

// Open window
function MM_openBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}

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_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];}
}

// Check country selection
function checkCountry() {
	var Country = document.form1.Country.value;
	if (Country=='US')	{
	document.form1.Province.disabled=1;
	document.form1.State.disabled=0;
	}
	else {
	document.form1.Province.disabled=0;
	document.form1.State.disabled=1;
	}
}

// Auto-Tab fields
var field_length=0;
function TabNext(obj,event,len,next_field) {
	if (event == "down") {
		field_length=obj.value.length;
		}
	else if (event == "up") {
		if (obj.value.length != field_length) {
			field_length=obj.value.length;
			if (field_length == len) {
				next_field.focus();
				}
			}
		}
	}

// Enter numbers only
function maskKeyPress(objEvent) 
{
	var iKeyCode;  	
	iKeyCode = objEvent.keyCode;			
	if(iKeyCode>=48 && iKeyCode<=57) return true;
	return false;
}



function  copyAddress() { 
if (document.form1.useShippingAddress.checked == true) 
{
	document.form1.billFirstName.value = document.form1.shipFirstName.value;
	document.form1.billLastName.value = document.form1.shipLastName.value;
	document.form1.billCompany.value = document.form1.shipCompany.value;
	document.form1.billAddress1.value = document.form1.shipAddress1.value;
	document.form1.billAddress2.value = document.form1.shipAddress2.value;
	document.form1.billCity.value = document.form1.shipCity.value;
	document.form1.State.value = document.form1.shipState.value;
	document.form1.Province.value = document.form1.shipProvince.value;
	document.form1.billZip.value = document.form1.shipZip.value;
	document.form1.Country.value = document.form1.shipCountry.value;
	document.form1.billPhone1.value = document.form1.shipPhone1.value;
	document.form1.billPhone2.value = document.form1.shipPhone2.value;
	document.form1.billPhone3.value = document.form1.shipPhone3.value;
	document.form1.billCphone1.value = document.form1.shipCphone1.value;
	document.form1.billCphone2.value = document.form1.shipCphone2.value;
	document.form1.billCphone3.value = document.form1.shipCphone3.value;
	document.form1.billCphoneExt.value = document.form1.shipCphoneExt.value;
	document.form1.billFax1.value = document.form1.shipFax1.value;
	document.form1.billFax2.value = document.form1.shipFax2.value;
	document.form1.billFax3.value = document.form1.shipFax3.value;
}
else
{
	document.form1.billFirstName.value = '';
	document.form1.billLastName.value = '';
	document.form1.billCompany.value = '';
	document.form1.billAddress1.value = '';
	document.form1.billAddress2.value = '';
	document.form1.billCity.value = '';
	//document.form1.State.value = '';
	//document.form1.Province.value = '';
	document.form1.billZip.value = '';
	//document.form1.Country.value = '';
	document.form1.billPhone1.value = '';
	document.form1.billPhone2.value = '';
	document.form1.billPhone3.value = '';
	document.form1.billCphone1.value = '';
	document.form1.billCphone2.value = '';
	document.form1.billCphone3.value = '';
	document.form1.billCphoneExt.value = '';
	document.form1.billFax1.value = '';
	document.form1.billFax2.value = '';
	document.form1.billFax3.value = '';
}
}

/* ---------------------------------------------------------------
MOD
   Date: 6/15/2008
 Author: jroulette
Purpose: checkSearchForm function validates search form input.
         checkLoginForm functin validates login form input.
--------------------------------------------------------------- */
function checkSearchForm() {
    var fld0 = document.productsearch.q
    var filter = /^[ A-Za-z0-9&'\-\.]*$/	//allows alpha-numeric, -, &, ', and period.
    
    if(fld0.value=='') {
        fldstatus = false;
        fld0.focus();
        alert('Please provide a search word or phrase.');
    }
	else if (!filter.test(fld0.value)) {
		fldstatus = false;
		fld0.select();
		alert('Please provide a valid search word or phrase.\nNote: Search phrase can contain letters and numbers only.');
    }
    else {
        fldstatus = true;
    }
    return (fldstatus)
}

function checkLoginForm(){
	var emailFld=document.form1.cEmail
	var pwdFld=document.form1.cPassword
	
	var strEmail=emailFld.value						
	strEmail = strEmail.replace(/^\s*|\s*$/g,"");	// <--doing a 'trim' client-side
	
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

	if (strEmail=='')
		{
		fldstatus = false;
		alert('Please provide an Email address.');
		emailFld.focus();
		}
	else if (!filter.test(strEmail))
		{
		fldstatus = false;
		emailFld.select();
		alert('Please provide a valid Email address.');
		}
	else if (pwdFld.value=='' && document.form1.action3.checked==true)
		{
		fldstatus = false;
		alert('If you have a password, please provide it.\nIf you\'ve forgotten your password, please click\nthe \"Forgot your password?\" link, below.');
		emailFld.focus();
		}
	else{
		fldstatus = true;
		}
	return (fldstatus)
}


//-->
