

function P7_ExpMenu(){ //v1.1.0.2 by PVII-www.projectseven.com
 if(navigator.appVersion.indexOf("MSIE")==-1){return;}
 var i,k,g,lg,r=/\s*p7hvr/,nn='',c,cs='p7hvr',bv='p7menubar';
 for(i=0;i<10;i++){g=document.getElementById(bv+nn);if(g){
 lg=g.getElementsByTagName("LI");if(lg){for(k=0;k<lg.length;k++){
 lg[k].onmouseover=function(){c=this.className;cl=(c)?c+' '+cs:cs;
 this.className=cl;};lg[k].onmouseout=function(){c=this.className;
 this.className=(c)?c.replace(r,''):'';};}}}nn=i+1;}
}

function checkEnter(e){ //e is event object passed from function invocation
var characterCode //literal character code will be stored in this variable

if(e && e.which){ //if which property of event object is supported (NN4)
e = e
characterCode = e.which //character code is contained in NN4's which property
}
else{
e = event
characterCode = e.keyCode //character code is contained in IE's keyCode property
}

if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
checkQO() //submit the form
return false 
}
else{
return true 
}

}

function clearField(name,length)
{
if (document.getElementById(name).maxLength != length) {
    document.getElementById(name).value="";
    document.getElementById(name).maxLength=length;
    }
}

function checkQO()
{
    if (document.getElementById("QTY").value == "Qty") {document.getElementById("QTY").value = "1";}
    if (document.getElementById("Item").value == "Item Number") {document.getElementById("Item").value = "";}
    if (document.getElementById("CATCODE").value == "SourceCode:") {document.getElementById("CATCODE").value = "";}
    if (document.getElementById("SOURCECODE").value == " (optional)") {document.getElementById("SOURCECODE").value = "";}
    frmQO.submit();
}

function EmailReg()
{
var email = document.frmRegEmail.txtEmailx.value;
if (email.length<5 || email.indexOf(' ')+1 || email.indexOf(',')+1 || !(email.indexOf('@')+1) || !(email.indexOf('.')+1)) 
   {alert("Invalid email address");
    return false;
   }
else
   {urchinTracker('/form/newsletter-registration');
    frmRegEmail.submit();
   }
}

   function Validate(myForm) {
	if (!isLength(myForm.txtBFirstName.value, 1, 30)) return warnInvalid(myForm.txtBFirstName, "Billing first name must be between 1 and 30 characters in length");
	if (!isLength(myForm.txtBLastName.value, 1, 50)) return warnInvalid(myForm.txtBLastName, "Billing last name must be between 1 and 50 characters in length");
	if (!isLength(myForm.txtBAddress1.value, 1, 255)) return warnInvalid(myForm.txtBAddress1, "Billing address 1 must be between 1 and 255 characters in length");
	if (!isLength(myForm.txtBCity.value, 1, 50)) return warnInvalid(myForm.txtBCity, "Billing city must be between 1 and 50 characters in length");
	var tempBProvince = myForm.txtBProvince.value.toUpperCase();
	if (!isProvinceCode(myForm.txtBProvince.value, "US")) return warnInvalid(myForm.txtBProvince, "Billing state must be a valid 2 letter code (e.g. CA for California)");
	myForm.txtBPostalCode.value = StripNotIn(myForm.txtBPostalCode.value, digits)
	if (!isUSZipCode(myForm.txtBPostalCode.value)) return warnInvalid(myForm.txtBPostalCode, "You must enter a valid US billing zip code. (e.g. #####)");
	if (myForm.txtBPostalCode.value.length == 9) {
		myForm.txtBPostalCode.value = myForm.txtBPostalCode.value.slice(0,5) + "-" + myForm.txtBPostalCode.value.slice(5)
	}
	if (!isLength(myForm.txtBPhone.value, 1, 30)) return warnInvalid(myForm.txtBPhone, "Billing phone must be between 1 and 30 characters in length");
	if (!isLength(myForm.txtBEmail.value, 1, 200)) return warnInvalid(myForm.txtBEmail, "Billing email must be between 1 and 200 characters in length");
	if (!isEmpty(myForm.txtBEmail.value)) {
		var strBEmail = myForm.txtBEmail.value;
		if (!isEmail(strBEmail) || strBEmail.indexOf(' ')+1 || strBEmail.indexOf(',')+1) return warnInvalid(myForm.txtBEmail, "Billing email address is invalid.");
	}
	if (!isLength(myForm.txtSFirstName.value, 1, 30)) return warnInvalid(myForm.txtSFirstName, "Shipping first name must be between 1 and 30 characters in length");
	if (!isLength(myForm.txtSLastName.value, 1, 50)) return warnInvalid(myForm.txtSLastName, "Shipping last name must be between 1 and 50 characters in length");
	if (!isLength(myForm.txtSAddress1.value, 1, 255)) return warnInvalid(myForm.txtSAddress1, "Shipping address 1 must be between 1 and 255 characters in length");
	if (!isLength(myForm.txtSCity.value, 1, 50)) return warnInvalid(myForm.txtSCity, "Shipping city must be between 1 and 50 characters in length");
	var tempSProvince = myForm.txtSProvince.value.toUpperCase();
	if (!isProvinceCode(myForm.txtSProvince.value, "US")) return warnInvalid(myForm.txtSProvince, "Shipping state must be a valid 2 letter code (e.g. CA for California)");
	myForm.txtSPostalCode.value = StripNotIn(myForm.txtSPostalCode.value, digits)
	if (!isUSZipCode(myForm.txtSPostalCode.value)) return warnInvalid(myForm.txtSPostalCode, "You must enter a valid US 5-digit zip code. (e.g. #####)");
	if (!isLength(myForm.txtSPhone.value, 1, 30)) return warnInvalid(myForm.txtSPhone, "Shipping phone must be between 1 and 30 characters in length");
	if (!isLength(myForm.txtSEmail.value, 1, 200)) return warnInvalid(myForm.txtSEmail, "Shipping email must be between 1 and 200 characters in length");
	if (!isEmpty(myForm.txtSEmail.value)) {
		var strSEmail = myForm.txtSEmail.value;
		if (!isEmail(strSEmail) || strSEmail.indexOf(' ')+1 || strSEmail.indexOf(',')+1) return warnInvalid(myForm.txtSEmail, "Shipping email address is invalid.");
	}
	return true;
   }

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];}}
}

var submitRolls = new Object();

function submitroll(src, oversrc, name)
{
this.src=src;
this.oversrc=oversrc;
this.name=name;
this.alt="";
this.write=submitroll_write;
}

function submitroll_write()
{
var thisform = 'document.forms[' + (document.forms.length - 1) + ']';
submitRolls[this.name] = new Object();
submitRolls[this.name].over = new Image();
submitRolls[this.name].over.src = this.oversrc;
submitRolls[this.name].out = new Image();
submitRolls[this.name].out.src = this.src;

document.write
	(
	'<A onMouseOver="if (document.images)document.images[\'' + this.name + "'].src=submitRolls['" + this.name + '\'].over.src"' + 
	' onMouseOut="if (document.images)document.images[\'' + this.name + "'].src=submitRolls['" + this.name + '\'].out.src"' + 
	' HREF="javascript:'
	);

if (this.sendfield)
	{
	if (! this.sendvalue)
		this.sendvalue = 1;
	document.write(thisform, ".elements['", this.sendfield, "'].value='", this.sendvalue, "';");
	}

if (this.name == "mysubmit3") document.write('checkQO();"');
else if (this.name == "mysubmit2") document.write('EmailReg();"');

else document.write(thisform + '.submit();void(0);"');
if (this.msg)document.write(' onClick="return confirm(\'' , this.msg, '\')"');
document.write('>');

document.write('<IMG SRC="' + this.src + '" ALT="' + this.alt + '" BORDER=0 NAME="' + this.name + '"');
if (this.height)document.write(' HEIGHT=' + this.height);
if (this.width)document.write(' WIDTH='  + this.width);
if (this.otheratts)document.write(' ' + this.otheratts);
document.write('></A>');
if (this.sendfield)
	{
	document.write('<INPUT TYPE=HIDDEN NAME="' + this.sendfield + '">');
	document.forms[document.forms.length - 1].elements[this.sendfield].value='';
	}
}
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];}
}
