
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function URLDecode (encodedString) {
  var output = encodedString;
  var binVal, thisString;
  var myregexp = /(%[^%]{2})/;
  while ((match = myregexp.exec(output)) != null
             && match.length > 1
             && match[1] != '') {
    binVal = parseInt(match[1].substr(1),16);
    thisString = String.fromCharCode(binVal);
    output = output.replace(match[1], thisString);
  }
  return output;
}

function fillInBlanks()
{
	if ($('ContactForm') && $('ContactForm').first_name && String(document.location).match(/first_name=([^&]+)/))
		$('ContactForm').first_name.value = URLDecode((String(document.location).match(/first_name=([^&]+)/))[1]);
	if ($('ContactForm') && $('ContactForm').last_name && String(document.location).match(/last_name=([^&]+)/))
		$('ContactForm').last_name.value = URLDecode((String(document.location).match(/last_name=([^&]+)/))[1]);
	if ($('ContactForm') && $('ContactForm').email_address && String(document.location).match(/T1=([^&]+)/))
		$('ContactForm').email_address.value = URLDecode((String(document.location).match(/T1=([^&]+)/))[1]);
	if ($('ContactForm') && $('ContactForm').zip && String(document.location).match(/zip=([^&]+)/))
		$('ContactForm').zip.value = URLDecode((String(document.location).match(/zip=([^&]+)/))[1]);
}

addLoadEvent(fillInBlanks);