<!-- BEGIN: Hiding Javascript module from old browsers

//=============================================================================
//================== COPYRIGHT NOTICE =========================================
// NOV  8 2008: External Javascript called by Unlock.htm
// NOV  8 2009: Adapted from www.protext.com/ordersecure.js
// This code is too large to cleanly fit inside a HTML file.
// COPYRIGHT 2007 by:
// Val "Rocky" Patterson
// ETS Inc.
// 1115 East Brigadoon Ct
// Salt Lake City, UT 84117
// MrETS@xmission.com
// www.ProTEXT.com
// www.SaltLakeMetals.com
//================== COPYRIGHT NOTICE =========================================
// This code was written by and is copyrighted by Val Patterson.
// There is some PROPRIETARY CODE contained in this module.
// ESPECIALLY dealing with worldwide Credit Card information.
// It is expressly forbidden to even VIEW this credit card validation code,
// Let alone copy it, or use it in your application.
// If I ever see this credit card validation code on the World Wide Web,
// I will hunt you down and prosecute you for stealing this code.
// Val "Rocky" Patterson
//================== COPYRIGHT NOTICE =========================================
//=============================================================================

var gCookieName = "Unlock";

// Called from <body onload= tag
function OnLoadBody() {
   RestoreFormCookie();   // Read Cookies (if any) into form values
}

//=============================================================================
// The Form Reset button is hooked to call this function
// when the user presses the 'Clear Form' or 'Reset Form' button
// The Form object is passed by the calling button: using: this.form
//=============================================================================
function ResetForm( theForm ) {
   theForm.reset();   // Call Browsers DOM default reset() first
}


//================================
// Returns True if Email is Valid
function EmailBad( email ) {
 var Result   = 0;
 var AtSym    = email.indexOf('@');
 var Period   = email.lastIndexOf('.');
 var Space    = email.indexOf(' ');
 var Length   = email.length - 1; // Array is from 0 to length-1
 if( (AtSym < 1) ||               // '@' cannot be in first position
     (Period <= AtSym+1) ||       // Must be atleast one valid char btwn '@' and '.'
     (Period == Length ) ||       // Must be atleast one valid char after '.'
     (Space  != -1))              // No empty spaces permitted
   {  
      Result = 1; // bad
   }
 return Result;
}
//=============================================================================
// Format Phone Number from: Anything to: (ddd)ddd-dddd
// Added: OCT 4 2007
//=============================================================================
function FormatPhoneNumber( szInitialString ) {
 var FmtStr="";    // Resulting Phone Number String
 var len = szInitialString.length;
 var j;
 for( j=0; j<len; j++ ) {
    if( isNaN(parseInt(szInitialString.charAt(j))) ) {
       j = j;   // Not a Number, do nothing
    } else {
       FmtStr = FmtStr + szInitialString.charAt(j);
    }
 }
 if( FmtStr.length == 10 ) {   // Good Exit, return Formatted Phone Number
    FmtStr = "("+FmtStr.substring(0,3)+")"+FmtStr.substring(3,6)+"-"+FmtStr.substring(6,10);
 }
 return FmtStr;
}
//=============================================================================
// Make sure an input field contains only digits 0-9
//=============================================================================
function allNumeric(objName) {
  if( isNaN(objName) ) return false;
  return true;
}


//====================================================================
// Validadate the FORM on "Submit"
// Called by 'onsubmit(this)' from <form> tag in HTML
// returns FALSE (and alerts) if form fails validation
// returns TRUE and calls the Perl script if validation passes
//====================================================================
function ValidateForm(theForm) {
  var str = "";   // String variable
  theForm.Phone1.value = FormatPhoneNumber( theForm.Phone1.value ); // Standardize Phone Numbers
  theForm.Phone2.value = FormatPhoneNumber( theForm.Phone2.value ); // Standardize Phone Numbers
  // Begin validation ------------------------------------------------------------------------------
  if( theForm.Name.value.length < 25 ) {
    alert("Please enter a Valid Name and Address\n");
    theForm.Name.focus(); return false;
  }
  if( theForm.Phone1.value.length < 10 )  {   // dddddddddd = 10 chars -or- (ddd)ddd-dddd = 13 chars
    alert("Please enter your Phone number, with the Area Code.\nYou will only be contacted if there is a problem.\nWe keep all phone numbers confidential.");
    theForm.Phone1.focus(); return false;
  }
  if( EmailBad(theForm.Email.value) ) {
    alert("Please enter a Valid E-Mail Address.\nThis is where your Unlock Code will be e-mailed.");
    theForm.Email.focus(); return false;
  }
  if( theForm.Unlock1.value.length < 6 ) {
    alert("Please enter a Valid Unlock Number\n");
    theForm.Unlock1.focus(); return false;
  }
  if( theForm.Unlock2.value.length < 2 ) {
    alert("Please enter a Valid Unlock Number\n");
    theForm.Unlock2.focus(); return false;
  }
  if( !allNumeric(theForm.Unlock1.value) ) {
    alert("Please enter a Valid Unlock Number\n");
    theForm.Unlock1.focus(); return false;
  }
  if( !allNumeric(theForm.Unlock2.value) ) {
    alert("Please enter a Valid Unlock Number\n");
    theForm.Unlock2.focus(); return false;
  }
  SaveFormCookie();           // Save important form data to cookie
  return true;
}



//================================================
//================================================
// COOKIE ROUTINES:
// NOTE: "gCookieName" is Global to this JavaScript
//================================================
//================================================
// eg: DeleteCookie( )
function DeleteCookie( ) {
 var exp = new Date();
 exp.setTime(exp.getTime()-1) // Bye Bye Cookie
 var cval = GetCookie(gCookieName);
 document.cookie = gCookieName + "=" + cval + "; expires=" + exp.toGMTString();
}
//================================================
// eg: SetCookie( name, value, expires, path, domain, secure ) 
function SetCookie( name, value ) {
 var argv = SetCookie.arguments;
 var argc = SetCookie.arguments.length;
 var expires = (argc>2) ? argv[2] : null;
 var path =    (argc>3) ? argv[3] : null;
 var domain =  (argc>4) ? argv[4] : null;
 var secure =  (argc>5) ? argv[5] : false;
 document.cookie = name + "=" 
          + escape(value)
          + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) 
          + ((path == null)    ? "" : ("; path=" + path)) 
          + ((domain == null)  ? "" : ("; domain=" + domain)) 
          + ((secure == true)  ? "; secure" : "");
}
//==============================================
// Returns value for cookie name, or null
function GetCookie( name ) {
 var arg  = name + "=";
 var alen = arg.length;
 var clen = document.cookie.length;
 var i = 0;
 while( i < clen ) {
  var j = i + alen;
  if( document.cookie.substring(i,j) == arg) return GetCookieVal(j);
  i = document.cookie.indexOf(" ", i) + 1;
  if( i==0 ) break;
 }
 return null;
}
//==============================================
function GetCookieVal( offset ) {
 var endstr = document.cookie.indexOf( ";", offset );
 if( endstr == -1 ) endstr = document.cookie.length;
 return unescape(document.cookie.substring(offset,endstr));
}
//==============================================
function RestoreFormCookie( ) {
 // if( navigator.cookieEnabled == false ) return;  // Cookies not enabled
 var val = GetCookie(gCookieName);
 if( val==null ) return; // No cookie
 var form = document.forms[0];
 with( form ) {
  Name.value   = GetCookie("Name");
  Phone1.value = GetCookie("Phone1");
  Phone2.value = GetCookie("Phone2");
  Email.value  = GetCookie("Email");
 }  
}
//==============================================
// Save the Important elements of the form
function SaveFormCookie( ) {
 // if( navigator.cookieEnabled == false ) return;  // Cookies not enabled
 var expiryDate = new Date();
 expiryDate.setTime(expiryDate.getTime() + (365*24*60*60*1000)); // 365 days of Msecs
 // Set last value non-null for secure channel requirement
 // Note: Setting "secure" means cookie won't work for debugging off local drive!
 // SetCookie(gCookieName,"Address,Phone,Email,CardNumber,CardExpiry,CardName",expiryDate,null,null,0); // OLD
 SetCookie(gCookieName,"This Cookie saves your Shipping Address, etc.\nto save you re-typing the next time you visit.",expiryDate,null,null,0);  // Apr 22 2007 NEW
 var form = document.forms[0];
 with( form ) {
  SetCookie("Name",   Name.value,   expiryDate );
  SetCookie("Phone1", Phone2.value, expiryDate );
  SetCookie("Phone2", Phone2.value, expiryDate );
  SetCookie("Email",  Email.value,  expiryDate );
 }
}



// END: Hiding from old browsers -->


