function toggle(targetId) {
  if (document.getElementById) {
  		target = document.getElementById( targetId );
  			if (target.style.display == "none") {
  				target.style.display = "";
  			} else {
  				target.style.display = "none";
  			}
  	}
}

function togglehide(targetId) {
  if (document.getElementById) {
  		target = document.getElementById( targetId );
		target.style.display = "none";
  }
}

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];}
}
FlashObject = function(swf, id, w, h, ver, c, dt, sp, linkURL) {
	this.swf = swf;
	this.id = id;
	this.width = w;
	this.height = h;
	this.version = ver || 6; // default to 6
	this.displaytype = dt;
	this.subpicturepath = sp;
	this.subpicturelink = linkURL;
	
	this.align = "middle"; // default to middle
	this.redirect = "";
	this.sq = document.location.search.split("?")[1] || "";
	this.altTxt = "Please <a href='http://www.macromedia.com/go/getflashplayer'>upgrade/install your Flash Player</a>.";
	this.bypassTxt = "";
	this.params = new Object();
	this.variables = new Object();
	if (c) this.color = this.addParam('bgcolor', c);
	this.addParam('quality', 'high'); // default to high
	this.doDetect = getQueryParamValue('detectflash');
}

FlashObject.prototype.addParam = function(name, value) {
	this.params[name] = value;
}

FlashObject.prototype.getParams = function() {
    return this.params;
}

FlashObject.prototype.getParam = function(name) {
    return this.params[name];
}

FlashObject.prototype.addVariable = function(name, value) {
	this.variables[name] = value;
}

FlashObject.prototype.getVariable = function(name) {
    return this.variables[name];
}

FlashObject.prototype.getVariables = function() {
    return this.variables;
}

FlashObject.prototype.getParamTags = function() {
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    if (paramTags == "") {
        paramTags = null;
    }
    return paramTags;
}

FlashObject.prototype.getHTML = function() {
    var flashHTML = "";
    if (window.ActiveXObject && navigator.userAgent.indexOf('Mac') == -1) { // PC IE
        flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '">';
        flashHTML += '<param name="movie" value="' + this.swf + '" />';
        if (this.getParamTags() != null) {
            flashHTML += this.getParamTags();
        }
        if (this.getVariablePairs() != null) {
            flashHTML += '<param name="flashVars" value="' + this.getVariablePairs() + '" />';
        }
        flashHTML += '</object>';
    }
    else { // Everyone else
        flashHTML += '<embed type="application/x-shockwave-flash" src="' + this.swf + '" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '"';
        for (var param in this.getParams()) {
            flashHTML += ' ' + param + '="' + this.getParam(param) + '"';
        }
        if (this.getVariablePairs() != null) {
            flashHTML += ' flashVars="' + this.getVariablePairs() + '"';
        }
        flashHTML += '></embed>';
    }
    return flashHTML;	
}


FlashObject.prototype.getVariablePairs = function() {
    var variablePairs = new Array();
    for (var name in this.getVariables()) {
        variablePairs.push(name + "=" + escape(this.getVariable(name)));
    }
    if (variablePairs.length > 0) {
        return variablePairs.join("&");
    }
    else {
        return null;
    }
}

FlashObject.prototype.write = function(elementId) {
	if(detectFlash(this.version) || this.doDetect=='false') {
		if (elementId) {
			document.getElementById(elementId).innerHTML = this.getHTML();
		} else {
			document.write(this.getHTML());
		}
	} else {
		if (this.redirect != "") {
			document.location.replace(this.redirect);
		} else {
			if (this.displaytype == "pic")
			{
				if (elementId) {
					document.getElementById(elementId).innerHTML = "<!--beep-->"
				} else {
					document.write("<a href='" + this.subpicturelink + "'>" + "<img src='" + this.subpicturepath + "' border='0' width='" + this.width + "' height='" + this.height + "'></a>");
				}

			} else {
				// displaytype == ""
			}
		}
	}		
}

function getFlashVersion() {
	var flashversion = 0;
	if (navigator.plugins && navigator.plugins.length) {
		var x = navigator.plugins["Shockwave Flash"];
		if(x){
			if (x.description) {
				var y = x.description;
	   			flashversion = y.charAt(y.indexOf('.')-1);
			}
		}
	} else {
		result = false;
	    for(var i = 15; i >= 3 && result != true; i--){
   			execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
   			flashversion = i;
   		}
	}
	return flashversion;
}

function detectFlash(ver) {	
	if (getFlashVersion() >= ver) {
		return true;
	} else {
		return false;
	}
}

// get value of querystring param
function getQueryParamValue(param) {
	var q = document.location.search;
	var detectIndex = q.indexOf(param);
	var endIndex = (q.indexOf("&", detectIndex) != -1) ? q.indexOf("&", detectIndex) : q.length;
	if(q.length > 1 && detectIndex != -1) {
		return q.substring(q.indexOf("=", detectIndex)+1, endIndex);
	} else {
		return "";
	}
}

/* add Array.push if needed */
if(Array.prototype.push == null){
	Array.prototype.push = function(item){
		this[this.length] = item;
		return this.length;
	}
}

var rules = new Array();
rules.push("required,r_firstname,Please enter your first name.");
rules.push("required,r_lastname,Please enter your last name.");
rules.push("required,r_company,Please enter your company.");
rules.push("required,r_phone,Please enter your phone number.");
rules.push("required,r_email,Please enter your email address.");
rules.push("valid_email,r_email,Please enter a valid email address.");


var claimrules = new Array();
claimrules.push("required,r_claimant,Please enter the company.");
claimrules.push("required,r_address,Please enter the address.");
claimrules.push("required,r_city,Please enter the city.");
claimrules.push("required,r_prov,Please enter the province or state.");
claimrules.push("required,r_postal,Please enter the postal code or zip code.");
claimrules.push("required,r_contact,Please enter the contact name.");
claimrules.push("required,r_email,Please enter the claimant email.");
claimrules.push("required,r_phone,Please enter the claimant phone.");
claimrules.push("required,r_commodity,Please enter the commodity.");
claimrules.push("required,r_poNumber,Please enter PO number.");
claimrules.push("required,r_iflRef,Please enter IFL reference.");
claimrules.push("required,r_intentClaim,Please enter intent to claim.");
claimrules.push("required,r_cdn,Please enter $CDN amount.");

var bolrules = new Array();
bolrules.push("required,r_carrier,Please enter your carrier.");
bolrules.push("required,r_prepared,Please enter perpared by.");
bolrules.push("required,r_shipper,Please enter shipped by.");
bolrules.push("required,r_email,Please enter email.");
bolrules.push("required,r_carAddress,Please enter carrier address.");
bolrules.push("required,r_carCity,Please enter carrier city.");
bolrules.push("required,r_carState,Please enter carrier state/province.");
bolrules.push("required,r_carZip,Please enter carrier zip/postal code.");
bolrules.push("required,r_cosignee,Please enter a cosignee.");
bolrules.push("required,r_cosAddress,Please enter cosignee address.");
bolrules.push("required,r_cosCity,Please enter cosignee city.");
bolrules.push("required,r_cosState,Please enter cosignee state/province.");
bolrules.push("required,r_cosZip,Please enter cosignee zip/postal code.");
bolrules.push("required,r_orderNumber,Please enter your order number.");
bolrules.push("required,r_shipperRef,Please enter shipper reference number.");
bolrules.push("required,r_poNumber,Please enter PO number.");
bolrules.push("required,r_notExceed,Please enter not exceed amount.");
bolrules.push("required,r_perShipper,Please enter Per Shipper.");
bolrules.push("required,r_perShipper2,Please enter Per Shipper.");
bolrules.push("required,r_shipDate,Please enter ship date.");
bolrules.push("required,r_perDriver,Please enter Per Driver.");
bolrules.push("required,r_pickupDate,Please enter pick up date.");
bolrules.push("required,r_pickupTime,Please enter pick up time.");

var creditrules = new Array();
creditrules.push("required,r_companyName,Please enter your company name.");
creditrules.push("required,r_contactName,Please enter your contact name.");
creditrules.push("required,r_email,Please enter your contact email.");
creditrules.push("required,r_address,Please enter your address.");
creditrules.push("required,r_city,Please enter your city.");
creditrules.push("required,r_state,Please enter your state/province.");
creditrules.push("required,r_zip,Please enter your zip/posctal code.");
creditrules.push("required,r_phone,Please enter your phone.");
creditrules.push("required,r_fax,Please enter your fax.");
creditrules.push("required,r_website,Please enter your website.");
creditrules.push("required,r_gst,Please enter your gst/irs number.");
creditrules.push("required,r_acctname,Please enter your Accounts Payable Contact Name.");
creditrules.push("required,r_acctphn,Please enter your Accounts Payable phone number.");
creditrules.push("required,r_years,Please enter your years in business.");
creditrules.push("required,r_bankInfo,Please enter your bank information.");
creditrules.push("required,r_bankContact,Please enter your bank contact.");
creditrules.push("required,r_bankEmail,Please enter your bank email.");
creditrules.push("required,r_bankPhone,Please enter your bank phone.");
creditrules.push("required,r_bankFax,Please enter your bank fax.");
creditrules.push("required,r_creditLimit,Please enter your credit limit request.");
creditrules.push("required,r_invoiceCurrency,Please enter your invoice currency.");
creditrules.push("required,r_transRef1,Please enter your transportation reference.");
creditrules.push("required,r_transRef1Phone,Please enter your transportation reference phone.");
creditrules.push("required,r_transRef1Fax,Please enter your transportation reference fax.");
creditrules.push("required,r_transRef2,Please enter your transportation reference.");
creditrules.push("required,r_transRef2Phone,Please enter your transportation reference phone.");
creditrules.push("required,r_transRef2Fax,Please enter your transportation reference fax.");
creditrules.push("required,r_tradeRef1,Please enter your trade reference.");
creditrules.push("required,r_tradeRef1Phone,Please enter your trade reference phone.");
creditrules.push("required,r_tradeRef1Fax,Please enter your trade reference fax.");
creditrules.push("required,r_tradeRef2,Please enter your trade reference.");
creditrules.push("required,r_tradeRef2Phone,Please enter your trade reference phone.");
creditrules.push("required,r_tradeRef2Fax,Please enter your trade reference fax.");
creditrules.push("required,r_name,Please enter your name.");
creditrules.push("required,r_title,Please enter your title.");
creditrules.push("required,r_signDate,Please enter the date.");


<!--

	
/*--------------------------------------------------------------------------------------------*\
  Function: validateFields()
  Purpose:  validates required fields on forms
\*--------------------------------------------------------------------------------------------*/

function validateFields(form, fieldInfo)
{

  // loop through fieldInfo
  for (var i=0; i<fieldInfo.length; i++)
  {
    // split row into component parts 
    var row = fieldInfo[i].split(",");

    // while the row begins with "if:..." test the condition. If true, strip the
    // if:..., part and continue evaluating the rest of the line. Keep repeating 
    // this while the line begins with an if-condition. If it fails any of the 
    // conditions, don't bother validating the rest of the line.
    var satisfiesIfConditions = true;
    while (row[0].match("^if:"))
    {
      var condition = row[0];
      condition = condition.replace("if:", "");
      var parts = condition.split("=");
      var fieldToCheck = parts[0];
      var valueToCheck = parts[1];

      // find value of FIELDNAME for conditional check
      var fieldnameValue = "";      
      if (form[fieldToCheck].type == undefined) // RADIO
      {
        for (var j=0; j<form[fieldToCheck].length; j++)
        {
          if (form[fieldToCheck][j].checked)
            fieldnameValue = form[fieldToCheck][j].value;
        }
      }
      else                    // ALL OTHER FIELD TYPES
        fieldnameValue = form[parts[0]].value;

      // if the VALUE is NOT the same, we don't need to validate this field. Return.
      if (fieldnameValue != valueToCheck)
      {
        satisfiesIfConditions = false;
        break;
      }
      else 
        row.shift();    // remove this if-condition from line, and continue validating line
    }

    if (!satisfiesIfConditions)
      continue;


    var requirement = row[0];
    var fieldName   = row[1];

    // depending on the validation test, store the incoming strings for use later...
    if (row.length == 6)        // valid_date
    {
      var fieldName2   = row[2];
      var fieldName3   = row[3];
      var date_flag    = row[4];
      var errorMessage = row[5];
    }
    else if (row.length == 4)     // same_as
    {
      fieldName2   = row[2];
      errorMessage = row[3];
    }
    else
      errorMessage = row[2];    // everything else!


    // if the requirement is "length=...", rename requirement to "length" for switch statement
    if (requirement.match("^length="))
    {
      var lengthRequirements = requirement;
      requirement = "length";
    }

    // if the requirement is "range=...", rename requirement to "range" for switch statement
    if (requirement.match("^range="))
    {
      var rangeRequirements = requirement;
      requirement = "range";
    }


    // now, validate whatever is required of the field
    switch (requirement)
    {
      case "required":
        // if radio buttons, do separate check:
        if (form[fieldName].type == undefined)
        {
          var oneIsChecked = false;
          for (j=0; j<form[fieldName].length; j++)
          {
            if (form[fieldName][j].checked)
              oneIsChecked = true;
          }
          if (!oneIsChecked)
          {
            alertMessage(form[fieldName], errorMessage);
            return false;           
          }
        }
        // otherwise, just perform ordinary "required" check.
        else if (!form[fieldName].value)
        {         
          alertMessage(form[fieldName], errorMessage);
          return false;
        }
        break;

      case "digits_only":       
        if (form[fieldName].value && form[fieldName].value.match(/\D/))
        {
          alertMessage(form[fieldName], errorMessage);
          return false;
        }
        break;

      case "length":
        var result  = lengthRequirements.replace("length=", "");
        var range_or_exact_number = result.match(/[^_]+/);
        var fieldCount = range_or_exact_number[0].split("-");

        // if the user supplied two length fields, make sure the field is within that range
        if (fieldCount.length == 2)
        {
          if (form[fieldName].value.length < fieldCount[0] || form[fieldName].value.length > fieldCount[1])
            {
            alertMessage(form[fieldName], errorMessage);
            return false;
          }
        }

        // otherwise, check it's EXACTLY the size the user specified 
        else
        {
          if (form[fieldName].value.length != fieldCount[0])
          {
            alertMessage(form[fieldName], errorMessage);
            return false;
          }
        }       
        break;

      // this is also true if field is empty [should be same for digits_only]
      case "valid_email":
        if (form[fieldName].value && !isValidEmail(form[fieldName].value))
        {
          alertMessage(form[fieldName], errorMessage);
          return false;         
        }
        break;

      case "valid_date":

        // this is written for future extensibility of isValidDate function to allow 
        // checking for dates BEFORE today, AFTER today, IS today and ANY day.
        var isLaterDate = false;
        if    (date_flag == "later_date")
          isLaterDate = true;
        else if (date_flag == "any_date")
          isLaterDate = false;

        if (!isValidDate(form[fieldName].value, form[fieldName2].value, form[fieldName3].value, isLaterDate))
        {
          alertMessage(form[fieldName], errorMessage);
          return false;
        }
        break;

      case "same_as":
        if (form[fieldName].value != form[fieldName2].value)
        {
          alertMessage(form[fieldName], errorMessage);
          return false;
        }       
        break;

      case "range":
        result  = rangeRequirements.replace("range=", "");
        var rangeValues = result.split("-");
        
        // if the user supplied two length fields, make sure the field is within that range
        if ((form[fieldName].value < Number(rangeValues[0])) || (form[fieldName].value > Number(rangeValues[1])))
        {
          alertMessage(form[fieldName], errorMessage);
          return false;
        }
        break;

      default:
        alert("Unknown requirement flag in validateFields(): " + requirement);
        return false;
    }
  }
  
  return true;
}


/*--------------------------------------------------------------------------------------------*\
  Function: alertMessage()
  Purpose:  simple helper function which alerts a message, then focuses on and highlights 
        a particular field.
\*--------------------------------------------------------------------------------------------*/
function alertMessage(obj, message)
{ 
  var backgroundColor = "#e4edc6";

  alert(message);

  // if "obj" is an array: it's a radio button. Focus on the first element.
  if (obj.type == undefined)
    obj[0].focus();
  else
  {
    obj.style.background = backgroundColor;
    obj.focus();
  }
  return false;
}


function isValidEmail(str)
{
  // trim starting / ending whitespace
  str = str.replace(/^\s*/, "");
  str = str.replace(/\s*$/, "");

  var at="@"
  var dot="."
  var lat=str.indexOf(at)
  var lstr=str.length
  var ldot=str.indexOf(dot)

  if (str.indexOf(at)==-1)
    return false
  
  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
    return false
  
  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
    return false

  if (str.indexOf(at,(lat+1))!=-1)
    return false

  if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
    return false

  if (str.indexOf(dot,(lat+2))==-1)
    return false

  if (str.indexOf(" ")!=-1)
    return false

  return true;
}


// helper function to check to see if a string is empty
function isEmpty(str)
{  
  return ((str == null) || (str.length == 0));
}


/*--------------------------------------------------------------------------------------------*\
  Function: isWhitespace()
  Purpose:  Returns true if string parameter is empty or whitespace characters only.
\*--------------------------------------------------------------------------------------------*/
function isWhitespace(s)
{
  var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    for (i=0; i<s.length; i++)
    {   
        var c = s.charAt(i);
        if (whitespace.indexOf(c) == -1)
      return false;
    }

    return true;
}


/*----------------------------------------------------------------------------*\
  Function:   isValidDate()
  Purpose:    to check an incoming date is valid. If any of the date parameters  
              fail, it returns a string message denoting the problem.
  Parameters: month       - an integer between 1 and 12
              day         - an integer between 1 and 31 (depending on month)
              year        - a 4-digit integer value
              isLaterDate - a boolean value. If true, the function verifies the 
                            date being passed in is LATER than the current date.
\*----------------------------------------------------------------------------*/
function isValidDate(month, day, year, isLaterDate)
{

  // depending on the year, calculate the number of days in the month
  if (year % 4 == 0)      // LEAP YEAR 
    daysInMonth = new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
  else
    daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);


  // first, check the incoming month and year are valid. 
  if (!month || !day || !year)          return false;
  if (1 > month || month > 12)          return false;
  if (year < 0)                         return false;
  if (1 > day || day > daysInMonth[month-1]) return false;


  // if required, verify the incoming date is LATER than the current date.
  if (isLaterDate)
  {
    // get current date
    var today = new Date();
    var currMonth = today.getMonth() + 1; // since returns 0-11
    var currDay   = today.getDate();
    var currYear  = today.getFullYear();

    // zero-pad today's month & day
    if (String(currMonth).length == 1)  currMonth = "0" + currMonth;
    if (String(currDay).length == 1)  currDay   = "0" + currDay;    
    currDate = String(currYear) + String(currMonth) + String(currDay);
    
    // zero-pad incoming month & day
    if (String(month).length == 1)  month = "0" + month;
    if (String(day).length == 1)  day   = "0" + day;
    incomingDate = String(year) + String(month) + String(day);

    if (Number(currDate) > Number(incomingDate))
      return false;
  }
  
  return true;
}

//-->