

function BrowserStats() {
  var userAgent = " " + navigator.userAgent.toLowerCase();
  // determine nn/ie, rounded version number and platform
  this.nn = userAgent.indexOf( "mozilla" ) > 0;
  // "compatible" versions of mozilla are not netscape
  if( userAgent.indexOf( "compatible" ) > 0 )
    this.nn = false;
  this.ie = userAgent.indexOf( "msie" ) > 0;
  this.version = navigator.appVersion;
  this.major = parseInt( this.version );
  this.mac = userAgent.indexOf( "mac" ) > 0;
  // ie 5 reports itself as 4
  if( this.ie ) {
    if( userAgent.indexOf( "msie 5" ) > 0 )
      this.major = 5;
  }
  return this;
}

var browser = new BrowserStats();

// font platform resize
var platformCSS;
if( browser.mac && browser.major >= 5 ) {
  platformCSS = "ieadjust.css";
} else if( browser.mac ){
  platformCSS = "v4adjustMac.css";
}
if( !browser.mac && browser.ie ) {
  platformCSS = "ieadjust.css";
}
if( browser.nn && browser.major >= 5 ) {
  platformCSS = "ieadjust.css";
}
if( platformCSS ){
  document.write( "<link rel='stylesheet' href='/Shared/" + platformCSS + "'type='text/css'>" );
}

var currentField, nextField, maxChars; 
function advance(c,n,m) { 
    currentField = c, nextField = n, maxChars = m;
    if (currentField.value.length == maxChars)
      document.fulfillment['A36$2$email'].focus();
    setTimeout('effect()',1);
}

function effect() {
    if (currentField.value.length == maxChars)
        document.fulfillment[nextField].focus();
}

function getBrandFromURI() {
/* uses the current url to try to guess the brand, defaults to null if no brand can be obtained */
  var uri = document.location.toString();
  var brand = null;
  if( uri.toLowerCase().indexOf( "chrysler" ) > -1 ) brand = "C";
  if( uri.toLowerCase().indexOf( "dodge" ) > -1 )    brand = "D";
  if( uri.toLowerCase().indexOf( "jeep" ) > -1 )     brand = "J";
  return brand;
}

/*
Query String Routines - These functions provide access to the query string passed to a web page
*/

// The main function - usage: queryString( "name of parameter" );
function queryString(key) {
  var value = null;
  for (var i=0;i<queryString.keys.length;i++) {
    if (queryString.keys[i]==key) {
      value = queryString.values[i];
      break;
  }
}
 return value;
}

// Support function to split the name value pairs into their respective arrays
function queryString_Parse() {
  var query = window.location.search.substring(1);
  var pairs = query.split("&");
  for (var i=0;i<pairs.length;i++) {
    var pos = pairs[i].indexOf('=');
    if (pos >= 0) {
      var argname = pairs[i].substring(0,pos);
      var value = pairs[i].substring(pos+1);
      queryString.keys[queryString.keys.length] = argname;
      queryString.values[queryString.values.length] = value;                
    }
  }
}

// Initialize key / value arrays
queryString.keys = new Array();
queryString.values = new Array();
queryString_Parse();  // You need to call this function once
